Package antlr.debug
Class ParseTreeDebugParser
java.lang.Object
antlr.Parser
antlr.LLkParser
antlr.debug.ParseTreeDebugParser
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
FieldsModifier and TypeFieldDescriptionprotected StackEach new rule invocation must have it's own subtree.protected ParseTreeRuleTrack most recently created parse subtree so that when parsing is finished, we can get to the root.protected intFor every rule replacement with a production, we bump up count.Fields inherited from class antlr.Parser
astFactory, inputState, returnAST, tokenNames, tokenTypeToASTClassMap, traceDepth -
Constructor Summary
ConstructorsConstructorDescriptionParseTreeDebugParser(int k_) ParseTreeDebugParser(ParserSharedInputState state, int k_) ParseTreeDebugParser(TokenBuffer tokenBuf, int k_) ParseTreeDebugParser(TokenStream lexer, int k_) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidThis adds LT(1) to the current parse subtree.intvoidmatch(int i) Make sure current lookahead symbol matches token type t.voidMake 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.voidmatchNot(int i) voidCreate a rule node, add to current tree, and make it current rootvoidPop current root; back to adding to old rootMethods inherited from class antlr.Parser
addMessageListener, addParserListener, addParserMatchListener, addParserTokenListener, addSemanticPredicateListener, addSyntacticPredicateListener, addTraceListener, consumeUntil, consumeUntil, defaultDebuggingSetup, getAST, getASTFactory, getFilename, getInputState, getTokenName, getTokenNames, getTokenTypeToASTClassMap, isDebugMode, mark, panic, recover, removeMessageListener, removeParserListener, removeParserMatchListener, removeParserTokenListener, removeSemanticPredicateListener, removeSyntacticPredicateListener, removeTraceListener, reportError, reportError, reportWarning, rewind, setASTFactory, setASTNodeClass, setASTNodeType, setDebugMode, setFilename, setIgnoreInvalidDebugCalls, setInputState, setTokenBuffer, traceIndent
-
Field Details
-
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
Track most recently created parse subtree so that when parsing is finished, we can get to the root. -
numberOfDerivationSteps
protected int numberOfDerivationStepsFor every rule replacement with a production, we bump up count.
-
-
Constructor Details
-
ParseTreeDebugParser
public ParseTreeDebugParser(int k_) -
ParseTreeDebugParser
-
ParseTreeDebugParser
-
-
Method Details
-
getParseTree
-
getNumberOfDerivationSteps
public int getNumberOfDerivationSteps() -
match
Description copied from class:ParserMake 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.- Overrides:
matchin classParser- Throws:
MismatchedTokenExceptionTokenStreamException
-
match
Description copied from class:ParserMake 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.- Overrides:
matchin classParser- Throws:
MismatchedTokenExceptionTokenStreamException
-
matchNot
- Overrides:
matchNotin classParser- Throws:
MismatchedTokenExceptionTokenStreamException
-
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).- Throws:
TokenStreamException
-
traceIn
Create a rule node, add to current tree, and make it current root- Overrides:
traceInin classLLkParser- Throws:
TokenStreamException
-
traceOut
Pop current root; back to adding to old root- Overrides:
traceOutin classLLkParser- Throws:
TokenStreamException
-