public class RuleContext extends Object implements RuleNode
ParserRuleContext| Modifier and Type | Field and Description |
|---|---|
static ParserRuleContext |
EMPTY |
int |
invokingState
What state invoked the rule associated with this context?
The "return address" is the followState of invokingState
If parent is null, this should be -1.
|
RuleContext |
parent
What context invoked this rule?
|
| Constructor and Description |
|---|
RuleContext() |
RuleContext(RuleContext parent,
int invokingState) |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
accept(ParseTreeVisitor<? extends T> visitor)
The ParseTreeVisitor needs a double dispatch method
|
int |
depth() |
ParseTree |
getChild(int i)
If there are children, get the ith value indexed from 0.
|
int |
getChildCount()
How many children are there? If there is none, then this
node represents a leaf node.
|
RuleContext |
getParent()
The parent of this node.
|
RuleContext |
getPayload()
This method returns whatever object represents the data at this note.
|
RuleContext |
getRuleContext() |
int |
getRuleIndex() |
Interval |
getSourceInterval()
Return an interval indicating the index in the TokenStream of
the first and last token associated with this subtree.
|
String |
getText()
Return the combined text of all child nodes.
|
void |
inspect(Parser parser)
Call this method to view a parse tree in a dialog box visually.
|
boolean |
isEmpty()
A context is empty if there is no invoking state; meaning nobody call
current context.
|
void |
save(Parser parser,
String fileName)
Save this tree in a postscript file
|
void |
save(Parser parser,
String fileName,
String fontName,
int fontSize)
Save this tree in a postscript file using a particular font name and size
|
String |
toString() |
String |
toString(List<String> ruleNames) |
String |
toString(List<String> ruleNames,
RuleContext stop) |
String |
toString(Recognizer<?,?> recog) |
String |
toString(Recognizer<?,?> recog,
RuleContext stop) |
String |
toStringTree()
Print out a whole tree, not just a node, in LISP format
(root child1 ..
|
String |
toStringTree(List<String> ruleNames)
Print out a whole tree, not just a node, in LISP format
(root child1 ..
|
String |
toStringTree(Parser recog)
Print out a whole tree, not just a node, in LISP format
(root child1 ..
|
public static final ParserRuleContext EMPTY
public RuleContext parent
public int invokingState
public RuleContext()
public RuleContext(RuleContext parent, int invokingState)
public int depth()
public boolean isEmpty()
public Interval getSourceInterval()
SyntaxTreeInterval.INVALID.getSourceInterval in interface SyntaxTreepublic RuleContext getRuleContext()
getRuleContext in interface RuleNodepublic RuleContext getParent()
Treepublic RuleContext getPayload()
TreegetPayload in interface Treepublic String getText()
Since tokens on hidden channels (e.g. whitespace or comments) are not added to the parse trees, they will not appear in the output of this method.
public int getRuleIndex()
public ParseTree getChild(int i)
Treepublic int getChildCount()
TreegetChildCount in interface Treepublic <T> T accept(ParseTreeVisitor<? extends T> visitor)
ParseTreepublic void inspect(Parser parser)
public void save(Parser parser, String fileName) throws IOException, PrintException
IOExceptionPrintExceptionpublic void save(Parser parser, String fileName, String fontName, int fontSize) throws IOException
IOExceptionpublic String toStringTree(@Nullable Parser recog)
toStringTree in interface ParseTreepublic String toStringTree(@Nullable List<String> ruleNames)
public String toStringTree()
TreetoStringTree in interface Treepublic final String toString(@Nullable Recognizer<?,?> recog)
public String toString(@Nullable Recognizer<?,?> recog, @Nullable RuleContext stop)
Copyright © 2012. All Rights Reserved.