AST nodes and attributes.
#define MAX_ERROR_LEN
Maximum length (in characters) of any error message.
Definition common.h:52
#define DECL_LIST_TYPE(NAME, ELEMTYPE)
Declare a singly-linked list structure of the given type.
Definition common.h:132
#define MAX_ID_LEN
Maximum length (in characters) of any identifier.
Definition common.h:57
DecafType
Valid Decaf types.
Definition common.h:66
Main AST node structure.
Definition ast.h:471
Static analysis error structure.
Definition symbol.h:212
char message[256]
Error message.
Definition symbol.h:213
struct AnalysisError * next
Next message (if stored in a list)
Definition symbol.h:214
Linked list of AnalysisError* elements.
Definition symbol.h:217
Node visitor structure.
Definition visitor.h:28
Linked list of struct Parameter* elements.
Definition ast.h:123
Single Decaf symbol.
Definition symbol.h:31
int length
Length (for array symbols only)
Definition symbol.h:54
ParameterList * parameters
List of parameters (for function symbols only)
Definition symbol.h:59
char name[256]
Name of symbol in code.
Definition symbol.h:44
DecafType type
Variable or function return type.
Definition symbol.h:49
enum Symbol::@5 location
Memory access location (initialized during code generation)
enum Symbol::@4 symbol_type
Kind of symbol (scalar, array, or function)
struct Symbol * next
Next symbol (if stored in a list)
Definition symbol.h:79
int offset
Memory offset (initialized during code generation)
Definition symbol.h:74
Linked list of struct Symbol* elements.
Definition symbol.h:119
Stores symbol info for a single lexical scope.
Definition symbol.h:129
SymbolList * local_symbols
List of symbols defined in the scope associated with this table.
Definition symbol.h:133
struct SymbolTable * parent
Link to parent table.
Definition symbol.h:138
Symbol * SymbolTable_lookup(SymbolTable *table, const char *name)
Retrieve a symbol from a table.
Definition symbol.c:136
Symbol * lookup_symbol(ASTNode *node, const char *name)
Look up a symbol in an AST.
Definition symbol.c:155
void symtable_attr_print(void *value, FILE *output)
Function that prints a symbol table attribute using DOT formatting.
Definition symbol.c:9
NodeVisitor * BuildSymbolTablesVisitor_new(void)
Create a new visitor that builds symbol tables.
Definition symbol.c:251
void type_attr_print(void *value, FILE *output)
Simple "print" function that prints an attribute value as a Decaf type.
Definition symbol.c:4
SymbolTable * SymbolTable_new_child(SymbolTable *parent)
Create a new symbol table with a parent link.
Definition symbol.c:124
Symbol * Symbol_new(const char *name, DecafType type)
Create a new scalar symbol.
Definition symbol.c:26
SymbolTable * SymbolTable_new(void)
Create a new symbol table with no parent link.
Definition symbol.c:115
void SymbolTable_insert(SymbolTable *table, Symbol *symbol)
Add a symbol to a table.
Definition symbol.c:131
void Symbol_print(Symbol *symbol, FILE *output)
Print simplified string representation.
Definition symbol.c:74
NodeVisitor * PrintSymbolsVisitor_new(FILE *output)
Create a new visitor that prints symbol tables.
Definition symbol.c:324
Symbol * Symbol_new_function(const char *name, DecafType return_type, ParameterList *parameters)
Create a new function symbol.
Definition symbol.c:56
void SymbolTable_free(SymbolTable *table)
Deallocate a symbol table.
Definition symbol.c:149
void Symbol_free(Symbol *symbol)
Deallocate a symbol.
Definition symbol.c:107
Symbol * Symbol_new_array(const char *name, DecafType type, int length)
Create a new array symbol.
Definition symbol.c:41
void ErrorList_printf(ErrorList *list, const char *format,...)
Add an error message to a list of errors using printf syntax.
Definition symbol.c:341