public class RuleContext extends java.lang.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. |
java.lang.String |
getText()
Return the combined text of all child nodes.
|
java.util.concurrent.Future<javax.swing.JDialog> |
inspect(java.util.List<java.lang.String> ruleNames) |
java.util.concurrent.Future<javax.swing.JDialog> |
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(java.util.List<java.lang.String> ruleNames,
java.lang.String fileName)
Save this tree in a postscript file
|
void |
save(java.util.List<java.lang.String> ruleNames,
java.lang.String fileName,
java.lang.String fontName,
int fontSize)
Save this tree in a postscript file using a particular font name and size
|
void |
save(Parser parser,
java.lang.String fileName)
Save this tree in a postscript file
|
void |
save(Parser parser,
java.lang.String fileName,
java.lang.String fontName,
int fontSize)
Save this tree in a postscript file using a particular font name and size
|
java.lang.String |
toString() |
java.lang.String |
toString(java.util.List<java.lang.String> ruleNames) |
java.lang.String |
toString(java.util.List<java.lang.String> ruleNames,
RuleContext stop) |
java.lang.String |
toString(Recognizer<?,?> recog) |
java.lang.String |
toString(Recognizer<?,?> recog,
RuleContext stop) |
java.lang.String |
toStringTree()
Print out a whole tree, not just a node, in LISP format
{@code (root child1 ..
|
java.lang.String |
toStringTree(java.util.List<java.lang.String> ruleNames)
Print out a whole tree, not just a node, in LISP format
(root child1 ..
|
java.lang.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 indicating the index in the
TokenStream of the first and last token associated with this
subtree. If this node is a leaf, then the interval represents a single
token.
If source interval is unknown, this returns Interval.INVALID.
getSourceInterval in interface SyntaxTreepublic RuleContext getRuleContext()
getRuleContext in interface RuleNodepublic RuleContext getParent()
Treepublic RuleContext getPayload()
TreeToken representing
a leaf node or a RuleContext object representing a rule
invocation. For abstract syntax trees (ASTs), this is a Token
object.getPayload in interface Treepublic java.lang.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)
Treeith value indexed from 0.public int getChildCount()
TreegetChildCount in interface Treepublic <T> T accept(ParseTreeVisitor<? extends T> visitor)
ParseTreeParseTreeVisitor needs a double dispatch method.public java.util.concurrent.Future<javax.swing.JDialog> inspect(Parser parser)
public java.util.concurrent.Future<javax.swing.JDialog> inspect(java.util.List<java.lang.String> ruleNames)
public void save(Parser parser, java.lang.String fileName) throws java.io.IOException, javax.print.PrintException
java.io.IOExceptionjavax.print.PrintExceptionpublic void save(Parser parser, java.lang.String fileName, java.lang.String fontName, int fontSize) throws java.io.IOException
java.io.IOExceptionpublic void save(java.util.List<java.lang.String> ruleNames,
java.lang.String fileName)
throws java.io.IOException,
javax.print.PrintException
java.io.IOExceptionjavax.print.PrintExceptionpublic void save(java.util.List<java.lang.String> ruleNames,
java.lang.String fileName,
java.lang.String fontName,
int fontSize)
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String toStringTree(Parser recog)
toStringTree in interface ParseTreepublic java.lang.String toStringTree(java.util.List<java.lang.String> ruleNames)
public java.lang.String toStringTree()
Tree(root child1 .. childN). Print just a node if this is a leaf.toStringTree in interface Treepublic java.lang.String toString()
toString in class java.lang.Objectpublic final java.lang.String toString(Recognizer<?,?> recog)
public final java.lang.String toString(java.util.List<java.lang.String> ruleNames)
public java.lang.String toString(Recognizer<?,?> recog, RuleContext stop)
public java.lang.String toString(java.util.List<java.lang.String> ruleNames,
RuleContext stop)