From 279f04cb63e45ceb9a9df82540d5362565b8b37b Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Fri, 12 Aug 2022 22:53:06 +0100 Subject: Initial import --- src/Ast.hs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/Ast.hs (limited to 'src/Ast.hs') diff --git a/src/Ast.hs b/src/Ast.hs new file mode 100644 index 0000000..c43eed4 --- /dev/null +++ b/src/Ast.hs @@ -0,0 +1,27 @@ +module Ast where + +import Text.Parsec (SourcePos) + +type Ident = String + +data Type = Type String | FuncType [Type] (Maybe Type) deriving (Eq, Ord, Show) + +type FuncParam = (Ident, Type, SourcePos) + +data Expr + = Num Integer SourcePos + | BinOp Op Expr Expr + | Var Ident SourcePos + | -- fn [params] return body private pos + Func Ident [FuncParam] (Maybe Type) [Expr] Bool SourcePos + | Call Expr [Expr] SourcePos + | Return (Maybe Expr) SourcePos + | Module String SourcePos + deriving (Eq, Ord, Show) + +data Op + = Plus + | Minus + | Mul + | Div + deriving (Eq, Ord, Show) -- cgit v1.2.3