Module Ast
module Ast: sig .. end
Definition of the parser generated AST and the runtime AST
Author(s): Tony BenBrahim < tony.benbrahim at gmail.com >
type operator =
| |
Plus |
| |
Minus |
| |
Times |
| |
Divide |
| |
Modulo |
| |
And |
| |
Or |
binary operation operators
type comparator =
| |
LessThan |
| |
LessThanEqual |
| |
Equal |
| |
GreaterThanEqual |
| |
GreaterThan |
| |
NotEqual |
binary comparaison operators
type variable_location =
| |
GlobalVar of int * int |
| |
LocalVar of int * int * int |
location for a variable in the runtime AST
for globals, unique id * an index into the global variables array
for locals, unique id * an index into the current stackframe * an index into the stack
type replacement = string * expression
string replacement specification in a template instruction
type replacement_list = replacement list
list of replacements for a template instructions
type conditional_spec =
conditional replacement criteria for a template instruction
type replacement_spec = string * conditional_spec * replacement_list
a single instruction in a set of template instructions
type template_spec = string option * string
definition for a line in a template definition
type map_subtype =
| |
MapSubtype |
| |
ArraySubtype |
type of map variable, either a dictionary or an array
type variable_value =
| |
IntegerValue of int |
| |
FloatValue of float |
| |
StringValue of string |
| |
BooleanValue of bool |
| |
FunctionValue of string list * statement list |
| |
MapValue of (string, variable_value) Hashtbl.t * map_subtype |
| |
Void |
variable values used in parsing AST
type runtime_variable_value =
variable values used in runtime AST
type runtime_env = {
}
The runtime environment.
consists of a heap for globals and an array of stackframes to support nested functions
type lib_function_def = {
|
name : string list; |
|
args : string list; |
|
num_args : int; |
|
vararg : bool; |
|
code : runtime_env -> unit; |
}
Definition for a library function
type expression =
expressions used in parsing AST
type runtime_expression =
expressions used in runtime AST
type statement =
statements used in parsing AST
type runtime_statement =
statements used in runtime AST
val is_vararg : string -> bool
determines if a variable is a varag
Returns true if the variable is a vararg, false otherwise
varname : the variable name
val vararg_formalname : string -> string
retuns the name for a vararg
exception CFReturn of runtime_variable_value
control flow exception for return instruction
exception CFBreak
control flow exception for break instruction
exception CFContinue
control flow exception for continue instruction
exception CFUserException of runtime_variable_value * string
exception generated by interpreted throw exception