Purple
0.1
Standard Language Specification
|
Logic for global and local symbol tables. More...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "translate/symbol_table.h"
#include "utils/hash.h"
#include "utils/logging.h"
Functions | |
SymbolTableStack * | new_symbol_table_stack (void) |
Create a new Symbol Table Stack. More... | |
SymbolTableStack * | new_nonempty_symbol_table_stack (void) |
Create a new Symbol Table Stack with one empty Symbol Table at the bottom. More... | |
void | free_symbol_table_stack (SymbolTableStack *stack) |
Free all memory in a Symbol Table Stack. More... | |
void | push_symbol_table (SymbolTableStack *stack) |
Push new empty Symbol Table onto Symbol Table Stack. More... | |
void | push_existing_symbol_table (SymbolTableStack *stack, SymbolTable *new_table) |
Push existing Symbol Table onto Symbol Table Stack. More... | |
SymbolTable * | pop_symbol_table (SymbolTableStack *stack) |
Remove Symbol Table from Symbol Table Stack and return its pointer. More... | |
void | pop_and_free_symbol_table (SymbolTableStack *stack) |
Remove Symbol Table from Symbol Table Stack and free its memory. More... | |
SymbolTable * | peek_symbol_table (SymbolTableStack *stack) |
Get pointer of the top Symbol Table from Symbol Table Stack. More... | |
SymbolTable * | new_symbol_table (void) |
Get pointer to empty Symbol Table with length SYMBOL_TABLE_DEFAULT_LENGTH. More... | |
SymbolTable * | new_symbol_table_with_length (int length) |
Get pointer to empty Symbol Table with a custom length. More... | |
void | resize_symbol_table (SymbolTable *table) |
Double the size of a Symbol Table's buckets array. More... | |
SymbolTableEntry * | find_symbol_table_entry (SymbolTable *table, char *symbol_name) |
Find the entry of a symbol in the provided Symbol Table if it exists. More... | |
SymbolTableEntry * | find_symbol_table_stack_entry (SymbolTableStack *stack, char *symbol_name) |
Find the entry of a symbol in the provided Symbol Table Stack if it exists, working from the top of the stack to the bottom. More... | |
SymbolTableEntry * | new_symbol_table_entry (char *symbol_name) |
Get pointer to new Symbol Table Entry. More... | |
SymbolTableEntry * | add_symbol_table_entry (SymbolTable *table, char *symbol_name, Type type) |
Hash symbol_name with hash function FNV-1 and put it into the chained Symbol Table. More... | |
Logic for global and local symbol tables.
SymbolTableEntry * add_symbol_table_entry | ( | SymbolTable * | table, |
char * | symbol_name, | ||
Type | type | ||
) |
Hash symbol_name with hash function FNV-1 and put it into the chained Symbol Table.
table | Table to put new Symbol Table Entry into |
symbol_name | Name of symbol to add |
type | Type of symbol to add |
SymbolTableEntry * find_symbol_table_entry | ( | SymbolTable * | table, |
char * | symbol_name | ||
) |
Find the entry of a symbol in the provided Symbol Table if it exists.
table | Table to search in |
symbol_name | Name of symbol to search for |
SymbolTableEntry * find_symbol_table_stack_entry | ( | SymbolTableStack * | stack, |
char * | symbol_name | ||
) |
Find the entry of a symbol in the provided Symbol Table Stack if it exists, working from the top of the stack to the bottom.
stack | Symbol Table Stack to search |
symbol_name | Name of symbol to find |
void free_symbol_table_stack | ( | SymbolTableStack * | stack | ) |
Free all memory in a Symbol Table Stack.
SymbolTableStack * new_nonempty_symbol_table_stack | ( | void | ) |
Create a new Symbol Table Stack with one empty Symbol Table at the bottom.
SymbolTable * new_symbol_table | ( | void | ) |
Get pointer to empty Symbol Table with length SYMBOL_TABLE_DEFAULT_LENGTH.
SymbolTableEntry * new_symbol_table_entry | ( | char * | symbol_name | ) |
Get pointer to new Symbol Table Entry.
symbol_name | Name of new symbol |
SymbolTableStack * new_symbol_table_stack | ( | void | ) |
Create a new Symbol Table Stack.
SymbolTable * new_symbol_table_with_length | ( | int | length | ) |
Get pointer to empty Symbol Table with a custom length.
SymbolTable * peek_symbol_table | ( | SymbolTableStack * | stack | ) |
Get pointer of the top Symbol Table from Symbol Table Stack.
stack | Stack to ppek at |
void pop_and_free_symbol_table | ( | SymbolTableStack * | stack | ) |
Remove Symbol Table from Symbol Table Stack and free its memory.
stack | Stack to pop from |
SymbolTable * pop_symbol_table | ( | SymbolTableStack * | stack | ) |
Remove Symbol Table from Symbol Table Stack and return its pointer.
stack | Stack to pop from |
void push_existing_symbol_table | ( | SymbolTableStack * | stack, |
SymbolTable * | new_table | ||
) |
Push existing Symbol Table onto Symbol Table Stack.
stack | Symbol Table Stack to push existing table onto |
new_table | New table to push onto stack |
void push_symbol_table | ( | SymbolTableStack * | stack | ) |
Push new empty Symbol Table onto Symbol Table Stack.
stack | Symbol Table Stack to push new table onto |
void resize_symbol_table | ( | SymbolTable * | table | ) |
Double the size of a Symbol Table's buckets array.
table | Table to double the size of |