antlr.debug

Class ParseTreeDebugParser

public class ParseTreeDebugParser extends LLkParser

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);
Field Summary
protected StackcurrentParseTreeRoot
Each new rule invocation must have it's own subtree.
protected ParseTreeRulemostRecentParseTreeRoot
Track most recently created parse subtree so that when parsing is finished, we can get to the root.
protected intnumberOfDerivationSteps
For every rule replacement with a production, we bump up count.
Constructor Summary
ParseTreeDebugParser(int k_)
ParseTreeDebugParser(ParserSharedInputState state, int k_)
ParseTreeDebugParser(TokenBuffer tokenBuf, int k_)
ParseTreeDebugParser(TokenStream lexer, int k_)
Method Summary
protected voidaddCurrentTokenToParseTree()
This adds LT(1) to the current parse subtree.
intgetNumberOfDerivationSteps()
ParseTreegetParseTree()
voidmatch(int i)
voidmatch(BitSet bitSet)
voidmatchNot(int i)
voidtraceIn(String s)
Create a rule node, add to current tree, and make it current root
voidtraceOut(String s)
Pop current root; back to adding to old root

Field Detail

currentParseTreeRoot

protected Stack currentParseTreeRoot
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.

mostRecentParseTreeRoot

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

numberOfDerivationSteps

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

Constructor Detail

ParseTreeDebugParser

public ParseTreeDebugParser(int k_)

ParseTreeDebugParser

public ParseTreeDebugParser(ParserSharedInputState state, int k_)

ParseTreeDebugParser

public ParseTreeDebugParser(TokenBuffer tokenBuf, int k_)

ParseTreeDebugParser

public ParseTreeDebugParser(TokenStream lexer, int k_)

Method Detail

addCurrentTokenToParseTree

protected void addCurrentTokenToParseTree()
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).

getNumberOfDerivationSteps

public int getNumberOfDerivationSteps()

getParseTree

public ParseTree getParseTree()

match

public void match(int i)

match

public void match(BitSet bitSet)

matchNot

public void matchNot(int i)

traceIn

public void traceIn(String s)
Create a rule node, add to current tree, and make it current root

traceOut

public void traceOut(String s)
Pop current root; back to adding to old root