From 8760f73d38c4bdde10cdfc22cd2cc83ce6dbda27 Mon Sep 17 00:00:00 2001 From: Jan Mas Rovira Date: Wed, 16 Mar 2022 12:39:50 +0100 Subject: [PATCH] [parser] allow '-' as the first character of an identifier. Use try for literals --- src/MiniJuvix/Syntax/Concrete/Lexer.hs | 1 - src/MiniJuvix/Syntax/Concrete/Parser.hs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/MiniJuvix/Syntax/Concrete/Lexer.hs b/src/MiniJuvix/Syntax/Concrete/Lexer.hs index d92812d5a..395841325 100644 --- a/src/MiniJuvix/Syntax/Concrete/Lexer.hs +++ b/src/MiniJuvix/Syntax/Concrete/Lexer.hs @@ -86,7 +86,6 @@ bareIdentifier = interval $ do isAlphaNum c || validFirstChar c validFirstChar :: Char -> Bool validFirstChar c = - c /= '-' && or [ isLetter c, cat == MathSymbol, diff --git a/src/MiniJuvix/Syntax/Concrete/Parser.hs b/src/MiniJuvix/Syntax/Concrete/Parser.hs index 25e252114..39eaaf96d 100644 --- a/src/MiniJuvix/Syntax/Concrete/Parser.hs +++ b/src/MiniJuvix/Syntax/Concrete/Parser.hs @@ -123,7 +123,7 @@ import_ = do expressionAtom :: MonadParsec e Text m => m (ExpressionAtom 'Parsed) expressionAtom = do - AtomLiteral <$> literal + AtomLiteral <$> P.try literal <|> AtomIdentifier <$> name <|> (AtomUniverse <$> universe) <|> (AtomLambda <$> lambda)