Module Parsing.Parsed_ast

type identifier =
| Variable of Ast.Ast_types.Var_name.t
| ObjField of Ast.Ast_types.Var_name.t * Ast.Ast_types.Field_name.t
type expr =
| Integer of Ast.Ast_types.loc * int
| Boolean of Ast.Ast_types.loc * bool
| Identifier of Ast.Ast_types.loc * identifier
| Constructor of Ast.Ast_types.loc * Ast.Ast_types.Class_name.t * Ast.Ast_types.type_expr option * constructor_arg list

optional type-parameter

| Let of Ast.Ast_types.loc * Ast.Ast_types.type_expr option * Ast.Ast_types.Var_name.t * expr

binds variable to expression (optional type annotation)

| Assign of Ast.Ast_types.loc * identifier * expr
| Consume of Ast.Ast_types.loc * identifier
| MethodApp of Ast.Ast_types.loc * Ast.Ast_types.Var_name.t * Ast.Ast_types.Method_name.t * expr list

read as x.m(args)

| FunctionApp of Ast.Ast_types.loc * Ast.Ast_types.Function_name.t * expr list
| Printf of Ast.Ast_types.loc * string * expr list
| FinishAsync of Ast.Ast_types.loc * async_expr list * block_expr

a list async exprs and the current thread's expr

| If of Ast.Ast_types.loc * expr * block_expr * block_expr

If ___ then ___ else ___

| While of Ast.Ast_types.loc * expr * block_expr

While ___ do ___

| For of Ast.Ast_types.loc * expr * expr * expr * block_expr

For(init_expr; cond_expr ; step_expr) body_expr

| BinOp of Ast.Ast_types.loc * Ast.Ast_types.bin_op * expr * expr
| UnOp of Ast.Ast_types.loc * Ast.Ast_types.un_op * expr

Possible executable expressions - note we pass in the location of the start token to provide useful debugging information - which line + position the parsing errors occurred

and block_expr =
| Block of Ast.Ast_types.loc * expr list
and async_expr =
| AsyncExpr of block_expr
and constructor_arg =
| ConstructorArg of Ast.Ast_types.Field_name.t * expr
type function_defn =
| TFunction of Ast.Ast_types.Function_name.t * Ast.Ast_types.borrowed_ref option * Ast.Ast_types.type_expr * Ast.Ast_types.param list * block_expr

Function defn consists of the function name, return type (and whether it returns a borrowed ref), the list of params, and the body expr of the function

type method_defn =
| TMethod of Ast.Ast_types.Method_name.t * Ast.Ast_types.borrowed_ref option * Ast.Ast_types.type_expr * Ast.Ast_types.param list * Ast.Ast_types.Capability_name.t list * block_expr

Method defn consists the method name, return type (and whether it returns a borrowed ref), the list of params, the capabilities used and the body expr of the function

type class_defn =
| TClass of Ast.Ast_types.Class_name.t * Ast.Ast_types.generic_type option * Ast.Ast_types.Class_name.t option * Ast.Ast_types.capability list * Ast.Ast_types.field_defn list * method_defn list

Class definitions consist of the class name and optionally specifying if generic and if it inherits from another class, its capabilities and the fields and methods in the class

type program =
| Prog of class_defn list * function_defn list * block_expr

Each bolt program defines the classes,followed by functions, followed by the main expression block to execute.