| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- type loc = string * int * int * int * int
- let noloc = ("", 0, 0, 0, 0)
- type operator = Neg | Not
- | Add | Sub | Mul | Div | Mod
- | Eq | Ne | Lt | Le | Gt | Ge
- | And | Or
- type ctype = Void | Bool | Int | Float
- | ArrayDec of ctype * node list
- | ArrayDef of ctype * node list
- | ArraySpec of ctype * int
- and node =
- (* global *)
- | Program of node list * loc
- | Param of ctype * string * loc
- | Dim of string * loc
- | FunDec of ctype * string * node list * loc
- | FunDef of bool * ctype * string * node list * node * loc
- | GlobalDec of ctype * string * loc
- | GlobalDef of bool * ctype * string * node option * loc
- (* statements *)
- | VarDec of ctype * string * node option * loc
- | Assign of string * node list option * node * loc
- | Return of node * loc
- | If of node * node * loc
- | IfElse of node * node * node * loc
- | While of node * node * loc
- | DoWhile of node * node * loc
- | For of string * node * node * node * node * loc
- | Allocate of string * node list * node * loc
- | Expr of node
- | Block of node list
- (* expressions *)
- | BoolConst of bool * loc
- | IntConst of int * loc
- | FloatConst of float * loc
- | ArrayConst of node list * loc
- | Var of string * loc
- | Deref of string * node list * loc
- | Monop of operator * node * loc
- | Binop of operator * node * node * loc
- | TypeCast of ctype * node * loc
- | FunCall of string * node list * loc
- | Arg of node
- (* additional types for convenience in traversals *)
- | ArrayScalar of node
- | ArrayInit of node * ctype
- | Cond of node * node * node * loc
- | VarLet of node * ctype * int
- | VarUse of node * ctype * int
- | FunUse of node * node * int
- | DimDec of node
- | Type of node * ctype
- | DummyNode
- (* container for command-line arguments *)
- type args = {
- mutable infile : string option;
- mutable outfile : string option;
- mutable verbose : int;
- mutable cpp : bool;
- }
- (* intermediate representations between phases *)
- type intermediate =
- | Args of args
- | FileContent of string * string * args
- | Ast of node * args
- | Assembly of string list * args
- (* exceptions *)
- exception LocError of loc * string
- exception NodeError of node * string
- exception CompileError of string
- exception EmptyError
- exception InvalidNode
- exception InvalidInput of string
|