Grammatica
|
A recursive descent parser. More...
Public Member Functions | |
RecursiveDescentParser (TextReader input) | |
Creates a new parser. More... | |
RecursiveDescentParser (TextReader input, Analyzer analyzer) | |
Creates a new parser. More... | |
RecursiveDescentParser (Tokenizer tokenizer) | |
Creates a new parser. More... | |
RecursiveDescentParser (Tokenizer tokenizer, Analyzer analyzer) | |
Creates a new parser. More... | |
override void | AddPattern (ProductionPattern pattern) |
Adds a new production pattern to the parser. More... | |
override void | Prepare () |
Initializes the parser. More... | |
![]() | |
Tokenizer | GetTokenizer () |
Returns the tokenizer in use by this parser. More... | |
Analyzer | GetAnalyzer () |
Returns the analyzer in use by this parser. More... | |
void | Reset (TextReader input) |
Resets this parser for usage with another input stream. More... | |
void | Reset (TextReader input, Analyzer analyzer) |
Resets this parser for usage with another input stream. More... | |
Node | Parse () |
Parses the token stream and returns a parse tree. More... | |
override string | ToString () |
Returns a string representation of this parser. More... | |
Protected Member Functions | |
override Node | ParseStart () |
Parses the input stream and creates a parse tree. More... | |
![]() | |
virtual Tokenizer | NewTokenizer (TextReader input) |
Creates a new tokenizer for this parser. More... | |
virtual Analyzer | NewAnalyzer () |
Creates a new analyzer for this parser. More... | |
virtual Production | NewProduction (ProductionPattern pattern) |
Factory method to create a new production node. More... | |
Additional Inherited Members | |
![]() | |
Tokenizer | Tokenizer [get] |
The tokenizer property (read-only). More... | |
Analyzer | Analyzer [get] |
The analyzer property (read-only). More... | |
A recursive descent parser.
This parser handles LL(n) grammars, selecting the appropriate pattern to parse based on the next few tokens. The parser is more efficient the fewer look-ahead tokens that is has to consider.
|
inline |
Creates a new parser.
input | the input stream to read from |
ParserCreationException | if the tokenizer couldn't be initialized correctly |
|
inline |
Creates a new parser.
input | the input stream to read from |
analyzer | the analyzer callback to use |
ParserCreationException | if the tokenizer couldn't be initialized correctly |
|
inline |
Creates a new parser.
tokenizer | the tokenizer to use |
|
inline |
Creates a new parser.
tokenizer | the tokenizer to use |
analyzer | the analyzer callback to use |
|
inlinevirtual |
Adds a new production pattern to the parser.
The pattern will be added last in the list. The first pattern added is assumed to be the starting point in the grammar. The pattern will be validated against the grammar type to some extent.
pattern | the pattern to add |
ParserCreationException | if the pattern couldn't be added correctly to the parser |
Reimplemented from PerCederberg.Grammatica.Runtime.Parser.
|
inlineprotectedvirtual |
Parses the input stream and creates a parse tree.
ParseException | if the input couldn't be parsed correctly |
Implements PerCederberg.Grammatica.Runtime.Parser.
|
inlinevirtual |
Initializes the parser.
All the added production patterns will be analyzed for ambiguities and errors. This method also initializes the internal data structures used during the parsing.
ParserCreationException | if the parser couldn't be initialized correctly |
Reimplemented from PerCederberg.Grammatica.Runtime.Parser.