|
|
@@ -10,38 +10,38 @@ type ctype = Void | Bool | Int | Float
|
|
|
and node =
|
|
|
(* global *)
|
|
|
| Program of node list * loc
|
|
|
- | Param of ctype * string * loc
|
|
|
- | FunDec of ctype * string * node list * loc
|
|
|
- | FunDef of bool * ctype * string * node list * node list * loc
|
|
|
- | GlobalDec of ctype * string * loc
|
|
|
- | GlobalDef of bool * ctype * string * node option * loc
|
|
|
+ | Param of ctype * string
|
|
|
+ | FunDec of ctype * string * node list
|
|
|
+ | FunDef of bool * ctype * string * node list * node list
|
|
|
+ | GlobalDec of ctype * string
|
|
|
+ | GlobalDef of bool * ctype * string * node option
|
|
|
|
|
|
(* statements *)
|
|
|
- | VarDec of ctype * string * node option * loc
|
|
|
- | Assign of string * node * loc
|
|
|
- | Return of node * loc
|
|
|
- | If of node * node list * loc
|
|
|
- | IfElse of node * node list * node list * loc
|
|
|
- | While of node * node list * loc
|
|
|
- | DoWhile of node * node list * loc
|
|
|
- | For of string * node * node * node * node list * loc
|
|
|
- | Allocate of string * node list * loc
|
|
|
- | Expr of node * loc
|
|
|
- | Statements of node list * loc
|
|
|
+ | VarDec of ctype * string * node option
|
|
|
+ | Assign of string * node
|
|
|
+ | Return of node
|
|
|
+ | If of node * node list
|
|
|
+ | IfElse of node * node list * node list
|
|
|
+ | While of node * node list
|
|
|
+ | DoWhile of node * node list
|
|
|
+ | For of string * node * node * node * node list
|
|
|
+ | Allocate of string * node list
|
|
|
+ | Expr of node
|
|
|
+ | Statements of node list
|
|
|
|
|
|
(* expressions *)
|
|
|
- | BoolConst of bool * loc
|
|
|
- | IntConst of int * loc
|
|
|
- | FloatConst of float * loc
|
|
|
- | ArrayConst of node list * loc
|
|
|
- | ArrayScalar of node * loc
|
|
|
- | Var of string * loc
|
|
|
- | Deref of string * node list * loc
|
|
|
- | Monop of monop * node * loc
|
|
|
- | Binop of binop * node * node * loc
|
|
|
- | Cond of node * node * node * loc
|
|
|
- | TypeCast of ctype * node * loc
|
|
|
- | FunCall of string * node list * loc
|
|
|
+ | BoolConst of bool
|
|
|
+ | IntConst of int
|
|
|
+ | FloatConst of float
|
|
|
+ | ArrayConst of node list
|
|
|
+ | ArrayScalar of node
|
|
|
+ | Var of string
|
|
|
+ | Deref of string * node list
|
|
|
+ | Monop of monop * node
|
|
|
+ | Binop of binop * node * node
|
|
|
+ | Cond of node * node * node
|
|
|
+ | TypeCast of ctype * node
|
|
|
+ | FunCall of string * node list
|
|
|
|
|
|
(* intermediate representations between phases *)
|
|
|
type repr =
|