summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2024-09-18 20:50:34 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2024-09-18 20:50:34 +0200
commitcf508f90bc3c51ef01de1f66226d8168cb1630fe (patch)
tree19db7e7a23b5d8116d69aff5c795e1e7f9a388be /src
parent31fd34766e33f8334c3fbcbfba2a0e1314b4f334 (diff)
Make sure identifier starts with a letter
Diffstat (limited to 'src')
-rw-r--r--src/Parser/Expr.hs9
1 files changed, 6 insertions, 3 deletions
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