diff options
| author | Eugen Wissner <belka@caraus.de> | 2024-07-24 01:22:20 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2024-07-24 01:22:20 +0200 |
| commit | 947c5aa7efba507a849463fcf813b3cc61042845 (patch) | |
| tree | e10fe357e91389325ddd647b79c71b0b69cabc38 /lib/Language/Elna/AST.hs | |
| parent | 9d1f0385945e926e7084e60fc72fe5846e7139b2 (diff) | |
| download | elna-947c5aa7efba507a849463fcf813b3cc61042845.tar.gz | |
Parse expressions
Diffstat (limited to 'lib/Language/Elna/AST.hs')
| -rw-r--r-- | lib/Language/Elna/AST.hs | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/lib/Language/Elna/AST.hs b/lib/Language/Elna/AST.hs index fc4b264..0add1d2 100644 --- a/lib/Language/Elna/AST.hs +++ b/lib/Language/Elna/AST.hs @@ -61,9 +61,6 @@ data Expression = VariableExpression Identifier | LiteralExpression Literal | NegationExpression Expression - | NotExpression Expression - | ReferenceExpression Expression - | DereferenceExpression Expression | SumExpression Expression Expression | SubtractionExpression Expression Expression | ProductExpression Expression Expression @@ -74,7 +71,7 @@ data Expression | GreaterExpression Expression Expression | LessOrEqualExpression Expression Expression | GreaterOrEqualExpression Expression Expression - | FieldExpression Expression Identifier + | ArrayExpression Expression Expression deriving Eq instance Show Expression @@ -82,9 +79,6 @@ instance Show Expression show (VariableExpression variable) = show variable show (LiteralExpression literal) = show literal show (NegationExpression negation) = '-' : show negation - show (NotExpression negation) = "not " <> show negation - show (ReferenceExpression reference) = '@' : show reference - show (DereferenceExpression dereference) = show dereference <> "^" show (SumExpression lhs rhs) = concat [show lhs, " + ", show rhs] show (SubtractionExpression lhs rhs) = concat [show lhs, " - ", show rhs] show (ProductExpression lhs rhs) = concat [show lhs, " * ", show rhs] @@ -95,8 +89,8 @@ instance Show Expression show (GreaterExpression lhs rhs) = concat [show lhs, " > ", show rhs] show (LessOrEqualExpression lhs rhs) = concat [show lhs, " <= ", show rhs] show (GreaterOrEqualExpression lhs rhs) = concat [show lhs, " >= ", show rhs] - show (FieldExpression fieldExpression identifier) = - show fieldExpression <> "." <> show identifier + show (ArrayExpression arrayExpression indexExpression) = + concat [show arrayExpression, "[", show indexExpression, "]"] data Statement = EmptyStatement |
