forked from jasder/antlr
fix def of EMPTY->INVALID
This commit is contained in:
parent
542e700644
commit
169f58a3ff
|
@ -294,7 +294,7 @@ public class ParserRuleContext<Symbol extends Token> extends RuleContext {
|
|||
|
||||
@Override
|
||||
public Interval getSourceInterval() {
|
||||
if ( start==null || stop==null ) return Interval.EMPTY;
|
||||
if ( start==null || stop==null ) return Interval.INVALID;
|
||||
return Interval.of(start.getTokenIndex(), stop.getTokenIndex());
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ public class ParserRuleContext<Symbol extends Token> extends RuleContext {
|
|||
*/
|
||||
public String getText(TokenStream tokens) {
|
||||
Interval range = getSourceInterval();
|
||||
return range==Interval.EMPTY ? null : tokens.toString(range.a, range.b);
|
||||
return range==Interval.INVALID ? null : tokens.toString(range.a, range.b);
|
||||
}
|
||||
|
||||
public Symbol getStart() { return start; }
|
||||
|
|
|
@ -212,7 +212,7 @@ public class RuleContext implements ParseTree.RuleNode {
|
|||
|
||||
@Override
|
||||
public Interval getSourceInterval() {
|
||||
return Interval.EMPTY;
|
||||
return Interval.INVALID;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,7 +33,6 @@ public class Interval {
|
|||
public static final int INTERVAL_POOL_MAX_VALUE = 1000;
|
||||
|
||||
public static final Interval INVALID = new Interval(-1,-2);
|
||||
public static final Interval EMPTY = new Interval(0,-1); // len 0
|
||||
|
||||
static Interval[] cache = new Interval[INTERVAL_POOL_MAX_VALUE+1];
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public interface SyntaxTree extends Tree {
|
|||
* node is a leaf, then the interval represents a single token.
|
||||
*
|
||||
* If source interval is unknown, this does not return null.
|
||||
* It returns an interval of length 0: Interval.EMPTY.
|
||||
* It returns Interval.INVALID.
|
||||
*/
|
||||
Interval getSourceInterval();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue