Comparing version 1.1.8 to 1.1.10
@@ -53,1 +53,2 @@ ANTLR4-C3 Project Contributors Certification of Origin and Rights | ||
2017/08/27, nick-stephen, Nick Stephen, nicks _at_ vmware.com | ||
2018/08/06, nuzelac, Nino Uzelac, uzelac.nino@gmail.com |
@@ -20,2 +20,3 @@ import { Parser, ParserRuleContext } from 'antlr4ts'; | ||
private tokens; | ||
private precedenceStack; | ||
private tokenStartIndex; | ||
@@ -28,12 +29,12 @@ private statesProcessed; | ||
collectCandidates(caretTokenIndex: number, context?: ParserRuleContext): CandidatesCollection; | ||
private checkPredicate(transition); | ||
private translateToRuleIndex(ruleStack); | ||
private getFollowingTokens(transition); | ||
private determineFollowSets(start, stop); | ||
private collectFollowSets(s, stopState, followSets, seen, ruleStack); | ||
private processRule(startState, tokenIndex, callStack, indentation); | ||
private checkPredicate; | ||
private translateToRuleIndex; | ||
private getFollowingTokens; | ||
private determineFollowSets; | ||
private collectFollowSets; | ||
private processRule; | ||
private atnStateTypeMap; | ||
private generateBaseDescription(state); | ||
private printDescription(currentIndent, state, baseDescription, tokenIndex); | ||
private printRuleState(stack); | ||
private generateBaseDescription; | ||
private printDescription; | ||
private printRuleState; | ||
} |
@@ -64,2 +64,3 @@ 'use strict'; | ||
this.statesProcessed = 0; | ||
this.precedenceStack = []; | ||
this.tokenStartIndex = context ? context.start.tokenIndex : 0; | ||
@@ -80,3 +81,3 @@ let tokenStream = this.parser.inputStream; | ||
let startRule = context ? context.ruleIndex : 0; | ||
this.processRule(this.atn.ruleToStartState[startRule], 0, callStack, ""); | ||
this.processRule(this.atn.ruleToStartState[startRule], 0, callStack, 0, 0); | ||
if (this.showResult) { | ||
@@ -144,3 +145,3 @@ console.log("States processed: " + this.statesProcessed); | ||
if (!transition.isEpsilon) { | ||
let list = transition.label.toList(); | ||
let list = transition.label.toArray(); | ||
if (list.length == 1 && !this.ignoredTokens.has(list[0])) { | ||
@@ -170,3 +171,3 @@ result.push(list[0]); | ||
seen.add(s); | ||
if (s == stopState || s.stateType == 7) { | ||
if (s == stopState || s.stateType == atn_1.ATNStateType.RULE_STOP) { | ||
let set = new FollowSetWithPath(); | ||
@@ -215,3 +216,3 @@ set.intervals = misc_1.IntervalSet.of(antlr4ts_1.Token.EPSILON); | ||
} | ||
processRule(startState, tokenIndex, callStack, indentation) { | ||
processRule(startState, tokenIndex, callStack, precedence, indentation) { | ||
let positionMap = this.shortcutMap.get(startState.ruleIndex); | ||
@@ -257,3 +258,3 @@ if (!positionMap) { | ||
if (!this.translateToRuleIndex(fullPath)) { | ||
for (let symbol of set.intervals.toList()) | ||
for (let symbol of set.intervals.toArray()) | ||
if (!this.ignoredTokens.has(symbol)) { | ||
@@ -283,2 +284,5 @@ if (this.showDebugOutput) { | ||
} | ||
if (startState.isPrecedenceRule) { | ||
this.precedenceStack.push(precedence); | ||
} | ||
let statePipeline = []; | ||
@@ -297,12 +301,5 @@ let currentEntry; | ||
} | ||
switch (currentEntry.state.stateType) { | ||
case 2: | ||
indentation += " "; | ||
break; | ||
case 7: { | ||
result.add(currentEntry.tokenIndex); | ||
continue; | ||
} | ||
default: | ||
break; | ||
if (currentEntry.state.stateType == atn_1.ATNStateType.RULE_STOP) { | ||
result.add(currentEntry.tokenIndex); | ||
continue; | ||
} | ||
@@ -313,3 +310,4 @@ let transitions = currentEntry.state.getTransitions(); | ||
case 3: { | ||
let endStatus = this.processRule(transition.target, currentEntry.tokenIndex, callStack, indentation); | ||
let ruleTransition = transition; | ||
let endStatus = this.processRule(transition.target, currentEntry.tokenIndex, callStack, ruleTransition.precedence, indentation + 1); | ||
for (let position of endStatus) { | ||
@@ -325,6 +323,12 @@ statePipeline.push({ state: transition.followState, tokenIndex: position }); | ||
} | ||
case 10: { | ||
const predTransition = transition; | ||
if (predTransition.precedence >= this.precedenceStack[this.precedenceStack.length - 1]) | ||
statePipeline.push({ state: transition.target, tokenIndex: currentEntry.tokenIndex }); | ||
break; | ||
} | ||
case 9: { | ||
if (atCaret) { | ||
if (!this.translateToRuleIndex(callStack)) { | ||
for (let token of misc_1.IntervalSet.of(antlr4ts_1.Token.MIN_USER_TOKEN_TYPE, this.atn.maxTokenType).toList()) | ||
for (let token of misc_1.IntervalSet.of(antlr4ts_1.Token.MIN_USER_TOKEN_TYPE, this.atn.maxTokenType).toArray()) | ||
if (!this.ignoredTokens.has(token)) | ||
@@ -354,3 +358,3 @@ this.candidates.tokens.set(token, []); | ||
if (!this.translateToRuleIndex(callStack)) { | ||
let list = set.toList(); | ||
let list = set.toArray(); | ||
let addFollowing = list.length == 1; | ||
@@ -381,2 +385,5 @@ for (let symbol of list) | ||
callStack.pop(); | ||
if (startState.isPrecedenceRule) { | ||
this.precedenceStack.pop(); | ||
} | ||
positionMap.set(tokenIndex, result); | ||
@@ -389,4 +396,5 @@ return result; | ||
} | ||
printDescription(currentIndent, state, baseDescription, tokenIndex) { | ||
let output = currentIndent; | ||
printDescription(indentation, state, baseDescription, tokenIndex) { | ||
const indent = " ".repeat(indentation); | ||
let output = indent; | ||
let transitionDescription = ""; | ||
@@ -396,3 +404,3 @@ if (this.debugOutputWithTransitions) { | ||
let labels = ""; | ||
let symbols = transition.label ? transition.label.toList() : []; | ||
let symbols = transition.label ? transition.label.toArray() : []; | ||
if (symbols.length > 2) { | ||
@@ -410,3 +418,3 @@ labels = this.vocabulary.getDisplayName(symbols[0]) + " .. " + this.vocabulary.getDisplayName(symbols[symbols.length - 1]); | ||
labels = "ε"; | ||
transitionDescription += "\n" + currentIndent + "\t(" + labels + ") " + "[" + transition.target.stateNumber + " " + | ||
transitionDescription += "\n" + indent + "\t(" + labels + ") " + "[" + transition.target.stateNumber + " " + | ||
this.atnStateTypeMap[transition.target.stateType] + "] in " + this.ruleNames[transition.target.ruleIndex]; | ||
@@ -413,0 +421,0 @@ } |
@@ -9,3 +9,3 @@ import { ParseTree } from 'antlr4ts/tree/ParseTree'; | ||
Private = 2, | ||
Library = 3, | ||
Library = 3 | ||
} | ||
@@ -20,3 +20,3 @@ export declare enum TypeKind { | ||
Array = 6, | ||
Alias = 7, | ||
Alias = 7 | ||
} | ||
@@ -27,3 +27,3 @@ export declare enum ReferenceKind { | ||
Reference = 2, | ||
Instance = 3, | ||
Instance = 3 | ||
} | ||
@@ -133,3 +133,3 @@ export interface Type { | ||
SetterOrGetter = 8, | ||
Explicit = 16, | ||
Explicit = 16 | ||
} | ||
@@ -136,0 +136,0 @@ export declare class MethodSymbol extends RoutineSymbol { |
{ | ||
"name": "antlr4-c3", | ||
"version": "1.1.8", | ||
"version": "1.1.10", | ||
"description": "A code completion core implmentation for ANTLR4 based parsers", | ||
@@ -24,12 +24,12 @@ "main": "out/index.js", | ||
"dependencies": { | ||
"antlr4ts": "^0.4.1-alpha.0" | ||
"antlr4ts": "^0.5.0-alpha.0" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "^3.4.34", | ||
"@types/mocha": "^2.2.48", | ||
"@types/node": "^6.0.103", | ||
"chai": "^3.5.0", | ||
"mocha": "^2.5.3", | ||
"path": "^0.12.7", | ||
"typescript": "^2.7.2" | ||
"@types/chai": "^4.1.7", | ||
"@types/mocha": "^5.2.5", | ||
"@types/node": "^10.12.18", | ||
"chai": ">=4.2.0", | ||
"mocha": ">=5.2.0", | ||
"path": ">=0.12.7", | ||
"typescript": "^3.2.2" | ||
}, | ||
@@ -36,0 +36,0 @@ "author": "Mike Lischke", |
@@ -134,3 +134,3 @@ [![NPM](https://nodei.co/npm/antlr4-c3.png?downloads=true&downloadRank=true)](https://nodei.co/npm/antlr4-c3/) | ||
for (let candidate of candidates.tokens) { | ||
keywords.push(parser.vocabulay.getDisplayName(candidate[0]); | ||
keywords.push(parser.vocabulary.getDisplayName(candidate[0])); | ||
} | ||
@@ -137,0 +137,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1293
176105
+ Addedantlr4ts@0.5.0-dev(transitive)
+ Addedbuffer-from@1.1.2(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsource-map-support@0.5.21(transitive)
- Removedantlr4ts@0.4.1-alpha.0(transitive)
Updatedantlr4ts@^0.5.0-alpha.0