aboutsummaryrefslogtreecommitdiff
path: root/src/Ast.hs
blob: c43eed43af9461bc0205b8a3ce8b3eaf7b619e69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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)