How to use the antlr4ts/misc.IntervalSet.of 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
let endStatus = this.processRule(transition.target, currentEntry.tokenIndex, callStack, indentation);
                    statePipeline.push(...endStatus);

                    // See description above for this flag.
                    if (isLeftRecursive && transition.target.ruleIndex == callStack[callStack.length - 1])
                        forceLoopEnd = true;

                } else if (transition.serializationType == TransitionType.PREDICATE) {
                    if (this.checkPredicate(transition as PredicateTransition))
                        statePipeline.push({ state: transition.target, tokenIndex: currentEntry.tokenIndex });
                } else if (transition.isEpsilon) {
                    statePipeline.push({ state: transition.target, tokenIndex: currentEntry.tokenIndex });
                } else if (transition.serializationType == TransitionType.WILDCARD) {
                    if (atCaret) {
                        if (!this.translateToRuleIndex(callStack)) {
                            for (let token of IntervalSet.of(Token.MIN_USER_TOKEN_TYPE, this.atn.maxTokenType).toList())
                                if (!this.ignoredTokens.has(token))
                                    this.candidates.tokens.set(token, []);
                        }
                    } else {
                        statePipeline.push({ state: transition.target, tokenIndex: currentEntry.tokenIndex + 1 });
                    }
                } else {
                    let set = transition.label;
                    if (set && set.size > 0) {
                        if (transition.serializationType == TransitionType.NOT_SET) {
                            set = set.complement(IntervalSet.of(Token.MIN_USER_TOKEN_TYPE, this.atn.maxTokenType));
                        }
                        if (atCaret) {
                            if (!this.translateToRuleIndex(callStack)) {
                                let list = set.toList();
                                let addFollowing = list.length == 1;
github mike-lischke / antlr4-c3 / src / CodeCompletionCore.ts View on Github external
statePipeline.push({ state: transition.target, tokenIndex: currentEntry.tokenIndex });
                } else if (transition.serializationType == TransitionType.WILDCARD) {
                    if (atCaret) {
                        if (!this.translateToRuleIndex(callStack)) {
                            for (let token of IntervalSet.of(Token.MIN_USER_TOKEN_TYPE, this.atn.maxTokenType).toList())
                                if (!this.ignoredTokens.has(token))
                                    this.candidates.tokens.set(token, []);
                        }
                    } else {
                        statePipeline.push({ state: transition.target, tokenIndex: currentEntry.tokenIndex + 1 });
                    }
                } else {
                    let set = transition.label;
                    if (set && set.size > 0) {
                        if (transition.serializationType == TransitionType.NOT_SET) {
                            set = set.complement(IntervalSet.of(Token.MIN_USER_TOKEN_TYPE, this.atn.maxTokenType));
                        }
                        if (atCaret) {
                            if (!this.translateToRuleIndex(callStack)) {
                                let list = set.toList();
                                let addFollowing = list.length == 1;
                                for (let symbol of list)
                                    if (!this.ignoredTokens.has(symbol)) {
                                        if (this.showDebugOutput)
                                            console.log("=====> collected: ", this.vocabulary.getDisplayName(symbol));

                                        if (addFollowing)
                                            this.candidates.tokens.set(symbol, this.getFollowingTokens(transition));
                                        else
                                            this.candidates.tokens.set(symbol, []);
                                    }
                            }
github mike-lischke / antlr4-c3 / src / CodeCompletionCore.ts View on Github external
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) {
                if (this.checkPredicate(transition as PredicateTransition))
                    this.collectFollowSets(transition.target, stopState, followSets, seen, ruleStack);
            } else if (transition.isEpsilon) {
                this.collectFollowSets(transition.target, stopState, followSets, seen, ruleStack);
            } else if (transition.serializationType == TransitionType.WILDCARD) {
                let set = new FollowSetWithPath();
                set.intervals = IntervalSet.of(Token.MIN_USER_TOKEN_TYPE, this.atn.maxTokenType);
                set.path = ruleStack.slice();
                followSets.push(set);
            } else {
                let label = transition.label;
                if (label && label.size > 0) {
                    if (transition.serializationType == TransitionType.NOT_SET) {
                        label = label.complement(IntervalSet.of(Token.MIN_USER_TOKEN_TYPE, this.atn.maxTokenType));
                    }
                    let set = new FollowSetWithPath();
                    set.intervals = label;
                    set.path = ruleStack.slice();
                    set.following = this.getFollowingTokens(transition);
                    followSets.push(set);
                }
            }
        }
github mike-lischke / antlr4-c3 / src / CodeCompletionCore.ts View on Github external
} else if (transition.serializationType == TransitionType.PREDICATE) {
                if (this.checkPredicate(transition as PredicateTransition))
                    this.collectFollowSets(transition.target, stopState, followSets, seen, ruleStack);
            } else if (transition.isEpsilon) {
                this.collectFollowSets(transition.target, stopState, followSets, seen, ruleStack);
            } else if (transition.serializationType == TransitionType.WILDCARD) {
                let set = new FollowSetWithPath();
                set.intervals = IntervalSet.of(Token.MIN_USER_TOKEN_TYPE, this.atn.maxTokenType);
                set.path = ruleStack.slice();
                followSets.push(set);
            } else {
                let label = transition.label;
                if (label && label.size > 0) {
                    if (transition.serializationType == TransitionType.NOT_SET) {
                        label = label.complement(IntervalSet.of(Token.MIN_USER_TOKEN_TYPE, this.atn.maxTokenType));
                    }
                    let set = new FollowSetWithPath();
                    set.intervals = label;
                    set.path = ruleStack.slice();
                    set.following = this.getFollowingTokens(transition);
                    followSets.push(set);
                }
            }
        }
    }