Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private collectFollowSets(s: ATNState, stopState: ATNState, followSets: FollowSetWithPath[], seen: Set, ruleStack: number[]) {
if (seen.has(s))
return;
seen.add(s);
if (s == stopState || s.stateType == ATNStateType.RULE_STOP) {
let set = new FollowSetWithPath();
set.intervals = IntervalSet.of(Token.EPSILON);
set.path = ruleStack.slice();
followSets.push(set);
return;
}
for (let transition of s.getTransitions()) {
if (transition.serializationType == TransitionType.RULE) {
let ruleTransition: RuleTransition = transition as RuleTransition;
if (ruleStack.indexOf(ruleTransition.target.ruleIndex) != -1)
continue;
ruleStack.push(ruleTransition.target.ruleIndex);
this.collectFollowSets(transition.target, stopState, followSets, seen, ruleStack);
ruleStack.pop();