aboutsummaryrefslogtreecommitdiff
path: root/src/Language/SimpleShell/AST/Expr.hs
diff options
context:
space:
mode:
authorEinhard Leichtfuß <alguien@respiranto.de>2025-05-19 01:57:15 +0200
committerEinhard Leichtfuß <alguien@respiranto.de>2025-05-19 01:57:15 +0200
commit96b767d7cab6c8ca41f656e41dd57196cb45e233 (patch)
tree4d551007ae81f52a9430298867664649b66f59fc /src/Language/SimpleShell/AST/Expr.hs
parent3b8dda1e8dc86cd584ee8cba0435abb6bca4301d (diff)
Expression AST and parser
Deleted old AST.hs; old code shall re-appear.
Diffstat (limited to 'src/Language/SimpleShell/AST/Expr.hs')
-rw-r--r--src/Language/SimpleShell/AST/Expr.hs47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/Language/SimpleShell/AST/Expr.hs b/src/Language/SimpleShell/AST/Expr.hs
new file mode 100644
index 0000000..0aaf16d
--- /dev/null
+++ b/src/Language/SimpleShell/AST/Expr.hs
@@ -0,0 +1,47 @@
+module Language.SimpleShell.AST.Expr
+ ( Expr(..)
+ , TypedExpr
+ , VarName
+ , FunName
+ )
+where
+
+
+import Language.SimpleShell.AST.SimpleType (SimpleType)
+
+import Data.Text (Text)
+
+
+type VarName = Text
+type FunName = Text
+
+
+-- | Pure expression (no side effects).
+data Expr
+ = IntLiteral Integer
+ | StrLiteral String
+ | BoolLiteral Bool
+ | Var VarName
+ | FunCall FunName [Expr]
+ | And Expr Expr
+ | Or Expr Expr
+ | Not Expr
+ | Eq Expr Expr
+ | Neq Expr Expr
+ | Gt Expr Expr
+ | Ge Expr Expr
+ | Lt Expr Expr
+ | Le Expr Expr
+ | Add Expr Expr
+ | Sub Expr Expr
+ | Mul Expr Expr
+ | Div Expr Expr
+ | UMinus Expr
+ | Concat Expr Expr
+ | Ternary Expr Expr Expr
+ | Length Expr
+ | IntCast Expr
+ | StrCast Expr
+ deriving (Show)
+
+type TypedExpr = (SimpleType, Expr)