Bond 0.9
C++ Bond Runtime Library API Documentation
|
A semantic analyzer for a parse tree generated from the Bond scripting language. More...
#include <bond/compiler/semanticanalyzer.h>
Public Member Functions | |
SemanticAnalyzer (CompilerErrorBuffer &errorBuffer, PointerSize pointerSize=BOND_NATIVE_POINTER_SIZE) | |
Constructs a SemanticAnalyzer object. More... | |
~SemanticAnalyzer () | |
void | Analyze (TranslationUnit *translationUnitList) |
Performs semantic analysis on a list of parse trees. More... | |
const SymbolTable & | GetSymbolTable () const |
Returns the symbol table to which symbols are added during semantic analysis. More... | |
const CompilerErrorBuffer & | GetErrorBuffer () const |
Returns the buffer where error messages are pushed. More... | |
A semantic analyzer for a parse tree generated from the Bond scripting language.
The SemanticAnalyzer traverses the given parse tree to populate a symbol table, resolve symbol names (e.g. type names, variable names, function names and so forth), evaluate the value of compile-time constants (e.g. constant expressions, type sizes and array lengths), and report semantic errors (e.g. unresolved symbol names).
A single SemanticAnalyzer can analyze the parse trees generated from several translation units. All translation units are assumed to be part of a common project, therefore all of the symbols are added to a common symbol table.
When writing a tool that requires a compiler front end, the interactions between the front end components, namely a Lexer, a Parser and a SemanticAnalyzer, can be managed by a FrontEnd.
|
inline |
Constructs a SemanticAnalyzer object.
errorBuffer | Buffer where error messages are pushed when semantic errors are encountered. |
pointerSize | Size of pointers used by the target virtual machine that will execute the Bond code. It is required to calculate the size of types. |
|
inline |
void Bond::SemanticAnalyzer::Analyze | ( | TranslationUnit * | translationUnitList | ) |
Performs semantic analysis on a list of parse trees.
translationUnitList | A linked list of parse trees to be analyzed. |
|
inline |
Returns the buffer where error messages are pushed.
|
inline |
Returns the symbol table to which symbols are added during semantic analysis.