Bond 0.9
C++ Bond Runtime Library API Documentation
Loading...
Searching...
No Matches
Bond::SemanticAnalyzer Class Reference

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 SymbolTableGetSymbolTable () const
 Returns the symbol table to which symbols are added during semantic analysis. More...
 
const CompilerErrorBufferGetErrorBuffer () const
 Returns the buffer where error messages are pushed. More...
 

Detailed Description

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.

See also
CompilerErrorBuffer, FrontEnd, Lexer, Parser, SymbolTable, TranslationUnit

Constructor & Destructor Documentation

◆ SemanticAnalyzer()

Bond::SemanticAnalyzer::SemanticAnalyzer ( CompilerErrorBuffer errorBuffer,
PointerSize  pointerSize = BOND_NATIVE_POINTER_SIZE 
)
inline

Constructs a SemanticAnalyzer object.

Parameters
errorBufferBuffer where error messages are pushed when semantic errors are encountered.
pointerSizeSize of pointers used by the target virtual machine that will execute the Bond code. It is required to calculate the size of types.

◆ ~SemanticAnalyzer()

Bond::SemanticAnalyzer::~SemanticAnalyzer ( )
inline

Member Function Documentation

◆ Analyze()

void Bond::SemanticAnalyzer::Analyze ( TranslationUnit translationUnitList)

Performs semantic analysis on a list of parse trees.

Parameters
translationUnitListA linked list of parse trees to be analyzed.

◆ GetErrorBuffer()

const CompilerErrorBuffer & Bond::SemanticAnalyzer::GetErrorBuffer ( ) const
inline

Returns the buffer where error messages are pushed.

◆ GetSymbolTable()

const SymbolTable & Bond::SemanticAnalyzer::GetSymbolTable ( ) const
inline

Returns the symbol table to which symbols are added during semantic analysis.


The documentation for this class was generated from the following file: