Overview   Project   Class   Tree   Deprecated   Index 
Grammatica 1.5 Documentation
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD

PerCederberg.Grammatica.Runtime
Class RecursiveDescentParser

System.Object
   |
   +--Parser
         |
         +--RecursiveDescentParser

   in RecursiveDescentParser.cs

public class RecursiveDescentParser
extends Parser

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.


Inner Classes, Typedefs, and Enums
class RecursiveDescentParser.CallStack
          A name value stack.
   
Fields inherited from class Parser
Tokenizer, Analyzer
 
Constructor Summary
RecursiveDescentParser( TextReader input )
          Creates a new parser.
RecursiveDescentParser( TextReader input, Analyzer analyzer )
          Creates a new parser.
RecursiveDescentParser( Tokenizer tokenizer )
          Creates a new parser.
RecursiveDescentParser( Tokenizer tokenizer, Analyzer analyzer )
          Creates a new parser.
 
Method Summary
 override void AddPattern( ProductionPattern pattern )
          Adds a new production pattern to the parser.
protected override Node ParseStart()
          Parses the input stream and creates a parse tree.
 override void Prepare()
          Initializes the parser.
   
Methods inherited from class Parser
NewTokenizer, NewAnalyzer, GetTokenizer, GetAnalyzer, SetInitialized, AddPattern, Prepare, Reset, Parse, ParseStart, NewProduction, AddError, GetPattern, GetStartPattern, GetPatterns, EnterNode, ExitNode, AddNode, NextToken, NextToken, PeekToken, ToString, GetTokenDescription
 

Constructor Detail

RecursiveDescentParser

public RecursiveDescentParser( TextReader input );
Creates a new parser.
Parameters:
input - the input stream to read from
Throws:
ParserCreationException - if the tokenizer couldn't be initialized correctly
Since:
1.5

RecursiveDescentParser

public RecursiveDescentParser( TextReader input, Analyzer analyzer );
Creates a new parser.
Parameters:
input - the input stream to read from
analyzer - the analyzer callback to use
Throws:
ParserCreationException - if the tokenizer couldn't be initialized correctly
Since:
1.5

RecursiveDescentParser

public RecursiveDescentParser( Tokenizer tokenizer );
Creates a new parser.
Parameters:
tokenizer - the tokenizer to use

RecursiveDescentParser

public RecursiveDescentParser( Tokenizer tokenizer, Analyzer analyzer );
Creates a new parser.
Parameters:
tokenizer - the tokenizer to use
analyzer - the analyzer callback to use


Method Detail

AddPattern

public override void AddPattern( ProductionPattern pattern );
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.
Parameters:
pattern - the pattern to add
Throws:
ParserCreationException - if the pattern couldn't be added correctly to the parser

ParseStart

protected override Node ParseStart();
Parses the input stream and creates a parse tree.
Returns:
the parse tree
Throws:
ParseException - if the input couldn't be parsed correctly

Prepare

public override void Prepare();
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.
Throws:
ParserCreationException - if the parser couldn't be initialized correctly

 Overview   Project   Class   Tree   Deprecated   Index 
Grammatica 1.5 Documentation
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD