(* Abstract syntax of uC, an imperative language sestoft@dina.kvl.dk 2001-03-18 *) datatype constant = CstI of int (* Integer constant *) | CstN (* The null object reference *) datatype typ = TypI (* Type int *) | TypC (* Type char *) | TypA of typ * expr option (* Array type *) | TypP of typ (* Pointer type *) and expr = Access of access (* Variable or element access *) | Assign of access * expr (* Assignment to var or elt *) | Addr of access (* Get address *) | Cst of constant (* Constant *) | Prim1 of string * expr (* Strict primitive operator *) | Prim2 of string * expr * expr (* Strict primitive operator *) | Andalso of expr * expr (* Sequential and *) | Orelse of expr * expr (* Sequential or *) | Call of string * expr list (* Function call f(...) *) and access = AccVar of string (* Variable access *) | AccDeref of expr (* Dereferencing of a pointer *) | AccIndex of access * expr (* Array indexing *) and stmt = If of expr * stmt * stmt (* Conditional *) | While of expr * stmt (* While loop *) | Expr of expr (* Expression (as in C or Java) *) | Return of expr option (* Return from method *) | Block of stmtordec list (* Block: grouping and scope *) and stmtordec = Dec of typ * string (* Declaration of local variable *) | Stmt of stmt (* A statement *) and topdec = Fundec of typ option * string * paramdec list * stmt | Vardec of typ * string and program = Prog of topdec list withtype paramdec = typ * string