diff options
Diffstat (limited to 'src/Parser.hs')
-rw-r--r-- | src/Parser.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Parser.hs b/src/Parser.hs index b67ce55..51fc0f0 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -208,6 +208,19 @@ regex = label "regular expression" $ lexeme $ do _ <- eval expr -- test regex parsing with empty variables return expr +list :: TestParser SomeExpr +list = label "list" $ do + symbol "[" + SomeExpr x <- someExpr + choice + [do symbol "]" + return $ SomeExpr $ UnOp (:[]) x + ,do symbol "," + xs <- listOf typedExpr + symbol "]" + return $ SomeExpr $ foldr (BinOp (:)) (Literal []) (x:xs) + ] + data SomeExpr = forall a. ExprType a => SomeExpr (Expr a) data SomeUnOp = forall a b. (ExprType a, ExprType b) => SomeUnOp (a -> b) @@ -310,6 +323,7 @@ someExpr = join inner <?> "expression" [ return <$> numberLiteral , return . SomeExpr <$> quotedString , return . SomeExpr <$> regex + , return <$> list ] variable = label "variable" $ do |