ast.sig 1.01 KB
signature AST = sig

datatype binop =
    Add
  | Sub
  | Mul
  | Div
  | Lt
  | StrictAnd

datatype ty =
    Int
  | Void
  | Bool
  | Array of ty
  | Class of string

datatype exp =
    Id of string
  | Number of int
  | Op of exp * binop * exp
  | Invoke of exp * string * (exp list)
  | ArrayGet of exp * exp
  | ArrayLength of exp
  | True
  | False
  | This
  | New of string
  | NewIntArray of exp
  | Neg of exp
  | Read
and stm =
    Assignment of string * exp
  | ArrayAssignment of string * exp * exp
  | If of exp * stm * stm
  | While of exp * stm
  | Write of exp
  | Println of exp
  | Seq of (stm list)

type method_decl = {
  method_name: string,
  return_type: ty,
  parameters: (string * ty) list,
  throws_ioexception: bool,
  locals: (string * ty) list,
  body: stm,
  return_exp: exp
}

type class_decl = {
  class_name: string,
  fields: (string * ty) list,
  methods: method_decl list
}

type program = {
  main_class: string,
  main_throws_ioexception: bool,
  main_body: stm,
  classes: class_decl list
}

end