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:
- Int - Integer
- Float - Floating-point number
- String - A sequence of characters
- Bool - a boolean value of either true or false
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 =
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 =
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; |
|
host : string option; |
|
name : string; |
|
static : bool; |
|
formals : var_def list; |
|
body : stmt list; |
|
section : class_section; |
|
inklass : string; |
|
uid : string; |
|
builtin : bool; |
}
We have four different kinds of callable code blocks: main, init, refine, method.
type member_def =
A member is either a variable or some sort of function
type class_sections_def = {
}
Things that can go in a class
type class_def = {
}
The basic class definition
type program = class_def list
A program, right and proper