module Ast:Bombs-Must-Detonate: AST Definition & Print functionsig..end
Bombs-Must-Detonate : AST Types
Author(s): Brian Go, Brian Go
type field_info =
| |
VIdUnspecified |
(* | Not yet set by type checkerNot yet set by type checker | *) |
| |
VIdStructField of |
(* | The field is the (int)th field of the structThe field is the (int)th field of the struct | *) |
| |
VIdEnumValue of |
(* | The field is the (int)th value of an enumThe field is the (int)th value of an enum | *) |
Field info is annotated by the type checker for use in the IR compiler
type global_expression =
| |
SynFunctionDeclare of |
| |
SynRemotableFunctionDeclare of |
| |
SynTemplatedDeclare of |
| |
SynFunctionDefine of |
| |
SynTemplatedDefine of |
| |
SynStructDeclare of |
| |
SynGlobalEnumDeclare of |
| |
SynGlobalVarDeclare of |
| |
SynInclude of |
| |
SynStateMachine of |
Top-level expressions
type include_data =
| |
IncludeFileName of |
| |
IncludeAst of |
The include string is replaced by an AST so as to only parse it once
type expression =
| |
SynVarDeclare of |
|||
| |
SynEnumDeclare of |
|||
| |
SynVarAssign of |
|||
| |
SynCond of |
|||
| |
SynLoop of |
|||
| |
SynFunctionCall of |
|||
| |
SynReturnStatement of |
|||
| |
SynBreak |
(* | Produces a type error if not in a loopProduces a type error if not in a loop | *) |
| |
SynContinue |
(* | Produces a type error if not in a loopProduces a type error if not in a loop | *) |
Expressions
typefunction_declare =data_type * string * (data_type * string) list
return type, name, arg list
Functions
return type, name, arg list
typefunction_define =function_declare * expression list
declaration, body
type function_call =
| |
SynLocalCall of |
(* | name, args, true if it is a variable-functionname, args, true if it is a variable-function | *) |
| |
SynRemoteCall of |
(* | name, args, return value target variablename, args, return value target variable | *) |
| |
SynRemoteCallNoResult of |
(* | name, argsname, args | *) |
type return_statement =
| |
SynVoidReturn |
| |
SynValueReturn of |
typestruct_declare =string * var_declare list
name, fields
Data Structures
name, fields
typeenum_declare =string * string list
name, values
type var_declare =
| |
SynVarDeclareNoInit of |
(* | type, nametype, name | *) |
| |
SynVarDeclareWithInit of |
(* | type, name, initial valuetype, name, initial value | *) |
Variables
type var_assign =
| |
SynVarAssignment of |
(* | var_ident = value_producervar_ident = value_producer | *) |
| |
SynVarModify of |
(* | e.g. +=,*=. for cons (::=), the list is on the LHSe.g. +=,*=. for cons (::=), the list is on the LHS | *) |
type conditional =
| |
SynIf of |
| |
SynIfCase of |
Conditionals
type continued_conditional =
| |
SynFinalElse of |
| |
SynElse of |
type loop =
| |
SynWhile of |
|||
| |
SynFor of |
(* | init, test, step, body. Note: step expression must end in a semicoloninit, test, step, body. Note: step expression must end in a semicolon | *) |
| |
SynDoWhile of |
Loops
type value_producer =
| |
SynValue of |
| |
SynFunctionCallValue of |
| |
SynVarIdentifier of |
| |
SynBinop of |
| |
SynPrefixUnop of |
| |
SynParenthesized of |
| |
SynArrayValueProducer of |
| |
SynListValueProducer of |
Value Producers
type value =
| |
SynIntValue of |
| |
SynFloatValue of |
| |
SynStringValue of |
| |
SynBoolValue of |
type list_value_producer =
| |
SynListNil of |
|||
| |
SynListList of |
|||
| |
SynListCons of |
(* | car, cdrcar, cdr | *) |
type var_ident =
| |
SynVarName of |
|||
| |
SynStructOrEnumValue of |
(* | field info set by type checker for use by IR compilerfield info set by type checker for use by IR compiler | *) |
| |
SynArrayCell of |
type data_type =
| |
SynIntType |
|||
| |
SynFloatType |
|||
| |
SynStringType |
|||
| |
SynBoolType |
|||
| |
SynVoidType |
|||
| |
SynEnumOrStructType of |
(* | field types set by type checker for use by IR compilerfield types set by type checker for use by IR compiler | *) |
| |
SynArrayType of |
|||
| |
SynListType of |
|||
| |
SynRefType of |
|||
| |
SynArrowType of |
(* | arg types, return typearg types, return type | *) |
Data Types
type binop =
| |
SynBinopAnd |
| |
SynBinopOr |
| |
SynBinopAdd |
| |
SynBinopSub |
| |
SynBinopMul |
| |
SynBinopDiv |
| |
SynBinopIDiv |
| |
SynBinopMod |
| |
SynBinopConcat |
| |
SynBinopCons |
| |
SynCompLt |
| |
SynCompGt |
| |
SynCompLte |
| |
SynCompGte |
| |
SynCompEq |
| |
SynCompNeq |
Operators
type pre_unop =
| |
SynUnopNot |
| |
SynUnopCar |
| |
SynUnopCdr |
| |
SynUnopTrunc |
| |
SynUnopDeref |
| |
SynUnopNeg |
| |
SynUnopNull |
typefsm_state_machine =string * string * fsm_state list
name, onInit handler, state list
State Machine Syntax
name, onInit handler, state list
typefsm_state =string * fsm_callback list * fsm_transition list
name, callbacks, transitions
type fsm_callback =
| |
SynFsmOnInit of |
(* | This is not actually a callback but is executed every time the state is visitedThis is not actually a callback but is executed every time the state is visited | *) |
| |
SynFsmOnMoveRequest of |
|||
| |
SynFsmOnTeammateDeath of |
|||
| |
SynFsmOnBombDetonate of |
|||
| |
SynFsmOnDeath of |
typefsm_transition =string list * (string * float) list
typesrc_program =global_expression list
val concat : string list -> stringval string_of_global_expression : global_expression -> stringval string_of_arglist : (data_type * string) list -> stringval string_of_datatype : data_type -> stringval string_of_string_list : string list -> stringval string_of_expr_list : expression list -> stringval string_of_var_declare_list : var_declare list -> stringval string_of_var_declare : var_declare -> stringval string_of_include : include_data -> stringval string_of_value_producer : value_producer -> stringval string_of_datatype_list : data_type list -> stringval string_of_expr : expression -> stringval string_of_value : value -> stringval string_of_function_call : function_call -> stringval string_of_variable_identifier : var_ident -> stringval string_of_unop : pre_unop -> stringval string_of_value_producer_list : value_producer list -> string -> stringval string_of_list_value_producer : list_value_producer -> stringval string_of_var_assign : var_assign -> stringval string_of_conditional : conditional -> stringval string_of_continued_conditional : continued_conditional -> stringval string_of_loop : loop -> stringval string_of_return_statement : return_statement -> stringval string_of_binop : binop -> stringval string_of_ast : global_expression list -> stringval print_ast : global_expression list -> unit