was not computing lookahead correctly in _LOOK. It assumed all epsilons were predicates.
This commit is contained in:
parent
ea7037dd2d
commit
2232ea5101
|
@ -114,29 +114,34 @@ public class LL1Analyzer {
|
||||||
|
|
||||||
int n = s.getNumberOfTransitions();
|
int n = s.getNumberOfTransitions();
|
||||||
for (int i=0; i<n; i++) {
|
for (int i=0; i<n; i++) {
|
||||||
Transition t = s.transition(i);
|
Transition t = s.transition(i);
|
||||||
if ( t.getClass() == RuleTransition.class ) {
|
if ( t.getClass() == RuleTransition.class ) {
|
||||||
RuleContext newContext =
|
RuleContext newContext =
|
||||||
new RuleContext(ctx, s.stateNumber);
|
new RuleContext(ctx, s.stateNumber);
|
||||||
_LOOK(t.target, newContext, look, lookBusy, seeThruPreds);
|
_LOOK(t.target, newContext, look, lookBusy, seeThruPreds);
|
||||||
}
|
}
|
||||||
else if ( t.isEpsilon() && seeThruPreds ) {
|
else if ( t instanceof PredicateTransition ) {
|
||||||
_LOOK(t.target, ctx, look, lookBusy, seeThruPreds);
|
if ( seeThruPreds ) {
|
||||||
}
|
_LOOK(t.target, ctx, look, lookBusy, seeThruPreds);
|
||||||
else if ( t.getClass() == WildcardTransition.class ) {
|
}
|
||||||
look.addAll( IntervalSet.of(Token.MIN_USER_TOKEN_TYPE, atn.maxTokenType) );
|
}
|
||||||
}
|
else if ( t.isEpsilon() ) {
|
||||||
else {
|
_LOOK(t.target, ctx, look, lookBusy, seeThruPreds);
|
||||||
|
}
|
||||||
|
else if ( t.getClass() == WildcardTransition.class ) {
|
||||||
|
look.addAll( IntervalSet.of(Token.MIN_USER_TOKEN_TYPE, atn.maxTokenType) );
|
||||||
|
}
|
||||||
|
else {
|
||||||
// System.out.println("adding "+ t);
|
// System.out.println("adding "+ t);
|
||||||
IntervalSet set = t.label();
|
IntervalSet set = t.label();
|
||||||
if (set != null) {
|
if (set != null) {
|
||||||
if (t instanceof NotSetTransition) {
|
if (t instanceof NotSetTransition) {
|
||||||
set = set.complement(IntervalSet.of(Token.MIN_USER_TOKEN_TYPE, atn.maxTokenType));
|
set = set.complement(IntervalSet.of(Token.MIN_USER_TOKEN_TYPE, atn.maxTokenType));
|
||||||
}
|
}
|
||||||
look.addAll(set);
|
look.addAll(set);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue