From cf508f90bc3c51ef01de1f66226d8168cb1630fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Wed, 18 Sep 2024 20:50:34 +0200 Subject: Make sure identifier starts with a letter --- src/Parser/Expr.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/Parser/Expr.hs') diff --git a/src/Parser/Expr.hs b/src/Parser/Expr.hs index a228ad0..835c58d 100644 --- a/src/Parser/Expr.hs +++ b/src/Parser/Expr.hs @@ -34,11 +34,14 @@ import Parser.Core import Test identifier :: TestParser Text -identifier = do - lexeme $ TL.toStrict <$> takeWhile1P Nothing (\x -> isAlphaNum x || x == '_') +identifier = label "identifier" $ do + lexeme $ do + lead <- lowerChar + rest <- takeWhileP Nothing (\x -> isAlphaNum x || x == '_') + return $ TL.toStrict $ TL.fromChunks $ (T.singleton lead :) $ TL.toChunks rest varName :: TestParser VarName -varName = VarName <$> identifier +varName = label "variable name" $ VarName <$> identifier newVarName :: forall a. ExprType a => TestParser (TypedVarName a) newVarName = do -- cgit v1.2.3