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/AST.hs | |
| parent | 87f183baad01f2b572f5f9051895b5876a56dd4c (diff) | |
| download | elna-0850f0a8d66af028e32a79063cdad328b70db909.tar.gz | |
Implement if statements with equality
Diffstat (limited to 'lib/Language/Elna/Frontend/AST.hs')
| -rw-r--r-- | lib/Language/Elna/Frontend/AST.hs | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/lib/Language/Elna/Frontend/AST.hs b/lib/Language/Elna/Frontend/AST.hs index b9ed539..68ac581 100644 --- a/lib/Language/Elna/Frontend/AST.hs +++ b/lib/Language/Elna/Frontend/AST.hs @@ -6,8 +6,8 @@ module Language.Elna.Frontend.AST , Statement(..) , TypeExpression(..) , VariableDeclaration(..) - {-, VariableAccess(..) - , Condition(..)-} + --, VariableAccess(..) + , Condition(..) , Expression(..) , Literal(..) ) where @@ -67,8 +67,8 @@ instance Show TypeExpression data Statement = EmptyStatement - {-| AssignmentStatement VariableAccess Expression | IfStatement Condition Statement (Maybe Statement) + {-| AssignmentStatement VariableAccess Expression | WhileStatement Condition Statement -} | CompoundStatement [Statement] | CallStatement Identifier [Expression] @@ -77,13 +77,13 @@ data Statement instance Show Statement where show EmptyStatement = ";" - {-show (AssignmentStatement lhs rhs) = - concat [show lhs, " := ", show rhs, ";"] show (IfStatement condition if' else') = concat [ "if (", show condition, ") " , show if' , maybe "" ((<> " else ") . show) else' ] + {-show (AssignmentStatement lhs rhs) = + concat [show lhs, " := ", show rhs, ";"] show (WhileStatement expression statement) = concat ["while (", show expression, ") ", show statement, ";"]-} show (CompoundStatement statements) = @@ -143,22 +143,21 @@ instance Show VariableAccess show (VariableAccess variableName) = show variableName show (ArrayAccess arrayAccess elementIndex) = concat [show arrayAccess, "[", show elementIndex, "]"] - +-} data Condition = EqualCondition Expression Expression - | NonEqualCondition Expression Expression - | LessCondition Expression Expression - | GreaterCondition Expression Expression - | LessOrEqualCondition Expression Expression - | GreaterOrEqualCondition Expression Expression + -- | NonEqualCondition Expression Expression + -- | LessCondition Expression Expression + -- | GreaterCondition Expression Expression + -- | LessOrEqualCondition Expression Expression + -- | GreaterOrEqualCondition Expression Expression deriving Eq instance Show Condition where show (EqualCondition lhs rhs) = concat [show lhs, " = ", show rhs] - show (NonEqualCondition lhs rhs) = concat [show lhs, " # ", show rhs] - show (LessCondition lhs rhs) = concat [show lhs, " < ", show rhs] - show (GreaterCondition lhs rhs) = concat [show lhs, " > ", show rhs] - show (LessOrEqualCondition lhs rhs) = concat [show lhs, " <= ", show rhs] - show (GreaterOrEqualCondition lhs rhs) = concat [show lhs, " >= ", show rhs] --} + -- show (NonEqualCondition lhs rhs) = concat [show lhs, " # ", show rhs] + -- show (LessCondition lhs rhs) = concat [show lhs, " < ", show rhs] + -- show (GreaterCondition lhs rhs) = concat [show lhs, " > ", show rhs] + -- show (LessOrEqualCondition lhs rhs) = concat [show lhs, " <= ", show rhs] + -- show (GreaterOrEqualCondition lhs rhs) = concat [show lhs, " >= ", show rhs] |
