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

A parser for the Bond scripting language. More...

#include <bond/compiler/parser.h>

Public Member Functions

 Parser (Allocator &allocator, CompilerErrorBuffer &errorBuffer, ParseNodeStore &store)
 Constructs a Parser object. More...
 
 Parser (const Parser &other)=delete
 
Parseroperator= (const Parser &other)=delete
 
TranslationUnitParse (TokenCollection &collection)
 Parses a sequence of Tokens and generates a parse tree. More...
 
TranslationUnitParse (TokenStream &stream)
 Parses a sequence of Tokens and generates a parse tree. More...
 
const CompilerErrorBufferGetErrorBuffer () const
 Returns the buffer where error messages are pushed. More...
 
ParseNodeStoreGetParseNodeStore ()
 Returns the store of owning pointers to the ParseNodes created by this Parser. More...
 

Detailed Description

A parser for the Bond scripting language.

The Parser parses the contents of a TokenCollection generated from a Lexer that has scanned Bond source code. Its output is a parse tree of objects that derive from ParseNode. The concrete type of the root node is TranslationUnit. The parse tree can then be used as input to a SemanticAnalyzer and CodeGenerator. A single Parser can be used to parse several collections of Tokens.

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, Parser, SemanticAnalyzer, TokenCollection, TokenStream, TranslationUnit

Constructor & Destructor Documentation

◆ Parser() [1/2]

Bond::Parser::Parser ( Allocator allocator,
CompilerErrorBuffer errorBuffer,
ParseNodeStore store 
)
inline

Constructs a Parser object.

Parameters
allocatorThe memory allocator from which ParseNodes are allocated.
errorBufferBuffer where error messages are pushed when syntax errors are encountered.
storeStore of owning pointers to the ParseNodes created by this Parser.

◆ Parser() [2/2]

Bond::Parser::Parser ( const Parser other)
delete

Member Function Documentation

◆ GetErrorBuffer()

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

Returns the buffer where error messages are pushed.

◆ GetParseNodeStore()

ParseNodeStore & Bond::Parser::GetParseNodeStore ( )
inline

Returns the store of owning pointers to the ParseNodes created by this Parser.

◆ operator=()

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

◆ Parse() [1/2]

TranslationUnit * Bond::Parser::Parse ( TokenCollection collection)

Parses a sequence of Tokens and generates a parse tree.

Parameters
collectionThe collection of Tokens to be parsed.
Returns
A parse tree of ParseNodes rooted with a TranslationUnit.

◆ Parse() [2/2]

TranslationUnit * Bond::Parser::Parse ( TokenStream stream)

Parses a sequence of Tokens and generates a parse tree.

Parameters
streamThe stream of Tokens to be parsed.
Returns
A parse tree of ParseNodes rooted with a Translationunit.

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