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.
Adds a symbol to the symbol_table
symbol table. Used for scoping.
Removes the head of the symbol_table
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 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