on master help sign in
Make the char parser more restrictive to try to get better errors.

Before it permitted sequences of unescaped chars.

commit62bd7208822d037d07802709ecc2ac0356188584 authorEvan Czaplicki <info@elm-lang.org> dateWed 8 Jan 2014, 11:36 (13 years ago) parent61dd68b
1 file changed+5−2
compiler/Parse/Helpers.hs+5−2
compiler/Parse/Helpers.hs+5−2
@@ -351,9 +351,12 @@ escaped delim = try $ do
351351chr :: IParser Char
352352chr = betwixt '\'' '\'' character <?> "character"
353353 where
354+ nonQuote = satisfy (/='\'')
354355 character = do
355− c <- many1 $ choice [ escaped '\'', (:[]) <$> satisfy (/='\'') ]
356− processAs T.charLiteral . sandwich '\'' $ concat c
356+ c <- choice [ escaped '\''
357+ , (:) <$> char '\\' <*> many1 nonQuote
358+ , (:[]) <$> nonQuote ]
359+ processAs T.charLiteral $ sandwich '\'' c
357360
358361processAs :: (T.GenTokenParser String u SourceM -> IParser a) -> String -> IParser a
359362processAs processor s = calloutParser s (processor lexer)