diff options
Diffstat (limited to 'src/Parser.hs')
-rw-r--r-- | src/Parser.hs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Parser.hs b/src/Parser.hs index 5d62ab0..1d889d3 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -73,6 +73,16 @@ parseNumeral = do number :: Parser Integer number = ap sign nat +parseString :: Parser Expression +parseString = do + str <- between (char '\"') (char '\"') (some $ satisfy (`notElem` "\"\\")) + pure (stringToExpression str) <?> "string" + +parseChar :: Parser Expression +parseChar = do + ch <- between (char '\'') (char '\'') (satisfy (`notElem` "\"\\")) + pure (charToExpression ch) <?> "char" + parseVariable :: Parser Expression parseVariable = do var <- identifier @@ -82,6 +92,8 @@ parseSingleton :: Parser Expression parseSingleton = parseBruijn <|> parseNumeral + <|> parseString + <|> parseChar <|> parseAbstraction <|> (parens parseApplication <?> "enclosed application") <|> parseVariable |