From 5e7d3a5ff586ac75b768a9a1c1f2d5b80960e821 Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 3 Jun 2020 15:41:17 +0200 Subject: Back to where I was but without the mess --- src/parser/Statement.hs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/parser/Statement.hs (limited to 'src/parser/Statement.hs') diff --git a/src/parser/Statement.hs b/src/parser/Statement.hs new file mode 100644 index 0000000..ca16eca --- /dev/null +++ b/src/parser/Statement.hs @@ -0,0 +1,27 @@ +module Parser.Statement where + +import Control.Applicative + +import Expr +import Parser.Core +import Parser.Expr + + +data Statement + = Evaluation Expr + | VariableDeclaration String Expr + | FunctionDeclaration String String Expr + +statementP :: Parser Statement +statementP = functionDeclarationP <|> variableDeclarationP <|> evaluationP + where + functionDeclarationP = FunctionDeclaration + <$> alphaStringP + <*> parenthesis alphaStringP + <*> (char '=' *> exprP) + + variableDeclarationP = VariableDeclaration + <$> alphaStringP + <*> (char '=' *> exprP) + + evaluationP = Evaluation <$> exprP <* char '=' <* char '?' -- cgit