aboutsummaryrefslogtreecommitdiffstats
path: root/src/Parser.hs
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2022-12-08 13:16:16 +0200
committerJan Tuomi <jans.tuomi@gmail.com>2022-12-08 13:16:32 +0200
commit723fa29e5ceb2f7ee4a13632ccfe3acf5e8808c2 (patch)
tree239124e9d389e65568c8527014521568e147fe41 /src/Parser.hs
parentd91979adb9dc6eaa96f37ac0af337fed1aed08af (diff)
Add :tag AST, refactor core to use it
Diffstat (limited to 'src/Parser.hs')
-rw-r--r--src/Parser.hs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/Parser.hs b/src/Parser.hs
index 959a630..e7c0701 100644
--- a/src/Parser.hs
+++ b/src/Parser.hs
@@ -26,6 +26,8 @@ validateBalance allowed asts = do
parseToken :: Token -> AST
parseToken (Token token tr tc tf)
+ | isTag token = let tok = tail token
+ in ast $ ASTTag (computeTagN tok) tok
| isString token = ast $ ASTString $ removeQuotes token
| isInteger token = ast $ ASTInteger (read token)
| isDouble token = ast $ ASTDouble (read token)
@@ -39,6 +41,7 @@ parseToken (Token token tr tc tf)
isDouble :: String -> Bool
isDouble t = t =~ doubleRegex
isString t = "\"" `L.isPrefixOf` t
+ isTag t = ":" `L.isPrefixOf` t && length t > 1
removeQuotes s = drop 1 s $> take (length s - 2)
isBoolean t = t `elem` ["true", "false"]
asBoolean t = t == "true"