How to use the antlr4ts.Token.EPSILON function in antlr4ts

To help you get started, we’ve selected a few antlr4ts examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mike-lischke / antlr4-c3 / src / CodeCompletionCore.ts View on Github external
if (this.candidates.tokens.get(symbol) != set.following)
                                        this.candidates.tokens.set(symbol, []);
                                }
                            }
                    }
                }
            }

            callStack.pop();
            return result;

        } else {
            // Process the rule if we either could pass it without consuming anything (epsilon transition)
            // or if the current input symbol will be matched somewhere after this entry point.
            // Otherwise stop here.
            if (!followSets.combined.contains(Token.EPSILON) && !followSets.combined.contains(currentSymbol)) {
                callStack.pop();
                return result;
            }
        }

        let isLeftRecursive = (startState as RuleStartState).leftFactored;
        let forceLoopEnd = false;

        // The current state execution pipeline contains all yet-to-be-processed ATN states in this rule.
        // For each such state we store the token index + a list of rules that lead to it.
        let statePipeline: PipelineEntry[] = [];
        let currentEntry;

        // Bootstrap the pipeline.
        statePipeline.push({ state: startState, tokenIndex: tokenIndex });
github mike-lischke / antlr4-c3 / src / CodeCompletionCore.ts View on Github external
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();

            } else if (transition.serializationType == TransitionType.PREDICATE) {