diff options
author | Einhard Leichtfuß <alguien@respiranto.de> | 2025-05-19 01:57:15 +0200 |
---|---|---|
committer | Einhard Leichtfuß <alguien@respiranto.de> | 2025-05-19 01:57:15 +0200 |
commit | 96b767d7cab6c8ca41f656e41dd57196cb45e233 (patch) | |
tree | 4d551007ae81f52a9430298867664649b66f59fc /src/Language/SimpleShell/AST | |
parent | 3b8dda1e8dc86cd584ee8cba0435abb6bca4301d (diff) |
Expression AST and parser
Deleted old AST.hs; old code shall re-appear.
Diffstat (limited to 'src/Language/SimpleShell/AST')
-rw-r--r-- | src/Language/SimpleShell/AST/Expr.hs | 47 | ||||
-rw-r--r-- | src/Language/SimpleShell/AST/SimpleType.hs | 14 |
2 files changed, 61 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) diff --git a/src/Language/SimpleShell/AST/SimpleType.hs b/src/Language/SimpleShell/AST/SimpleType.hs new file mode 100644 index 0000000..733f19a --- /dev/null +++ b/src/Language/SimpleShell/AST/SimpleType.hs @@ -0,0 +1,14 @@ +module Language.SimpleShell.AST.SimpleType + ( SimpleType(..) + , FunSig + ) +where + + +data SimpleType + = IntType + | StrType + | BoolType + deriving (Show, Eq) + +type FunSig = (SimpleType, [SimpleType]) |