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
i th 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.
|
Future<JDialog> |
inspect(List<String> ruleNames) |
Future<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(List<String> ruleNames,
String fileName)
Save this tree in a postscript file
|
void |
save(List<String> ruleNames,
String fileName,
String fontName,
int fontSize)
Save this tree in a postscript file using a particular font name and size
|
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
{@code (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()
SyntaxTree
Interval
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 SyntaxTree
public RuleContext getRuleContext()
getRuleContext
in interface RuleNode
public RuleContext getParent()
Tree
public RuleContext getPayload()
Tree
Token
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 Tree
public 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)
Tree
i
th value indexed from 0.public int getChildCount()
Tree
getChildCount
in interface Tree
public <T> T accept(ParseTreeVisitor<? extends T> visitor)
ParseTree
ParseTreeVisitor
needs a double dispatch method.public Future<JDialog> inspect(@Nullable Parser parser)
public void save(@Nullable Parser parser, String fileName) throws IOException, PrintException
IOException
PrintException
public void save(@Nullable Parser parser, String fileName, String fontName, int fontSize) throws IOException
IOException
public void save(@Nullable List<String> ruleNames, String fileName) throws IOException, PrintException
IOException
PrintException
public void save(@Nullable List<String> ruleNames, String fileName, String fontName, int fontSize) throws IOException
IOException
public String toStringTree(@Nullable Parser recog)
toStringTree
in interface ParseTree
public String toStringTree(@Nullable List<String> ruleNames)
public String toStringTree()
Tree
(root child1 .. childN)
. Print just a node if this is a leaf.toStringTree
in interface Tree
public final String toString(@Nullable Recognizer<?,?> recog)
public String toString(@Nullable Recognizer<?,?> recog, @Nullable RuleContext stop)
Copyright © 1992-2013 ANTLR. All Rights Reserved.