(* Abstract syntax of uJava, a class-based OO language sestoft@dina.kvl.dk 2001-02-11, 2001-04-10 *) datatype constant = CstI of int (* Integer constant *) | CstS of string (* String constant *) | CstN (* The null object reference *) datatype typ = TypI (* Type int *) | TypO of string (* Class type (class name) *) datatype expr = GetLocal of string (* Argument or variable access *) | GetField of expr * string (* Field access o.f *) | Cst of constant (* Constant *) | New of string (* Create instance of a class *) | Prim1 of string * expr (* Strict primitive operator *) | Prim2 of string * expr * expr (* Strict primitive operator *) | PrimC of string * expr list (* Primitive function call *) | Andalso of expr * expr (* Sequential and *) | Orelse of expr * expr (* Sequential or *) | Call of expr * string * expr list (* Method invocation o.m(...) *) and stmt = SetLocal of string * expr (* Set argument or local variable *) | SetField of expr * string * expr (* Set field o.f *) | 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 memberdec = Methoddec of typ option * string * paramdec list * stmt | Fielddec of typ * string and classdec = Classdec of string * string * memberdec list withtype paramdec = typ * string