aboutsummaryrefslogtreecommitdiff
path: root/src/parser/Core.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser/Core.hs')
-rw-r--r--src/parser/Core.hs15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/parser/Core.hs b/src/parser/Core.hs
index 5928fe4..64e0b84 100644
--- a/src/parser/Core.hs
+++ b/src/parser/Core.hs
@@ -100,13 +100,16 @@ choice :: [Parser a] -> Parser a
choice [] = empty
choice (p:ps) = p <|> choice ps
--- verify :: (a -> Bool) -> Parser a -> Parser a
--- verify predicate p = do a <- p
--- if predicate a then p else Parser (\_ -> Left "Bonjour")
+verify :: (a -> Bool) -> a -> Parser a
+verify predicate x = if predicate x then pure x else empty
--- Parse a string of alpha character, converted to lower case
-labelP :: Parser String
-labelP = (map toLower) <$> some (satisfyChar isAlpha)
+-- Parse a string of alpha character
+-- Convert to lower case and check that the label isn't `i`
+varLabelP :: Parser String
+varLabelP = (map toLower <$> some (satisfyChar isAlpha)) >>= verify (/= "i")
+
+funLabelP :: Parser String
+funLabelP = map toLower <$> some (satisfyChar isAlpha)
floatP :: Parser Float