diff options
author | Marvin Borner | 2022-08-10 18:53:34 +0200 |
---|---|---|
committer | Marvin Borner | 2022-08-10 18:53:34 +0200 |
commit | 792534b3888bc1b9c33047f1c312c4e17a720885 (patch) | |
tree | b0401f5c1ca156858fb7de94a5488151be075c89 /src/Parser.hs | |
parent | cba3d7d21241f8db913e6e2733a8edc3a522ee62 (diff) |
Added syntactic sugar for strings & chars
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 |