forked from jasder/antlr
mv ruleIndex, add alt
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9061]
This commit is contained in:
parent
62937ca639
commit
f13fd1973e
|
@ -53,12 +53,21 @@ public class ParserRuleContext extends RuleContext {
|
|||
public Object tree;
|
||||
public ST st;
|
||||
|
||||
/** Set during parsing to identify which rule parser is in. */
|
||||
public int ruleIndex;
|
||||
|
||||
/** Set during parsing to identify which alt of rule parser is in. */
|
||||
public int alt;
|
||||
|
||||
public ParserRuleContext() { super(); }
|
||||
|
||||
public ParserRuleContext(RuleContext parent, int stateNumber) {
|
||||
super(parent, stateNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRuleIndex() { return ruleIndex; }
|
||||
|
||||
public Object getTree() { return tree; }
|
||||
public ST getTemplate() { return st; }
|
||||
public Token getStart() { return start; }
|
||||
|
|
|
@ -84,9 +84,6 @@ public class RuleContext implements ParseTree.RuleNode {
|
|||
*/
|
||||
public int s = -1;
|
||||
|
||||
/** Set during parsing to identify which rule parser is in. */
|
||||
public int ruleIndex;
|
||||
|
||||
/** 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.
|
||||
|
@ -274,6 +271,8 @@ public class RuleContext implements ParseTree.RuleNode {
|
|||
|
||||
public int getChildCount() { return children!=null ? children.size() : 0; }
|
||||
|
||||
public int getRuleIndex() { return -1; }
|
||||
|
||||
public Interval getSourceInterval() {
|
||||
if ( getChildCount()==0 ) return Interval.ZeroLength;
|
||||
int start = getChild(0).getSourceInterval().a;
|
||||
|
|
|
@ -60,7 +60,7 @@ public class Trees {
|
|||
public static String getNodeText(Tree t, BaseRecognizer recog) {
|
||||
if ( recog!=null ) {
|
||||
if ( t instanceof ParseTree.RuleNode ) {
|
||||
int ruleIndex = ((ParseTree.RuleNode)t).getRuleContext().ruleIndex;
|
||||
int ruleIndex = ((ParseTree.RuleNode)t).getRuleContext().getRuleIndex();
|
||||
String ruleName = recog.getRuleNames()[ruleIndex];
|
||||
return ruleName;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue