Module Ast

module Ast: sig .. end
The abstract syntax tree for Gamma

type lit = 
| Int of int
| Float of float
| String of string
| Bool of bool
The four literal classes of Gamma:
type arith = 
| Add
| Sub
| Prod
| Div
| Mod
| Neg
| Pow
The binary arithmatic operators
type numtest = 
| Eq
| Neq
| Less
| Grtr
| Leq
| Geq
The binary comparison operators
type combtest = 
| And
| Or
| Nand
| Nor
| Xor
| Not
The binary boolean operators
type op = 
| Arithmetic of arith
| NumTest of numtest
| CombTest of combtest
All three sets of binary operators
type expr = 
| This
| Null
| Id of string
| NewObj of string * expr list
| Anonymous of string * expr list * func_def list
| Literal of lit
| Assign of expr * expr
| Deref of expr * expr
| Field of expr * string
| Invoc of expr * string * expr list
| Unop of op * expr
| Binop of expr * op * expr
| Refine of string * expr list * string option
| Refinable of string
The various types of expressions we can have.
type var_def = string * string 
The basic variable definition, a type and an id
type stmt = 
| Decl of var_def * expr option
| If of (expr option * stmt list) list
| While of expr * stmt list
| Expr of expr
| Return of expr option
| Super of expr list
The basic statements: Variable declarations, control statements, assignments, return statements, and super class expressions
type class_section = 
| Publics
| Protects
| Privates
| Refines
| Mains
Three access levels, the refinements, and the main function
type func_def = {
   returns : string option; (*A return type (method/refine)*)
   host : string option; (*A host class (refine)*)
   name : string; (*The function name (all)*)
   static : bool; (*If the function is static (main)*)
   formals : var_def list; (*A list of all formal parameters of the function (all)*)
   body : stmt list; (*A list of statements that form the function body (all)*)
   section : class_section; (*A sementic tag of the class section in which the function lives (all)*)
   inklass : string; (*A semantic tag of the class in which the function lives (all)*)
   uid : string; (*A string for referencing this -- should be maintained in transformations to later ASTs*)
   builtin : bool; (*Whether or not the function is built in (uid should have _ in it then)*)
}
We have four different kinds of callable code blocks: main, init, refine, method.
type member_def = 
| VarMem of var_def
| MethodMem of func_def
| InitMem of func_def
A member is either a variable or some sort of function
type class_sections_def = {
   privates : member_def list;
   protects : member_def list;
   publics : member_def list;
   refines : func_def list;
   mains : func_def list;
}
Things that can go in a class
type class_def = {
   klass : string; (*A name string*)
   parent : string option; (*The parent class name*)
   sections : class_sections_def; (*The five sections*)
}
The basic class definition
type program = class_def list 
A program, right and proper