|
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. | |
| ~SemanticAnalyzer () | |
| Destroys a SemanticAnalyzer object. | |
| void | Analyze (TranslationUnit *translationUnitList) |
| Performs semantic analysis on a list of parse trees. | |
| const SymbolTable & | GetSymbolTable () const |
| Returns the symbol table to which symbols are added during semantic analysis. | |
| const CompilerErrorBuffer & | GetErrorBuffer () const |
| Returns the buffer where error messages are pushed. | |
| void | SetPointerSize (PointerSize pointerSize) |
| Sets the pointer size used for type and value evaluation. | |
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 |
Destroys a SemanticAnalyzer object.
| void Bond::SemanticAnalyzer::Analyze | ( | TranslationUnit * | translationUnitList | ) |
Performs semantic analysis on a list of parse trees.
The results of the analysis, such as resolved symbols and evaluated types and values, are stored in the ParseNodes of the parse trees. Errors are pushed to the CompilerErrorBuffer.
| 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.
|
inline |
Sets the pointer size used for type and value evaluation.
| pointerSize | Size of pointers used by the target virtual machine. |