on master help sign in
Make the char parser more restrictive to try to get better errors.
62bd720Evan Czaplicki
compiler/Parse/Helpers.hs+5−2
@@ -351,9 +351,12 @@ escaped delim = try $ do
351chr :: IParser Char
351chr :: IParser Char
352chr = betwixt '\'' '\'' character <?> "character"
352chr = betwixt '\'' '\'' character <?> "character"
353 where
353 where
354+ nonQuote = satisfy (/='\'')
354 character = do
355 character = do
355− c <- many1 $ choice [ escaped '\'', (:[]) <$> satisfy (/='\'') ]
356+ c <- choice [ escaped '\''
357+ , (:) <$> char '\\' <*> many1 nonQuote
358+ , (:[]) <$> nonQuote ]
356− processAs T.charLiteral . sandwich '\'' $ concat c
359+ processAs T.charLiteral $ sandwich '\'' c
357
360
358processAs :: (T.GenTokenParser String u SourceM -> IParser a) -> String -> IParser a
361processAs :: (T.GenTokenParser String u SourceM -> IParser a) -> String -> IParser a
359processAs processor s = calloutParser s (processor lexer)
362processAs processor s = calloutParser s (processor lexer)