Public Member Functions | Protected Member Functions | Protected Attributes

antlr.debug.ParseTreeDebugParser Class Reference

Inheritance diagram for antlr.debug.ParseTreeDebugParser:
antlr.LLkParser antlr.Parser

List of all members.

Public Member Functions

 ParseTreeDebugParser (int k_)
 ParseTreeDebugParser (ParserSharedInputState state, int k_)
 ParseTreeDebugParser (TokenBuffer tokenBuf, int k_)
 ParseTreeDebugParser (TokenStream lexer, int k_)
ParseTree getParseTree ()
int getNumberOfDerivationSteps ()
void match (int i) throws MismatchedTokenException, TokenStreamException
void match (BitSet bitSet) throws MismatchedTokenException, TokenStreamException
void matchNot (int i) throws MismatchedTokenException, TokenStreamException
void traceIn (String s) throws TokenStreamException
void traceOut (String s) throws TokenStreamException

Protected Member Functions

void addCurrentTokenToParseTree () throws TokenStreamException

Protected Attributes

Stack currentParseTreeRoot = new Stack()
ParseTreeRule mostRecentParseTreeRoot = null
int numberOfDerivationSteps = 1

Detailed Description

Override the standard matching and rule entry/exit routines to build parse trees. This class is useful for 2.7.3 where you can specify a superclass like

class TinyCParser extends Parser(ParseTreeDebugParser);


Constructor & Destructor Documentation

antlr.debug.ParseTreeDebugParser.ParseTreeDebugParser ( int  k_  ) 
antlr.debug.ParseTreeDebugParser.ParseTreeDebugParser ( ParserSharedInputState  state,
int  k_ 
)
antlr.debug.ParseTreeDebugParser.ParseTreeDebugParser ( TokenBuffer  tokenBuf,
int  k_ 
)
antlr.debug.ParseTreeDebugParser.ParseTreeDebugParser ( TokenStream  lexer,
int  k_ 
)

Member Function Documentation

void antlr.debug.ParseTreeDebugParser.addCurrentTokenToParseTree (  )  throws TokenStreamException [protected]

This adds LT(1) to the current parse subtree. Note that the match() routines add the node before checking for correct match. This means that, upon mismatched token, there will a token node in the tree corresponding to where that token was expected. For no viable alternative errors, no node will be in the tree as nothing was matched() (the lookahead failed to predict an alternative).

References antlr.BaseAST.addChild(), antlr.debug.ParseTreeDebugParser.currentParseTreeRoot, antlr.ParserSharedInputState.guessing, antlr.Parser.inputState, antlr.LLkParser.LA(), and antlr.LLkParser.LT().

Referenced by antlr.debug.ParseTreeDebugParser.match(), and antlr.debug.ParseTreeDebugParser.matchNot().

int antlr.debug.ParseTreeDebugParser.getNumberOfDerivationSteps (  ) 
ParseTree antlr.debug.ParseTreeDebugParser.getParseTree (  ) 
void antlr.debug.ParseTreeDebugParser.match ( BitSet  b  )  throws MismatchedTokenException, TokenStreamException

Make sure current lookahead symbol matches the given set Throw an exception upon mismatch, which is catch by either the error handler or by the syntactic predicate.

Reimplemented from antlr.Parser.

References antlr.debug.ParseTreeDebugParser.addCurrentTokenToParseTree().

void antlr.debug.ParseTreeDebugParser.match ( int  t  )  throws MismatchedTokenException, TokenStreamException

Make sure current lookahead symbol matches token type t. Throw an exception upon mismatch, which is catch by either the error handler or by the syntactic predicate.

Reimplemented from antlr.Parser.

References antlr.debug.ParseTreeDebugParser.addCurrentTokenToParseTree().

void antlr.debug.ParseTreeDebugParser.matchNot ( int  i  )  throws MismatchedTokenException, TokenStreamException
void antlr.debug.ParseTreeDebugParser.traceIn ( String  s  )  throws TokenStreamException
void antlr.debug.ParseTreeDebugParser.traceOut ( String  s  )  throws TokenStreamException

Member Data Documentation

Each new rule invocation must have it's own subtree. Tokens are added to the current root so we must have a stack of subtree roots.

Referenced by antlr.debug.ParseTreeDebugParser.addCurrentTokenToParseTree(), antlr.debug.ParseTreeDebugParser.traceIn(), and antlr.debug.ParseTreeDebugParser.traceOut().

Track most recently created parse subtree so that when parsing is finished, we can get to the root.

Referenced by antlr.debug.ParseTreeDebugParser.getParseTree(), and antlr.debug.ParseTreeDebugParser.traceOut().

For every rule replacement with a production, we bump up count.

Referenced by antlr.debug.ParseTreeDebugParser.getNumberOfDerivationSteps(), and antlr.debug.ParseTreeDebugParser.traceIn().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties