Module Perk.Var_symbol_table

Utils for the var symbol table

val var_symbol_table : (Ast.perkident, Ast.perktype) Stdlib.Hashtbl.t list Stdlib.ref

List of hash tables, one for each scope. The head of the table is the current scope.

val push_symbol_table_local : ('a, 'b) Stdlib.Hashtbl.t list Stdlib.ref -> unit

Adds a symbol to the symbol_table symbol table. Used for scoping.

val push_symbol_table : unit -> unit

Adds a symbol to the var symbol table. Used for scoping.

val pop_symbol_table_local : 'a list Stdlib.ref -> unit

Removes the head of the symbol_table symbol table. Used for scoping.

val pop_symbol_table : unit -> unit

Removes the head of the var symbol table. Used for scoping.

val lookup_var_local : (Ast.perkident, Ast.perktype) Stdlib.Hashtbl.t list Stdlib.ref -> Ast.perkident -> Ast.perktype option

Looks up a variable id in the symbol table symbol_table.

val lookup_var : Ast.perkident -> Ast.perktype option

Looks up a variable in the var symbol table

val print_symbol_table_local : (string, Ast.perktype) Stdlib.Hashtbl.t list Stdlib.ref -> unit

Debug function for printing a symbol table

val print_symbol_table : unit -> unit

Debug function for printing the var symbol table

val bind_var_local : (Ast.perkident, Ast.perktype) Stdlib.Hashtbl.t list Stdlib.ref -> Ast.perkident -> Ast.perktype -> unit

Given a symbol table symbol_table, and identifier id and its type t, it binds id in symbol_table with type t if it is not already defined.

val bind_var : Ast.perkident -> Ast.perktype -> unit

Binds a variable in the var symbol table.

val rebind_var_local : (Ast.perkident, Ast.perktype) Stdlib.Hashtbl.t list Stdlib.ref -> Ast.perkident -> Ast.perktype -> unit

Given a symbol table symbol_table, and identifier id and its type t, it checks whether id is already defined in symbol_table, and if so rebinds it with type t.

val rebind_var : Ast.perkident -> Ast.perktype -> unit

Rebinds a variable in the var_symbol_table

val get_all_global_identifiers : unit -> string list

Returns a list of all global identifiers