diff options
| author | Eugen Wissner <belka@caraus.de> | 2024-10-11 16:14:01 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2024-10-11 16:14:01 +0200 |
| commit | 0850f0a8d66af028e32a79063cdad328b70db909 (patch) | |
| tree | 8c1fa49d5476e706e94a7af62ce37b12ef65e32d /lib/Language/Elna/Frontend/Parser.hs | |
| parent | 87f183baad01f2b572f5f9051895b5876a56dd4c (diff) | |
| download | elna-0850f0a8d66af028e32a79063cdad328b70db909.tar.gz | |
Implement if statements with equality
Diffstat (limited to 'lib/Language/Elna/Frontend/Parser.hs')
| -rw-r--r-- | lib/Language/Elna/Frontend/Parser.hs | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/Language/Elna/Frontend/Parser.hs b/lib/Language/Elna/Frontend/Parser.hs index 9d6bb60..9dd3206 100644 --- a/lib/Language/Elna/Frontend/Parser.hs +++ b/lib/Language/Elna/Frontend/Parser.hs @@ -16,8 +16,8 @@ import Language.Elna.Frontend.AST , Statement(..) , TypeExpression(..) , VariableDeclaration(..) - {-, VariableAccess(..) - , Condition(..)-} + --, VariableAccess(..) + , Condition(..) , Expression(..) , Literal(..) ) @@ -97,7 +97,7 @@ variableAccessP = do identifier <- identifierP indices <- many $ bracketsP expressionP pure $ foldr (flip ArrayAccess) (VariableAccess identifier) indices - +-} conditionP :: Parser Condition conditionP = do lhs <- expressionP @@ -105,14 +105,14 @@ conditionP = do conditionCons lhs <$> expressionP where comparisonOperator = - [ symbol "<" >> pure LessCondition - , symbol "<=" >> pure LessOrEqualCondition - , symbol ">" >> pure GreaterCondition - , symbol ">=" >> pure GreaterOrEqualCondition - , symbol "=" >> pure EqualCondition - , symbol "#" >> pure NonEqualCondition + --, symbol "<" >> pure LessCondition + --, symbol "<=" >> pure LessOrEqualCondition + --, symbol ">" >> pure GreaterCondition + --, symbol ">=" >> pure GreaterOrEqualCondition + [ symbol "=" >> pure EqualCondition + --, symbol "#" >> pure NonEqualCondition ] --} + symbol :: Text -> Parser Text symbol = Lexer.symbol space @@ -182,22 +182,22 @@ procedureDeclarationP = procedureCons statementP :: Parser Statement statementP = EmptyStatement <$ semicolonP + <|> ifElseP {-<|> CompoundStatement <$> blockP (many statementP) <|> try assignmentP - <|> try ifElseP <|> try whileP -} - <|> try callP + <|> callP <?> "statement" where callP = CallStatement <$> identifierP <*> parensP (sepBy expressionP commaP) <* semicolonP - {-ifElseP = IfStatement + ifElseP = IfStatement <$> (symbol "if" *> parensP conditionP) <*> statementP <*> optional (symbol "else" *> statementP) - whileP = WhileStatement + {-whileP = WhileStatement <$> (symbol "while" *> parensP conditionP) <*> statementP assignmentP = AssignmentStatement |
