]> ruin.nu Git - proglang.git/blob - Abs.hs
minor change
[proglang.git] / Abs.hs
1 {-
2 Abstract syntax for the language. This will be translated from the abstract syntax generated by bnfc.
3
4 The goal of this abstract syntax is to combine similar statements/expressions to be grouped together to simplify type checking and execution.
5
6 This abstract syntax is far from ready so far, but it gives a hint of what we are planning.
7 -}
8 module Abs (
9         Ident
10         ,Stm(...)
11         ,Exp(...)
12         ,Op(...)
13         ,BOp(...)
14 ) where
15
16 newtype Ident = Ident String deriving (Eq,Ord,Show)
17
18 type Program = [Stm]
19
20 data Stm = 
21           SNoop
22         | SDecl Type Ident Exp
23         | SExp Exp
24         | SBlock [Stm]
25         | SIf Exp Stm Stm
26         | SWhile Exp Stm
27         | SPrint Exp
28         deriving (Eq,Ord,Show)
29
30 data Exp =
31           EOp Op Exp Exp
32         | EBOp BOp Exp Exp
33         | EVar Ident
34         | EInt Integer
35         | EBool Bool
36         | ExpT Type Exp
37         | ENeg Exp
38         | ERead Type
39         deriving (Eq,Ord,Show)
40
41 data Op = Plus | Minus | Div | Times 
42 data BOp = Lt | Gt | Eq | Neq | ELt | EGt
43
44 data Type =
45           TInt
46         | TBool
47         deriving (Eq,Ord,Show)