diff options
| author | Eugen Wissner <belka@caraus.de> | 2024-11-06 22:23:49 +0100 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2024-11-06 22:23:49 +0100 |
| commit | 060496fc6ee331e2710ff8ade23317a0a79cbd6c (patch) | |
| tree | 9af7b8f8767449bea7ae9a76e244141118ae5e75 /lib/Language/Elna/Frontend/Parser.hs | |
| parent | e2d4b76c0bbad6c0740f5322e862a02971802e87 (diff) | |
| download | elna-060496fc6ee331e2710ff8ade23317a0a79cbd6c.tar.gz | |
Parse local variables
Diffstat (limited to 'lib/Language/Elna/Frontend/Parser.hs')
| -rw-r--r-- | lib/Language/Elna/Frontend/Parser.hs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/Language/Elna/Frontend/Parser.hs b/lib/Language/Elna/Frontend/Parser.hs index a8e61d2..98638f7 100644 --- a/lib/Language/Elna/Frontend/Parser.hs +++ b/lib/Language/Elna/Frontend/Parser.hs @@ -16,7 +16,7 @@ import Language.Elna.Frontend.AST , Statement(..) , TypeExpression(..) , VariableDeclaration(..) - --, VariableAccess(..) + , VariableAccess(..) , Condition(..) , Expression(..) , Literal(..) @@ -64,7 +64,7 @@ termP :: Parser Expression termP = choice [ parensP expressionP , LiteralExpression <$> literalP - -- , VariableExpression <$> variableAccessP + , VariableExpression <$> variableAccessP ] operatorTable :: [[Operator Parser Expression]] @@ -91,13 +91,13 @@ operatorTable = expressionP :: Parser Expression expressionP = makeExprParser termP operatorTable -{- + variableAccessP :: Parser VariableAccess -variableAccessP = do +variableAccessP = VariableAccess <$> identifierP {- do identifier <- identifierP indices <- many $ bracketsP expressionP - pure $ foldr (flip ArrayAccess) (VariableAccess identifier) indices --} + pure $ foldr (flip ArrayAccess) (VariableAccess identifier) indices -} + conditionP :: Parser Condition conditionP = do lhs <- expressionP @@ -187,8 +187,8 @@ statementP = EmptyStatement <$ semicolonP <|> ifElseP <|> CompoundStatement <$> blockP (many statementP) - {-<|> try assignmentP - <|> try whileP -} + <|> try assignmentP + -- <|> try whileP <|> callP <?> "statement" where @@ -202,12 +202,12 @@ statementP <*> optional (symbol "else" *> statementP) {-whileP = WhileStatement <$> (symbol "while" *> parensP conditionP) - <*> statementP + <*> statementP -} assignmentP = AssignmentStatement <$> variableAccessP <* symbol ":=" <*> expressionP - <* semicolonP -} + <* semicolonP variableDeclarationP :: Parser VariableDeclaration variableDeclarationP = VariableDeclaration |
