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