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

A compiler front end for the Bond scripting language. More...

#include <bond/compiler/frontend.h>

Public Member Functions

 FrontEnd (Allocator &allocator, TokenCollectionStore &tokenCollectionStore, Lexer &lexer, Parser &parser, SemanticAnalyzer &semanticAnalyzer, StreamFactory &streamFactory)
 Constructs a FrontEnd object. More...
 
 FrontEnd (const FrontEnd &other)=delete
 
FrontEndoperator= (const FrontEnd &other)=delete
 
void AddInputFile (const StringView &inputFileName)
 Adds the name of a Bond source file to the input file list. More...
 
bool ContainsInputFile (const StringView &inputFileName)
 Returns whether the given file name exists in the input file list.. More...
 
TranslationUnitAnalyze ()
 Performs loading, parsing and semantic analysis of all source files in the input file list, as well as those files referenced via include directives. returns A parse tree of ParseNodes rooted with a list of TranslationUnits. More...
 
bool HasErrors () const
 Returns whether any errors occurred whilst analyzing the source code. More...
 

Detailed Description

A compiler front end for the Bond scripting language.

The FrontEnd manages the interactions between the compiler's front end components, namely a Lexer, a Parser and a SemanticAnalyzer.

The FrontEnd also manages an input file list, a list of Bond source files that are required to be loaded, parsed and analyzed. Files can be explicitly added to the input file list via the AddInputFile method. Files are also implicitly added to the list when include directives in the Bond source files are parsed. A source file is never added to the input file list more than once, so encountering an include directive for a file that already exists in the list has no effect. One parse tree, rooted with a TranslationUnit, is generated for each Bond source file. Only the TranslationUnits for the files that were explicitly added to the input file list are flagged as requiring code generation.

When analysis is complete, the list of generated TranslationUnits is returned.

File loading is delegated to an object that implements the StreamFactory interface so that no assumptions about where the source files reside are made (e.g. disk, network, database, proprietary asset store, etc).

See also
CompilerErrorBuffer, FrontEnd, Parser, SemanticAnalyzer, TranslationUnit

Constructor & Destructor Documentation

◆ FrontEnd() [1/2]

Bond::FrontEnd::FrontEnd ( Allocator allocator,
TokenCollectionStore tokenCollectionStore,
Lexer lexer,
Parser parser,
SemanticAnalyzer semanticAnalyzer,
StreamFactory streamFactory 
)
inline

Constructs a FrontEnd object.

Parameters
allocatorThe allocator used for the FrontEnd's internal data structures.
tokenCollectionStoreStorage for the generated TokenCollections..
lexerThe Lexer used to scan the Bond source files.
parserThe Parser used to parse the Bond source files.
semanticAnalyzerThe SemanticAnalyzer used to analyze the Bond source files.
streamFactoryThe StreamFactory responsible for loading the Bond source files.

◆ FrontEnd() [2/2]

Bond::FrontEnd::FrontEnd ( const FrontEnd other)
delete

Member Function Documentation

◆ AddInputFile()

void Bond::FrontEnd::AddInputFile ( const StringView &  inputFileName)

Adds the name of a Bond source file to the input file list.

Parameters
inputFileNameThe name of the file to be loaded. Since StringViews are not deep copied, the lifetime of the string must at least span the lifetime of the FrontEnd.

◆ Analyze()

TranslationUnit * Bond::FrontEnd::Analyze ( )

Performs loading, parsing and semantic analysis of all source files in the input file list, as well as those files referenced via include directives. returns A parse tree of ParseNodes rooted with a list of TranslationUnits.

◆ ContainsInputFile()

bool Bond::FrontEnd::ContainsInputFile ( const StringView &  inputFileName)

Returns whether the given file name exists in the input file list..

Parameters
inputFileNameThe name of the file to be tested.

◆ HasErrors()

bool Bond::FrontEnd::HasErrors ( ) const

Returns whether any errors occurred whilst analyzing the source code.

◆ operator=()

FrontEnd & Bond::FrontEnd::operator= ( const FrontEnd other)
delete

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