C# Class Spring.Expressions.Parser.antlr.debug.ParseTreeDebugParser

Specifies the behaviour required (i.e. parser modifications) specifically to support parse tree debugging and derivation.

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);

Inheritance: antlr.LLkParser
Mostra file Open project: spring-projects/spring-net

Protected Properties

Property Type Description
currentParseTreeRoot System.Collections.Stack
mostRecentParseTreeRoot antlr.ParseTreeRule
numberOfDerivationSteps int

Public Methods

Method Description
ParseTreeDebugParser ( antlr.ParserSharedInputState state, int k_ ) : antlr
ParseTreeDebugParser ( antlr.TokenBuffer tokenBuf, int k_ ) : antlr
ParseTreeDebugParser ( TokenStream lexer, int k_ ) : antlr
ParseTreeDebugParser ( int k_ ) : antlr
getNumberOfDerivationSteps ( ) : int
getParseTree ( ) : antlr.ParseTree
match ( antlr.collections.impl.BitSet bitSet ) : void
match ( int i ) : void
matchNot ( int i ) : void
traceIn ( string s ) : void

Create a rule node, add to current tree, and make it current root

traceOut ( string s ) : void

Pop current root; back to adding to old root

Protected Methods

Method Description
addCurrentTokenToParseTree ( ) : void

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).

Method Details

ParseTreeDebugParser() public method

public ParseTreeDebugParser ( antlr.ParserSharedInputState state, int k_ ) : antlr
state antlr.ParserSharedInputState
k_ int
return antlr

ParseTreeDebugParser() public method

public ParseTreeDebugParser ( antlr.TokenBuffer tokenBuf, int k_ ) : antlr
tokenBuf antlr.TokenBuffer
k_ int
return antlr

ParseTreeDebugParser() public method

public ParseTreeDebugParser ( TokenStream lexer, int k_ ) : antlr
lexer TokenStream
k_ int
return antlr

ParseTreeDebugParser() public method

public ParseTreeDebugParser ( int k_ ) : antlr
k_ int
return antlr

addCurrentTokenToParseTree() protected method

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).

protected addCurrentTokenToParseTree ( ) : void
return void

getNumberOfDerivationSteps() public method

public getNumberOfDerivationSteps ( ) : int
return int

getParseTree() public method

public getParseTree ( ) : antlr.ParseTree
return antlr.ParseTree

match() public method

public match ( antlr.collections.impl.BitSet bitSet ) : void
bitSet antlr.collections.impl.BitSet
return void

match() public method

public match ( int i ) : void
i int
return void

matchNot() public method

public matchNot ( int i ) : void
i int
return void

traceIn() public method

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

traceOut() public method

Pop current root; back to adding to old root
public traceOut ( string s ) : void
s string
return void

Property Details

currentParseTreeRoot protected_oe property

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

mostRecentParseTreeRoot protected_oe property

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

numberOfDerivationSteps protected_oe property

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