Blame view

src/SML/ast.sig 1.01 KB
Ulrich Schoepp committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
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