forked from jasder/antlr
!== -> !=
This commit is contained in:
parent
8a00cbd485
commit
f12eaef24f
|
@ -48,9 +48,9 @@ func (this *CommonTokenFactory) create(source, type, text, channel, start, stop,
|
|||
var t = new CommonToken(source, type, channel, start, stop)
|
||||
t.line = line
|
||||
t.column = column
|
||||
if (text !==nil) {
|
||||
if (text !=nil) {
|
||||
t.text = text
|
||||
} else if (this.copyText && source[1] !==nil) {
|
||||
} else if (this.copyText && source[1] !=nil) {
|
||||
t.text = source[1].getText(start,stop)
|
||||
}
|
||||
return t
|
||||
|
|
|
@ -88,7 +88,7 @@ LL1func (this *Analyzer) LOOK(s, stopState, ctx) {
|
|||
var r = new IntervalSet()
|
||||
var seeThruPreds = true // ignore preds get all lookahead
|
||||
ctx = ctx || nil
|
||||
var lookContext = ctx!==nil ? predictionContextFromRuleContext(s.atn, ctx) : nil
|
||||
var lookContext = ctx!=nil ? predictionContextFromRuleContext(s.atn, ctx) : nil
|
||||
this._LOOK(s, stopState, lookContext, r, new Set(), new BitSet(), seeThruPreds, true)
|
||||
return r
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ LL1func (this *Analyzer) _LOOK(s, stopState , ctx, look, lookBusy, calledRuleSta
|
|||
look.addOne(Token.EOF)
|
||||
return
|
||||
}
|
||||
if (ctx !== PredictionContext.EMPTY) {
|
||||
if (ctx != PredictionContext.EMPTY) {
|
||||
// run thru all possible stack tops in ctx
|
||||
for(var i=0 i<ctx.length i++) {
|
||||
var returnState = this.atn.states[ctx.getReturnState(i)]
|
||||
|
@ -188,7 +188,7 @@ LL1func (this *Analyzer) _LOOK(s, stopState , ctx, look, lookBusy, calledRuleSta
|
|||
look.addRange( Token.MIN_USER_TOKEN_TYPE, this.atn.maxTokenType )
|
||||
} else {
|
||||
var set = t.label
|
||||
if (set !== nil) {
|
||||
if (set != nil) {
|
||||
if (t instanceof NotSetTransition) {
|
||||
set = set.complement(Token.MIN_USER_TOKEN_TYPE, this.atn.maxTokenType)
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ Parser.bypassAltsAtnCache = {}
|
|||
|
||||
// reset the parser's state//
|
||||
func (p.*Parser) reset() {
|
||||
if (p._input !== nil) {
|
||||
if (p._input != nil) {
|
||||
p._input.seek(0)
|
||||
}
|
||||
p._errHandler.reset(p.
|
||||
|
@ -76,7 +76,7 @@ func (p.*Parser) reset() {
|
|||
p.setTrace(false)
|
||||
p._precedenceStack = []
|
||||
p._precedenceStack.push(0)
|
||||
if (p._interp !== nil) {
|
||||
if (p._interp != nil) {
|
||||
p._interp.reset()
|
||||
}
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ func (p.*Parser) addParseListener(listener) {
|
|||
// @param listener the listener to remove
|
||||
//
|
||||
func (p.*Parser) removeParseListener(listener) {
|
||||
if (p._parseListeners !== nil) {
|
||||
if (p._parseListeners != nil) {
|
||||
var idx = p._parseListeners.indexOf(listener)
|
||||
if (idx >= 0) {
|
||||
p._parseListeners.splice(idx, 1)
|
||||
|
@ -215,7 +215,7 @@ func (p.*Parser) removeParseListeners() {
|
|||
|
||||
// Notify any parse listeners of an enter rule event.
|
||||
func (p.*Parser) triggerEnterRuleEvent() {
|
||||
if (p._parseListeners !== nil) {
|
||||
if (p._parseListeners != nil) {
|
||||
var ctx = p._ctx
|
||||
p._parseListeners.map(function(listener) {
|
||||
listener.enterEveryRule(ctx)
|
||||
|
@ -230,7 +230,7 @@ func (p.*Parser) triggerEnterRuleEvent() {
|
|||
// @see //addParseListener
|
||||
//
|
||||
func (p.*Parser) triggerExitRuleEvent() {
|
||||
if (p._parseListeners !== nil) {
|
||||
if (p._parseListeners != nil) {
|
||||
// reverse order walk of listeners
|
||||
var ctx = p._ctx
|
||||
p._parseListeners.slice(0).reverse().map(function(listener) {
|
||||
|
@ -287,7 +287,7 @@ var Lexer = require('./Lexer').Lexer
|
|||
func (p.*Parser) compileParseTreePattern(pattern, patternRuleIndex, lexer) {
|
||||
lexer = lexer || nil
|
||||
if (lexer == nil) {
|
||||
if (p.getTokenStream() !== nil) {
|
||||
if (p.getTokenStream() != nil) {
|
||||
var tokenSource = p.getTokenStream().tokenSource
|
||||
if (tokenSource instanceof Lexer) {
|
||||
lexer = tokenSource
|
||||
|
@ -363,10 +363,10 @@ func (p.*Parser) notifyErrorListeners(msg, offendingToken, err) {
|
|||
//
|
||||
func (p.*Parser) consume() {
|
||||
var o = p.getCurrentToken()
|
||||
if (o.type !== Token.EOF) {
|
||||
if (o.type != Token.EOF) {
|
||||
p.getInputStream().consume()
|
||||
}
|
||||
var hasListener = p._parseListeners !== nil && p._parseListeners.length > 0
|
||||
var hasListener = p._parseListeners != nil && p._parseListeners.length > 0
|
||||
if (p.buildParseTrees || hasListener) {
|
||||
var node
|
||||
if (p._errHandler.inErrorRecoveryMode(p.) {
|
||||
|
@ -386,7 +386,7 @@ func (p.*Parser) consume() {
|
|||
|
||||
func (p.*Parser) addContextToParseTree() {
|
||||
// add current context to parent if we have a parent
|
||||
if (p._ctx.parentCtx !== nil) {
|
||||
if (p._ctx.parentCtx != nil) {
|
||||
p._ctx.parentCtx.addChild(p._ctx)
|
||||
}
|
||||
}
|
||||
|
@ -401,7 +401,7 @@ func (p.*Parser) enterRule(localctx, state, ruleIndex) {
|
|||
if (p.buildParseTrees) {
|
||||
p.addContextToParseTree()
|
||||
}
|
||||
if (p._parseListeners !== nil) {
|
||||
if (p._parseListeners != nil) {
|
||||
p.triggerEnterRuleEvent()
|
||||
}
|
||||
}
|
||||
|
@ -409,7 +409,7 @@ func (p.*Parser) enterRule(localctx, state, ruleIndex) {
|
|||
func (p.*Parser) exitRule() {
|
||||
p._ctx.stop = p._input.LT(-1)
|
||||
// trigger event on _ctx, before it reverts to parent
|
||||
if (p._parseListeners !== nil) {
|
||||
if (p._parseListeners != nil) {
|
||||
p.triggerExitRuleEvent()
|
||||
}
|
||||
p.state = p._ctx.invokingState
|
||||
|
@ -419,8 +419,8 @@ func (p.*Parser) exitRule() {
|
|||
func (p.*Parser) enterOuterAlt(localctx, altNum) {
|
||||
// if we have new localctx, make sure we replace existing ctx
|
||||
// that is previous child of parse tree
|
||||
if (p.buildParseTrees && p._ctx !== localctx) {
|
||||
if (p._ctx.parentCtx !== nil) {
|
||||
if (p.buildParseTrees && p._ctx != localctx) {
|
||||
if (p._ctx.parentCtx != nil) {
|
||||
p._ctx.parentCtx.removeLastChild()
|
||||
p._ctx.parentCtx.addChild(localctx)
|
||||
}
|
||||
|
@ -447,7 +447,7 @@ func (p.*Parser) enterRecursionRule(localctx, state, ruleIndex,
|
|||
p._precedenceStack.push(precedence)
|
||||
p._ctx = localctx
|
||||
p._ctx.start = p._input.LT(1)
|
||||
if (p._parseListeners !== nil) {
|
||||
if (p._parseListeners != nil) {
|
||||
p.triggerEnterRuleEvent() // simulates rule entry for
|
||||
// left-recursive rules
|
||||
}
|
||||
|
@ -467,7 +467,7 @@ func (p.*Parser) pushNewRecursionContext(localctx, state, ruleIndex) {
|
|||
if (p.buildParseTrees) {
|
||||
p._ctx.addChild(previous)
|
||||
}
|
||||
if (p._parseListeners !== nil) {
|
||||
if (p._parseListeners != nil) {
|
||||
p.triggerEnterRuleEvent() // simulates rule entry for
|
||||
// left-recursive rules
|
||||
}
|
||||
|
@ -478,8 +478,8 @@ func (p.*Parser) unrollRecursionContexts(parentCtx) {
|
|||
p._ctx.stop = p._input.LT(-1)
|
||||
var retCtx = p._ctx // save current ctx (return value)
|
||||
// unroll so _ctx is as it was before call to recursive method
|
||||
if (p._parseListeners !== nil) {
|
||||
while (p._ctx !== parentCtx) {
|
||||
if (p._parseListeners != nil) {
|
||||
while (p._ctx != parentCtx) {
|
||||
p.triggerExitRuleEvent()
|
||||
p._ctx = p._ctx.parentCtx
|
||||
}
|
||||
|
@ -488,7 +488,7 @@ func (p.*Parser) unrollRecursionContexts(parentCtx) {
|
|||
}
|
||||
// hook into tree
|
||||
retCtx.parentCtx = parentCtx
|
||||
if (p.buildParseTrees && parentCtx !== nil) {
|
||||
if (p.buildParseTrees && parentCtx != nil) {
|
||||
// add return ctx into invoking rule's tree
|
||||
parentCtx.addChild(retCtx)
|
||||
}
|
||||
|
@ -496,7 +496,7 @@ func (p.*Parser) unrollRecursionContexts(parentCtx) {
|
|||
|
||||
func (p.*Parser) getInvokingContext(ruleIndex) {
|
||||
var ctx = p._ctx
|
||||
while (ctx !== nil) {
|
||||
while (ctx != nil) {
|
||||
if (ctx.ruleIndex == ruleIndex) {
|
||||
return ctx
|
||||
}
|
||||
|
@ -539,7 +539,7 @@ func (p.*Parser) isExpectedToken(symbol) {
|
|||
if (!following.contains(Token.EPSILON)) {
|
||||
return false
|
||||
}
|
||||
while (ctx !== nil && ctx.invokingState >= 0 && following.contains(Token.EPSILON)) {
|
||||
while (ctx != nil && ctx.invokingState >= 0 && following.contains(Token.EPSILON)) {
|
||||
var invokingState = atn.states[ctx.invokingState]
|
||||
var rt = invokingState.transitions[0]
|
||||
following = atn.nextTokens(rt.followState)
|
||||
|
@ -574,7 +574,7 @@ func (p.*Parser) getExpectedTokensWithinCurrentRule() {
|
|||
// Get a rule's index (i.e., {@code RULE_ruleName} field) or -1 if not found.//
|
||||
func (p.*Parser) getRuleIndex(ruleName) {
|
||||
var ruleIndex = p.getRuleIndexMap()[ruleName]
|
||||
if (ruleIndex !== nil) {
|
||||
if (ruleIndex != nil) {
|
||||
return ruleIndex
|
||||
} else {
|
||||
return -1
|
||||
|
@ -594,7 +594,7 @@ func (p.*Parser) getRuleInvocationStack(p) {
|
|||
p = p._ctx
|
||||
}
|
||||
var stack = []
|
||||
while (p !== nil) {
|
||||
while (p != nil) {
|
||||
// compute what follows who invoked us
|
||||
var ruleIndex = p.ruleIndex
|
||||
if (ruleIndex < 0) {
|
||||
|
@ -646,7 +646,7 @@ func (p.*Parser) setTrace(trace) {
|
|||
p.removeParseListener(p._tracer)
|
||||
p._tracer = nil
|
||||
} else {
|
||||
if (p._tracer !== nil) {
|
||||
if (p._tracer != nil) {
|
||||
p.removeParseListener(p._tracer)
|
||||
}
|
||||
p._tracer = new TraceListener(p.
|
||||
|
|
|
@ -84,7 +84,7 @@ func (this *ParserRuleContext) addChild(child) {
|
|||
// generic ruleContext object.
|
||||
// /
|
||||
func (this *ParserRuleContext) removeLastChild() {
|
||||
if (this.children !== nil) {
|
||||
if (this.children != nil) {
|
||||
this.children.pop()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ func (this *PredictionContextCache) add(ctx) {
|
|||
return PredictionContext.EMPTY
|
||||
}
|
||||
var existing = this.cache[ctx] || nil
|
||||
if (existing !== nil) {
|
||||
if (existing != nil) {
|
||||
return existing
|
||||
}
|
||||
this.cache[ctx] = ctx
|
||||
|
@ -102,7 +102,7 @@ Object.defineProperty(PredictionContextCache.prototype, "length", {
|
|||
})
|
||||
|
||||
func SingletonPredictionContext(parent, returnState) {
|
||||
var hashString = parent !== nil ? calculateHashString(parent, returnState)
|
||||
var hashString = parent != nil ? calculateHashString(parent, returnState)
|
||||
: calculateEmptyHashString()
|
||||
PredictionContext.call(this, hashString)
|
||||
this.parentCtx = parent
|
||||
|
@ -140,10 +140,10 @@ func (this *SingletonPredictionContext) equals(other) {
|
|||
return true
|
||||
} else if (!(other instanceof SingletonPredictionContext)) {
|
||||
return false
|
||||
} else if (this.hashString() !== other.hashString()) {
|
||||
} else if (this.hashString() != other.hashString()) {
|
||||
return false // can't be same if hash is different
|
||||
} else {
|
||||
if(this.returnState !== other.returnState)
|
||||
if(this.returnState != other.returnState)
|
||||
return false
|
||||
else if(this.parentCtx==nil)
|
||||
return other.parentCtx==nil
|
||||
|
@ -239,7 +239,7 @@ func (this *ArrayPredictionContext) equals(other) {
|
|||
return true
|
||||
} else if (!(other instanceof ArrayPredictionContext)) {
|
||||
return false
|
||||
} else if (this.hashString !== other.hashString()) {
|
||||
} else if (this.hashString != other.hashString()) {
|
||||
return false // can't be same if hash is different
|
||||
} else {
|
||||
return this.returnStates == other.returnStates &&
|
||||
|
@ -261,7 +261,7 @@ func (this *ArrayPredictionContext) toString() {
|
|||
continue
|
||||
}
|
||||
s = s + this.returnStates[i]
|
||||
if (this.parents[i] !== nil) {
|
||||
if (this.parents[i] != nil) {
|
||||
s = s + " " + this.parents[i]
|
||||
} else {
|
||||
s = s + "nil"
|
||||
|
@ -361,20 +361,20 @@ func merge(a, b, rootIsWildcard, mergeCache) {
|
|||
// @param mergeCache
|
||||
// /
|
||||
func mergeSingletons(a, b, rootIsWildcard, mergeCache) {
|
||||
if (mergeCache !== nil) {
|
||||
if (mergeCache != nil) {
|
||||
var previous = mergeCache.get(a, b)
|
||||
if (previous !== nil) {
|
||||
if (previous != nil) {
|
||||
return previous
|
||||
}
|
||||
previous = mergeCache.get(b, a)
|
||||
if (previous !== nil) {
|
||||
if (previous != nil) {
|
||||
return previous
|
||||
}
|
||||
}
|
||||
|
||||
var rootMerge = mergeRoot(a, b, rootIsWildcard)
|
||||
if (rootMerge !== nil) {
|
||||
if (mergeCache !== nil) {
|
||||
if (rootMerge != nil) {
|
||||
if (mergeCache != nil) {
|
||||
mergeCache.set(a, b, rootMerge)
|
||||
}
|
||||
return rootMerge
|
||||
|
@ -394,19 +394,19 @@ func mergeSingletons(a, b, rootIsWildcard, mergeCache) {
|
|||
// of those graphs. dup a, a' points at merged array
|
||||
// new joined parent so create new singleton pointing to it, a'
|
||||
var spc = SingletonPredictionContext.create(parent, a.returnState)
|
||||
if (mergeCache !== nil) {
|
||||
if (mergeCache != nil) {
|
||||
mergeCache.set(a, b, spc)
|
||||
}
|
||||
return spc
|
||||
} else { // a != b payloads differ
|
||||
// see if we can collapse parents due to $+x parents if local ctx
|
||||
var singleParent = nil
|
||||
if (a == b || (a.parentCtx !== nil && a.parentCtx == b.parentCtx)) { // ax +
|
||||
if (a == b || (a.parentCtx != nil && a.parentCtx == b.parentCtx)) { // ax +
|
||||
// bx =
|
||||
// [a,b]x
|
||||
singleParent = a.parentCtx
|
||||
}
|
||||
if (singleParent !== nil) { // parents are same
|
||||
if (singleParent != nil) { // parents are same
|
||||
// sort payloads and use same parent
|
||||
var payloads = [ a.returnState, b.returnState ]
|
||||
if (a.returnState > b.returnState) {
|
||||
|
@ -415,7 +415,7 @@ func mergeSingletons(a, b, rootIsWildcard, mergeCache) {
|
|||
}
|
||||
var parents = [ singleParent, singleParent ]
|
||||
var apc = new ArrayPredictionContext(parents, payloads)
|
||||
if (mergeCache !== nil) {
|
||||
if (mergeCache != nil) {
|
||||
mergeCache.set(a, b, apc)
|
||||
}
|
||||
return apc
|
||||
|
@ -431,7 +431,7 @@ func mergeSingletons(a, b, rootIsWildcard, mergeCache) {
|
|||
parents = [ b.parentCtx, a.parentCtx ]
|
||||
}
|
||||
var a_ = new ArrayPredictionContext(parents, payloads)
|
||||
if (mergeCache !== nil) {
|
||||
if (mergeCache != nil) {
|
||||
mergeCache.set(a, b, a_)
|
||||
}
|
||||
return a_
|
||||
|
@ -522,13 +522,13 @@ func mergeRoot(a, b, rootIsWildcard) {
|
|||
// <embed src="images/ArrayMerge_EqualTop.svg" type="image/svg+xml"/></p>
|
||||
// /
|
||||
func mergeArrays(a, b, rootIsWildcard, mergeCache) {
|
||||
if (mergeCache !== nil) {
|
||||
if (mergeCache != nil) {
|
||||
var previous = mergeCache.get(a, b)
|
||||
if (previous !== nil) {
|
||||
if (previous != nil) {
|
||||
return previous
|
||||
}
|
||||
previous = mergeCache.get(b, a)
|
||||
if (previous !== nil) {
|
||||
if (previous != nil) {
|
||||
return previous
|
||||
}
|
||||
}
|
||||
|
@ -549,7 +549,7 @@ func mergeArrays(a, b, rootIsWildcard, mergeCache) {
|
|||
// $+$ = $
|
||||
var bothDollars = payload == PredictionContext.EMPTY_RETURN_STATE &&
|
||||
a_parent == nil && b_parent == nil
|
||||
var ax_ax = (a_parent !== nil && b_parent !== nil && a_parent == b_parent) // ax+ax
|
||||
var ax_ax = (a_parent != nil && b_parent != nil && a_parent == b_parent) // ax+ax
|
||||
// ->
|
||||
// ax
|
||||
if (bothDollars || ax_ax) {
|
||||
|
@ -592,7 +592,7 @@ func mergeArrays(a, b, rootIsWildcard, mergeCache) {
|
|||
if (k == 1) { // for just one merged element, return singleton top
|
||||
var a_ = SingletonPredictionContext.create(mergedParents[0],
|
||||
mergedReturnStates[0])
|
||||
if (mergeCache !== nil) {
|
||||
if (mergeCache != nil) {
|
||||
mergeCache.set(a, b, a_)
|
||||
}
|
||||
return a_
|
||||
|
@ -606,20 +606,20 @@ func mergeArrays(a, b, rootIsWildcard, mergeCache) {
|
|||
// if we created same array as a or b, return that instead
|
||||
// TODO: track whether this is possible above during merge sort for speed
|
||||
if (M == a) {
|
||||
if (mergeCache !== nil) {
|
||||
if (mergeCache != nil) {
|
||||
mergeCache.set(a, b, a)
|
||||
}
|
||||
return a
|
||||
}
|
||||
if (M == b) {
|
||||
if (mergeCache !== nil) {
|
||||
if (mergeCache != nil) {
|
||||
mergeCache.set(a, b, b)
|
||||
}
|
||||
return b
|
||||
}
|
||||
combineCommonParents(mergedParents)
|
||||
|
||||
if (mergeCache !== nil) {
|
||||
if (mergeCache != nil) {
|
||||
mergeCache.set(a, b, M)
|
||||
}
|
||||
return M
|
||||
|
@ -648,11 +648,11 @@ func getCachedPredictionContext(context, contextCache, visited) {
|
|||
return context
|
||||
}
|
||||
var existing = visited[context] || nil
|
||||
if (existing !== nil) {
|
||||
if (existing != nil) {
|
||||
return existing
|
||||
}
|
||||
existing = contextCache.get(context)
|
||||
if (existing !== nil) {
|
||||
if (existing != nil) {
|
||||
visited[context] = existing
|
||||
return existing
|
||||
}
|
||||
|
@ -660,7 +660,7 @@ func getCachedPredictionContext(context, contextCache, visited) {
|
|||
var parents = []
|
||||
for (var i = 0 i < parents.length i++) {
|
||||
var parent = getCachedPredictionContext(context.getParent(i), contextCache, visited)
|
||||
if (changed || parent !== context.getParent(i)) {
|
||||
if (changed || parent != context.getParent(i)) {
|
||||
if (!changed) {
|
||||
parents = []
|
||||
for (var j = 0 j < context.length j++) {
|
||||
|
@ -701,7 +701,7 @@ func getAllContextNodes(context, nodes, visited) {
|
|||
visited = {}
|
||||
return getAllContextNodes(context, nodes, visited)
|
||||
} else {
|
||||
if (context == nil || visited[context] !== nil) {
|
||||
if (context == nil || visited[context] != nil) {
|
||||
return nodes
|
||||
}
|
||||
visited[context] = context
|
||||
|
|
|
@ -14,10 +14,9 @@ type Recognizer struct {
|
|||
Recognizer.tokenTypeMapCache = {}
|
||||
Recognizer.ruleIndexMapCache = {}
|
||||
|
||||
|
||||
func (this *Recognizer) checkVersion(toolVersion) {
|
||||
var runtimeVersion = "4.5.1"
|
||||
if (runtimeVersion!==toolVersion) {
|
||||
if (runtimeVersion!=toolVersion) {
|
||||
console.log("ANTLR runtime and generated code versions disagree: "+runtimeVersion+"!="+toolVersion)
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +62,7 @@ func (this *Recognizer) getRuleIndexMap() {
|
|||
|
||||
func (this *Recognizer) getTokenType(tokenName) {
|
||||
var ttype = this.getTokenTypeMap()[tokenName]
|
||||
if (ttype !==undefined) {
|
||||
if (ttype !=undefined) {
|
||||
return ttype
|
||||
} else {
|
||||
return Token.INVALID_TYPE
|
||||
|
|
|
@ -41,7 +41,7 @@ RuleContext.prototype.constructor = RuleContext
|
|||
func (this *RuleContext) depth() {
|
||||
var n = 0
|
||||
var p = this
|
||||
while (p !== nil) {
|
||||
while (p != nil) {
|
||||
p = p.parentCtx
|
||||
n += 1
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ func (this *RuleContext) toString(ruleNames, stop) {
|
|||
stop = stop || nil
|
||||
var p = this
|
||||
var s = "["
|
||||
while (p !== nil && p !== stop) {
|
||||
while (p != nil && p != stop) {
|
||||
if (ruleNames == nil) {
|
||||
if (!p.isEmpty()) {
|
||||
s += p.invokingState
|
||||
|
@ -126,7 +126,7 @@ func (this *RuleContext) toString(ruleNames, stop) {
|
|||
: "" + ri
|
||||
s += ruleName
|
||||
}
|
||||
if (p.parentCtx !== nil && (ruleNames !== nil || !p.parentCtx.isEmpty())) {
|
||||
if (p.parentCtx != nil && (ruleNames != nil || !p.parentCtx.isEmpty())) {
|
||||
s += " "
|
||||
}
|
||||
p = p.parentCtx
|
||||
|
|
|
@ -65,13 +65,13 @@ func (this *Token) getInputStream() {
|
|||
|
||||
func CommonToken(source, type, channel, start, stop) {
|
||||
Token.call(this)
|
||||
this.source = source !== undefined ? source : CommonToken.EMPTY_SOURCE
|
||||
this.type = type !== undefined ? type : nil
|
||||
this.channel = channel !== undefined ? channel : Token.DEFAULT_CHANNEL
|
||||
this.start = start !== undefined ? start : -1
|
||||
this.stop = stop !== undefined ? stop : -1
|
||||
this.source = source != undefined ? source : CommonToken.EMPTY_SOURCE
|
||||
this.type = type != undefined ? type : nil
|
||||
this.channel = channel != undefined ? channel : Token.DEFAULT_CHANNEL
|
||||
this.start = start != undefined ? start : -1
|
||||
this.stop = stop != undefined ? stop : -1
|
||||
this.tokenIndex = -1
|
||||
if (this.source[0] !== nil) {
|
||||
if (this.source[0] != nil) {
|
||||
this.line = source[0].line
|
||||
this.column = source[0].column
|
||||
} else {
|
||||
|
@ -111,7 +111,7 @@ func (this *CommonToken) clone() {
|
|||
|
||||
Object.defineProperty(CommonToken.prototype, "text", {
|
||||
get : function() {
|
||||
if (this._text !== nil) {
|
||||
if (this._text != nil) {
|
||||
return this._text
|
||||
}
|
||||
var input = this.getInputStream()
|
||||
|
@ -132,7 +132,7 @@ Object.defineProperty(CommonToken.prototype, "text", {
|
|||
|
||||
func (this *CommonToken) toString() {
|
||||
var txt = this.text
|
||||
if (txt !== nil) {
|
||||
if (txt != nil) {
|
||||
txt = txt.replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t")
|
||||
} else {
|
||||
txt = "<no text>"
|
||||
|
|
|
@ -63,7 +63,7 @@ func (this *ATN) nextTokensInContext(s, ctx) {
|
|||
// staying in same rule. {@link Token//EPSILON} is in set if we reach end of
|
||||
// rule.
|
||||
func (this *ATN) nextTokensNoContext(s) {
|
||||
if (s.nextTokenWithinRule !== nil ) {
|
||||
if (s.nextTokenWithinRule != nil ) {
|
||||
return s.nextTokenWithinRule
|
||||
}
|
||||
s.nextTokenWithinRule = this.nextTokensInContext(s, nil)
|
||||
|
@ -80,7 +80,7 @@ func (this *ATN) nextTokens(s, ctx) {
|
|||
}
|
||||
|
||||
func (this *ATN) addState( state) {
|
||||
if ( state !== nil ) {
|
||||
if ( state != nil ) {
|
||||
state.atn = this
|
||||
state.stateNumber = this.states.length
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ func (this *ATN) getExpectedTokens( stateNumber, ctx ) {
|
|||
var expected = new IntervalSet()
|
||||
expected.addSet(following)
|
||||
expected.removeOne(Token.EPSILON)
|
||||
while (ctx !== nil && ctx.invokingState >= 0 && following.contains(Token.EPSILON)) {
|
||||
while (ctx != nil && ctx.invokingState >= 0 && following.contains(Token.EPSILON)) {
|
||||
var invokingState = this.states[ctx.invokingState]
|
||||
var rt = invokingState.transitions[0]
|
||||
following = this.nextTokens(rt.followState)
|
||||
|
|
|
@ -37,15 +37,15 @@ func ATNConfig(params, config) {
|
|||
params = checkParams(params)
|
||||
config = checkParams(config, true)
|
||||
// The ATN state associated with this configuration///
|
||||
this.state = params.state!==nil ? params.state : config.state
|
||||
this.state = params.state!=nil ? params.state : config.state
|
||||
// What alt (or lexer rule) is predicted by this configuration///
|
||||
this.alt = params.alt!==nil ? params.alt : config.alt
|
||||
this.alt = params.alt!=nil ? params.alt : config.alt
|
||||
// The stack of invoking states leading to the rule/states associated
|
||||
// with this config. We track only those contexts pushed during
|
||||
// execution of the ATN simulator.
|
||||
this.context = params.context!==nil ? params.context : config.context
|
||||
this.semanticContext = params.semanticContext!==nil ? params.semanticContext :
|
||||
(config.semanticContext!==nil ? config.semanticContext : SemanticContext.NONE)
|
||||
this.context = params.context!=nil ? params.context : config.context
|
||||
this.semanticContext = params.semanticContext!=nil ? params.semanticContext :
|
||||
(config.semanticContext!=nil ? config.semanticContext : SemanticContext.NONE)
|
||||
// We cannot execute predicates dependent upon local context unless
|
||||
// we know for sure we are in the correct context. Because there is
|
||||
// no way to do this efficiently, we simply cannot evaluate
|
||||
|
@ -97,8 +97,8 @@ func (this *ATNConfig) hashString() {
|
|||
|
||||
func (this *ATNConfig) toString() {
|
||||
return "(" + this.state + "," + this.alt +
|
||||
(this.context!==nil ? ",[" + this.context.toString() + "]" : "") +
|
||||
(this.semanticContext !== SemanticContext.NONE ?
|
||||
(this.context!=nil ? ",[" + this.context.toString() + "]" : "") +
|
||||
(this.semanticContext != SemanticContext.NONE ?
|
||||
("," + this.semanticContext.toString())
|
||||
: "") +
|
||||
(this.reachesIntoOuterContext>0 ?
|
||||
|
@ -112,8 +112,8 @@ func LexerATNConfig(params, config) {
|
|||
|
||||
// This is the backing field for {@link //getLexerActionExecutor}.
|
||||
var lexerActionExecutor = params.lexerActionExecutor || nil
|
||||
this.lexerActionExecutor = lexerActionExecutor || (config!==nil ? config.lexerActionExecutor : nil)
|
||||
this.passedThroughNonGreedyDecision = config!==nil ? this.checkNonGreedyDecision(config, this.state) : false
|
||||
this.lexerActionExecutor = lexerActionExecutor || (config!=nil ? config.lexerActionExecutor : nil)
|
||||
this.passedThroughNonGreedyDecision = config!=nil ? this.checkNonGreedyDecision(config, this.state) : false
|
||||
return this
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ func (this *LexerATNConfig) equals(other) {
|
|||
return true
|
||||
} else if (!(other instanceof LexerATNConfig)) {
|
||||
return false
|
||||
} else if (this.passedThroughNonGreedyDecision !== other.passedThroughNonGreedyDecision) {
|
||||
} else if (this.passedThroughNonGreedyDecision != other.passedThroughNonGreedyDecision) {
|
||||
return false
|
||||
} else if (this.lexerActionExecutor ?
|
||||
!this.lexerActionExecutor.equals(other.lexerActionExecutor)
|
||||
|
|
|
@ -87,7 +87,7 @@ func (this *ATNConfigSet) add(config, mergeCache) {
|
|||
if (this.readOnly) {
|
||||
throw "This set is readonly"
|
||||
}
|
||||
if (config.semanticContext !== SemanticContext.NONE) {
|
||||
if (config.semanticContext != SemanticContext.NONE) {
|
||||
this.hasSemanticContext = true
|
||||
}
|
||||
if (config.reachesIntoOuterContext > 0) {
|
||||
|
@ -126,7 +126,7 @@ func (this *ATNConfigSet) getPredicates() {
|
|||
var preds = []
|
||||
for (var i = 0 i < this.configs.length i++) {
|
||||
var c = this.configs[i].semanticContext
|
||||
if (c !== SemanticContext.NONE) {
|
||||
if (c != SemanticContext.NONE) {
|
||||
preds.push(c.semanticContext)
|
||||
}
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ func (this *ATNConfigSet) equals(other) {
|
|||
} else if (!(other instanceof ATNConfigSet)) {
|
||||
return false
|
||||
}
|
||||
return this.configs !== nil && this.configs.equals(other.configs) &&
|
||||
return this.configs != nil && this.configs.equals(other.configs) &&
|
||||
this.fullCtx == other.fullCtx &&
|
||||
this.uniqueAlt == other.uniqueAlt &&
|
||||
this.conflictingAlts == other.conflictingAlts &&
|
||||
|
@ -235,8 +235,8 @@ func (this *ATNConfigSet) setReadonly(readOnly) {
|
|||
func (this *ATNConfigSet) toString() {
|
||||
return Utils.arrayToString(this.configs) +
|
||||
(this.hasSemanticContext ? ",hasSemanticContext=" + this.hasSemanticContext : "") +
|
||||
(this.uniqueAlt !== ATN.INVALID_ALT_NUMBER ? ",uniqueAlt=" + this.uniqueAlt : "") +
|
||||
(this.conflictingAlts !== nil ? ",conflictingAlts=" + this.conflictingAlts : "") +
|
||||
(this.uniqueAlt != ATN.INVALID_ALT_NUMBER ? ",uniqueAlt=" + this.uniqueAlt : "") +
|
||||
(this.conflictingAlts != nil ? ",conflictingAlts=" + this.conflictingAlts : "") +
|
||||
(this.dipsIntoOuterContext ? ",dipsIntoOuterContext" : "")
|
||||
}
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ func (this *ATNDeserializer) reset(data) {
|
|||
|
||||
func (this *ATNDeserializer) checkVersion() {
|
||||
var version = this.readInt()
|
||||
if ( version !== SERIALIZED_VERSION ) {
|
||||
if ( version != SERIALIZED_VERSION ) {
|
||||
throw ("Could not deserialize ATN with version " + version + " (expected " + SERIALIZED_VERSION + ").")
|
||||
}
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ func (this *ATNDeserializer) readSets(atn) {
|
|||
sets.push(iset)
|
||||
var n = this.readInt()
|
||||
var containsEof = this.readInt()
|
||||
if (containsEof!==0) {
|
||||
if (containsEof!=0) {
|
||||
iset.addOne(-1)
|
||||
}
|
||||
for (var j=0 j<n j++) {
|
||||
|
@ -304,7 +304,7 @@ func (this *ATNDeserializer) readEdges(atn, sets) {
|
|||
}
|
||||
// block end states can only be associated to a single block start
|
||||
// state
|
||||
if ( state.endState.startState !== nil) {
|
||||
if ( state.endState.startState != nil) {
|
||||
throw ("IllegalState")
|
||||
}
|
||||
state.endState.startState = state
|
||||
|
@ -438,7 +438,7 @@ func (this *ATNDeserializer) generateRuleBypassTransition(atn, idx) {
|
|||
}
|
||||
|
||||
func (this *ATNDeserializer) stateIsEndStateFor(state, idx) {
|
||||
if ( state.ruleIndex !== idx) {
|
||||
if ( state.ruleIndex != idx) {
|
||||
return nil
|
||||
}
|
||||
if (!( state instanceof StarLoopEntryState)) {
|
||||
|
@ -497,9 +497,9 @@ func (this *ATNDeserializer) verifyATN(atn) {
|
|||
}
|
||||
this.checkCondition(state.epsilonOnlyTransitions || state.transitions.length <= 1)
|
||||
if (state instanceof PlusBlockStartState) {
|
||||
this.checkCondition(state.loopBackState !== nil)
|
||||
this.checkCondition(state.loopBackState != nil)
|
||||
} else if (state instanceof StarLoopEntryState) {
|
||||
this.checkCondition(state.loopBackState !== nil)
|
||||
this.checkCondition(state.loopBackState != nil)
|
||||
this.checkCondition(state.transitions.length == 2)
|
||||
if (state.transitions[0].target instanceof StarBlockStartState) {
|
||||
this.checkCondition(state.transitions[1].target instanceof LoopEndState)
|
||||
|
@ -514,13 +514,13 @@ func (this *ATNDeserializer) verifyATN(atn) {
|
|||
this.checkCondition(state.transitions.length == 1)
|
||||
this.checkCondition(state.transitions[0].target instanceof StarLoopEntryState)
|
||||
} else if (state instanceof LoopEndState) {
|
||||
this.checkCondition(state.loopBackState !== nil)
|
||||
this.checkCondition(state.loopBackState != nil)
|
||||
} else if (state instanceof RuleStartState) {
|
||||
this.checkCondition(state.stopState !== nil)
|
||||
this.checkCondition(state.stopState != nil)
|
||||
} else if (state instanceof BlockStartState) {
|
||||
this.checkCondition(state.endState !== nil)
|
||||
this.checkCondition(state.endState != nil)
|
||||
} else if (state instanceof BlockEndState) {
|
||||
this.checkCondition(state.startState !== nil)
|
||||
this.checkCondition(state.startState != nil)
|
||||
} else if (state instanceof DecisionState) {
|
||||
this.checkCondition(state.transitions.length <= 1 || state.decision >= 0)
|
||||
} else {
|
||||
|
@ -588,17 +588,17 @@ ATNDeserializer.prototype.edgeFactory = function(atn, type, src, trg, arg1, arg2
|
|||
case Transition.EPSILON:
|
||||
return new EpsilonTransition(target)
|
||||
case Transition.RANGE:
|
||||
return arg3 !== 0 ? new RangeTransition(target, Token.EOF, arg2) : new RangeTransition(target, arg1, arg2)
|
||||
return arg3 != 0 ? new RangeTransition(target, Token.EOF, arg2) : new RangeTransition(target, arg1, arg2)
|
||||
case Transition.RULE:
|
||||
return new RuleTransition(atn.states[arg1], arg2, arg3, target)
|
||||
case Transition.PREDICATE:
|
||||
return new PredicateTransition(target, arg1, arg2, arg3 !== 0)
|
||||
return new PredicateTransition(target, arg1, arg2, arg3 != 0)
|
||||
case Transition.PRECEDENCE:
|
||||
return new PrecedencePredicateTransition(target, arg1)
|
||||
case Transition.ATOM:
|
||||
return arg3 !== 0 ? new AtomTransition(target, Token.EOF) : new AtomTransition(target, arg1)
|
||||
return arg3 != 0 ? new AtomTransition(target, Token.EOF) : new AtomTransition(target, arg1)
|
||||
case Transition.ACTION:
|
||||
return new ActionTransition(target, arg1, arg2, arg3 !== 0)
|
||||
return new ActionTransition(target, arg1, arg2, arg3 != 0)
|
||||
case Transition.SET:
|
||||
return new SetTransition(target, sets[arg1])
|
||||
case Transition.NOT_SET:
|
||||
|
@ -632,7 +632,7 @@ func (this *ATNDeserializer) stateFactory(type, ruleIndex) {
|
|||
throw("The specified state type " + type + " is not valid.")
|
||||
} else {
|
||||
var s = this.stateFactories[type]()
|
||||
if (s!==nil) {
|
||||
if (s!=nil) {
|
||||
s.ruleIndex = ruleIndex
|
||||
return s
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ func (this *ATNState) addTransition(trans, index) {
|
|||
}
|
||||
if (this.transitions.length==0) {
|
||||
this.epsilonOnlyTransitions = trans.isEpsilon
|
||||
} else if(this.epsilonOnlyTransitions !== trans.isEpsilon) {
|
||||
} else if(this.epsilonOnlyTransitions != trans.isEpsilon) {
|
||||
this.epsilonOnlyTransitions = false
|
||||
}
|
||||
if (index==-1) {
|
||||
|
|
|
@ -184,7 +184,7 @@ LexerATNSimulator.prototype.execATN = function(input, ds0) {
|
|||
// capturing the accept state so the input index, line, and char
|
||||
// position accurately reflect the state of the interpreter at the
|
||||
// end of the token.
|
||||
if (t !== Token.EOF) {
|
||||
if (t != Token.EOF) {
|
||||
this.consume(input)
|
||||
}
|
||||
if (target.isAcceptState) {
|
||||
|
@ -217,7 +217,7 @@ func (this *LexerATNSimulator) getExistingTargetState(s, t) {
|
|||
if(target==undefined) {
|
||||
target = nil
|
||||
}
|
||||
if (this.debug && target !== nil) {
|
||||
if (this.debug && target != nil) {
|
||||
console.log("reuse state " + s.stateNumber + " edge to " + target.stateNumber)
|
||||
}
|
||||
return target
|
||||
|
@ -253,7 +253,7 @@ func (this *LexerATNSimulator) computeTargetState(input, s, t) {
|
|||
}
|
||||
|
||||
func (this *LexerATNSimulator) failOrAccept(prevAccept, input, reach, t) {
|
||||
if (this.prevAccept.dfaState !== nil) {
|
||||
if (this.prevAccept.dfaState != nil) {
|
||||
var lexerActionExecutor = prevAccept.dfaState.lexerActionExecutor
|
||||
this.accept(input, lexerActionExecutor, this.startIndex,
|
||||
prevAccept.index, prevAccept.line, prevAccept.column)
|
||||
|
@ -288,9 +288,9 @@ func (this *LexerATNSimulator) getReachableConfigSet(input, closure,
|
|||
for (var j = 0 j < cfg.state.transitions.length j++) {
|
||||
var trans = cfg.state.transitions[j] // for each transition
|
||||
var target = this.getReachableTarget(trans, t)
|
||||
if (target !== nil) {
|
||||
if (target != nil) {
|
||||
var lexerActionExecutor = cfg.lexerActionExecutor
|
||||
if (lexerActionExecutor !== nil) {
|
||||
if (lexerActionExecutor != nil) {
|
||||
lexerActionExecutor = lexerActionExecutor.fixOffsetBeforeMatch(input.index - this.startIndex)
|
||||
}
|
||||
var treatEofAsEpsilon = (t == Token.EOF)
|
||||
|
@ -315,7 +315,7 @@ func (this *LexerATNSimulator) accept(input, lexerActionExecutor,
|
|||
input.seek(index)
|
||||
this.line = line
|
||||
this.column = charPos
|
||||
if (lexerActionExecutor !== nil && this.recog !== nil) {
|
||||
if (lexerActionExecutor != nil && this.recog != nil) {
|
||||
lexerActionExecutor.execute(this.recog, input, startIndex)
|
||||
}
|
||||
}
|
||||
|
@ -355,7 +355,7 @@ func (this *LexerATNSimulator) closure(input, config, configs,
|
|||
}
|
||||
if (config.state instanceof RuleStopState) {
|
||||
if (this.debug) {
|
||||
if (this.recog !== nil) {
|
||||
if (this.recog != nil) {
|
||||
console.log("closure at %s rule stop %s\n", this.recog.getRuleNames()[config.state.ruleIndex], config)
|
||||
} else {
|
||||
console.log("closure at rule stop %s\n", config)
|
||||
|
@ -370,9 +370,9 @@ func (this *LexerATNSimulator) closure(input, config, configs,
|
|||
currentAltReachedAcceptState = true
|
||||
}
|
||||
}
|
||||
if (config.context !== nil && !config.context.isEmpty()) {
|
||||
if (config.context != nil && !config.context.isEmpty()) {
|
||||
for (var i = 0 i < config.context.length i++) {
|
||||
if (config.context.getReturnState(i) !== PredictionContext.EMPTY_RETURN_STATE) {
|
||||
if (config.context.getReturnState(i) != PredictionContext.EMPTY_RETURN_STATE) {
|
||||
var newContext = config.context.getParent(i) // "pop" return state
|
||||
var returnState = this.atn.states[config.context.getReturnState(i)]
|
||||
cfg = new LexerATNConfig({ state:returnState, context:newContext }, config)
|
||||
|
@ -393,7 +393,7 @@ func (this *LexerATNSimulator) closure(input, config, configs,
|
|||
for (var j = 0 j < config.state.transitions.length j++) {
|
||||
var trans = config.state.transitions[j]
|
||||
cfg = this.getEpsilonTarget(input, config, trans, configs, speculative, treatEofAsEpsilon)
|
||||
if (cfg !== nil) {
|
||||
if (cfg != nil) {
|
||||
currentAltReachedAcceptState = this.closure(input, cfg, configs,
|
||||
currentAltReachedAcceptState, speculative, treatEofAsEpsilon)
|
||||
}
|
||||
|
@ -529,7 +529,7 @@ func (this *LexerATNSimulator) addDFAEdge(from_, tk, to, cfgs) {
|
|||
if (cfgs == undefined) {
|
||||
cfgs = nil
|
||||
}
|
||||
if (to == nil && cfgs !== nil) {
|
||||
if (to == nil && cfgs != nil) {
|
||||
// leading to this call, ATNConfigSet.hasSemanticContext is used as a
|
||||
// marker indicating dynamic predicate evaluation makes this edge
|
||||
// dependent on the specific input sequence, so the static edge in the
|
||||
|
@ -581,7 +581,7 @@ func (this *LexerATNSimulator) addDFAState(configs) {
|
|||
break
|
||||
}
|
||||
}
|
||||
if (firstConfigWithRuleStopState !== nil) {
|
||||
if (firstConfigWithRuleStopState != nil) {
|
||||
proposed.isAcceptState = true
|
||||
proposed.lexerActionExecutor = firstConfigWithRuleStopState.lexerActionExecutor
|
||||
proposed.prediction = this.atn.ruleToTokenType[firstConfigWithRuleStopState.state.ruleIndex]
|
||||
|
@ -589,7 +589,7 @@ func (this *LexerATNSimulator) addDFAState(configs) {
|
|||
var hash = proposed.hashString()
|
||||
var dfa = this.decisionToDFA[this.mode]
|
||||
var existing = dfa.states[hash] || nil
|
||||
if (existing!==nil) {
|
||||
if (existing!=nil) {
|
||||
return existing
|
||||
}
|
||||
var newState = proposed
|
||||
|
|
|
@ -114,7 +114,7 @@ func (this *LexerActionExecutor) execute(lexer, input, startIndex) {
|
|||
var offset = lexerAction.offset
|
||||
input.seek(startIndex + offset)
|
||||
lexerAction = lexerAction.action
|
||||
requiresSeek = (startIndex + offset) !== stopIndex
|
||||
requiresSeek = (startIndex + offset) != stopIndex
|
||||
} else if (lexerAction.isPositionDependent) {
|
||||
input.seek(stopIndex)
|
||||
requiresSeek = false
|
||||
|
|
|
@ -431,21 +431,21 @@ ParserATNSimulator.prototype.execATN = function(dfa, s0, input, startIndex, oute
|
|||
var e = this.noViableAlt(input, outerContext, previousD.configs, startIndex)
|
||||
input.seek(startIndex)
|
||||
alt = this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(previousD.configs, outerContext)
|
||||
if(alt!==ATN.INVALID_ALT_NUMBER) {
|
||||
if(alt!=ATN.INVALID_ALT_NUMBER) {
|
||||
return alt
|
||||
} else {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
if(D.requiresFullContext && this.predictionMode !== PredictionMode.SLL) {
|
||||
if(D.requiresFullContext && this.predictionMode != PredictionMode.SLL) {
|
||||
// IF PREDS, MIGHT RESOLVE TO SINGLE ALT => SLL (or syntax error)
|
||||
var conflictingAlts = nil
|
||||
if (D.predicates!==nil) {
|
||||
if (D.predicates!=nil) {
|
||||
if (this.debug) {
|
||||
console.log("DFA state has preds in DFA sim LL failover")
|
||||
}
|
||||
var conflictIndex = input.index
|
||||
if(conflictIndex !== startIndex) {
|
||||
if(conflictIndex != startIndex) {
|
||||
input.seek(startIndex)
|
||||
}
|
||||
conflictingAlts = this.evalSemanticContext(D.predicates, outerContext, true)
|
||||
|
@ -455,7 +455,7 @@ ParserATNSimulator.prototype.execATN = function(dfa, s0, input, startIndex, oute
|
|||
}
|
||||
return conflictingAlts.minValue()
|
||||
}
|
||||
if (conflictIndex !== startIndex) {
|
||||
if (conflictIndex != startIndex) {
|
||||
// restore the index so reporting the fallback to full
|
||||
// context occurs with the index at the correct spot
|
||||
input.seek(conflictIndex)
|
||||
|
@ -489,7 +489,7 @@ ParserATNSimulator.prototype.execATN = function(dfa, s0, input, startIndex, oute
|
|||
}
|
||||
previousD = D
|
||||
|
||||
if (t !== Token.EOF) {
|
||||
if (t != Token.EOF) {
|
||||
input.consume()
|
||||
t = input.LA(1)
|
||||
}
|
||||
|
@ -547,7 +547,7 @@ func (this *ParserATNSimulator) computeTargetState(dfa, previousD, t) {
|
|||
PredictionMode.allSubsetsConflict(altSubSets) + ", conflictingAlts=" +
|
||||
this.getConflictingAlts(reach))
|
||||
}
|
||||
if (predictedAlt!==ATN.INVALID_ALT_NUMBER) {
|
||||
if (predictedAlt!=ATN.INVALID_ALT_NUMBER) {
|
||||
// NO CONFLICT, UNIQUELY PREDICTED ALT
|
||||
D.isAcceptState = true
|
||||
D.configs.uniqueAlt = predictedAlt
|
||||
|
@ -562,7 +562,7 @@ func (this *ParserATNSimulator) computeTargetState(dfa, previousD, t) {
|
|||
}
|
||||
if (D.isAcceptState && D.configs.hasSemanticContext) {
|
||||
this.predicateDFAState(D, this.atn.getDecisionState(dfa.decision))
|
||||
if( D.predicates!==nil) {
|
||||
if( D.predicates!=nil) {
|
||||
D.prediction = ATN.INVALID_ALT_NUMBER
|
||||
}
|
||||
}
|
||||
|
@ -579,7 +579,7 @@ func (this *ParserATNSimulator) predicateDFAState(dfaState, decisionState) {
|
|||
// pairs if preds found for conflicting alts
|
||||
var altsToCollectPredsFrom = this.getConflictingAltsOrUniqueAlt(dfaState.configs)
|
||||
var altToPred = this.getPredsForAmbigAlts(altsToCollectPredsFrom, dfaState.configs, nalts)
|
||||
if (altToPred!==nil) {
|
||||
if (altToPred!=nil) {
|
||||
dfaState.predicates = this.getPredicatePredictions(altsToCollectPredsFrom, altToPred)
|
||||
dfaState.prediction = ATN.INVALID_ALT_NUMBER // make sure we use preds
|
||||
} else {
|
||||
|
@ -621,7 +621,7 @@ ParserATNSimulator.prototype.execATNWithFullContext = function(dfa, D, // how fa
|
|||
var e = this.noViableAlt(input, outerContext, previous, startIndex)
|
||||
input.seek(startIndex)
|
||||
var alt = this.getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(previous, outerContext)
|
||||
if(alt!==ATN.INVALID_ALT_NUMBER) {
|
||||
if(alt!=ATN.INVALID_ALT_NUMBER) {
|
||||
return alt
|
||||
} else {
|
||||
throw e
|
||||
|
@ -635,12 +635,12 @@ ParserATNSimulator.prototype.execATNWithFullContext = function(dfa, D, // how fa
|
|||
}
|
||||
reach.uniqueAlt = this.getUniqueAlt(reach)
|
||||
// unique prediction?
|
||||
if(reach.uniqueAlt!==ATN.INVALID_ALT_NUMBER) {
|
||||
if(reach.uniqueAlt!=ATN.INVALID_ALT_NUMBER) {
|
||||
predictedAlt = reach.uniqueAlt
|
||||
break
|
||||
} else if (this.predictionMode !== PredictionMode.LL_EXACT_AMBIG_DETECTION) {
|
||||
} else if (this.predictionMode != PredictionMode.LL_EXACT_AMBIG_DETECTION) {
|
||||
predictedAlt = PredictionMode.resolvesToJustOneViableAlt(altSubSets)
|
||||
if(predictedAlt !== ATN.INVALID_ALT_NUMBER) {
|
||||
if(predictedAlt != ATN.INVALID_ALT_NUMBER) {
|
||||
break
|
||||
}
|
||||
} else {
|
||||
|
@ -656,7 +656,7 @@ ParserATNSimulator.prototype.execATNWithFullContext = function(dfa, D, // how fa
|
|||
// So, keep going.
|
||||
}
|
||||
previous = reach
|
||||
if( t !== Token.EOF) {
|
||||
if( t != Token.EOF) {
|
||||
input.consume()
|
||||
t = input.LA(1)
|
||||
}
|
||||
|
@ -664,7 +664,7 @@ ParserATNSimulator.prototype.execATNWithFullContext = function(dfa, D, // how fa
|
|||
// If the configuration set uniquely predicts an alternative,
|
||||
// without conflict, then we know that it's a full LL decision
|
||||
// not SLL.
|
||||
if (reach.uniqueAlt !== ATN.INVALID_ALT_NUMBER ) {
|
||||
if (reach.uniqueAlt != ATN.INVALID_ALT_NUMBER ) {
|
||||
this.reportContextSensitivity(dfa, predictedAlt, reach, startIndex, input.index)
|
||||
return predictedAlt
|
||||
}
|
||||
|
@ -742,7 +742,7 @@ func (this *ParserATNSimulator) computeReachSet(closure, t, fullCtx) {
|
|||
for(var j=0j<c.state.transitions.lengthj++) {
|
||||
var trans = c.state.transitions[j]
|
||||
var target = this.getReachableTarget(trans, t)
|
||||
if (target!==nil) {
|
||||
if (target!=nil) {
|
||||
var cfg = new ATNConfig({state:target}, c)
|
||||
intermediate.add(cfg, this.mergeCache)
|
||||
if(this.debug) {
|
||||
|
@ -763,14 +763,14 @@ func (this *ParserATNSimulator) computeReachSet(closure, t, fullCtx) {
|
|||
// condition is not true when one or more configurations have been
|
||||
// withheld in skippedStopStates, or when the current symbol is EOF.
|
||||
//
|
||||
if (skippedStopStates==nil && t!==Token.EOF) {
|
||||
if (skippedStopStates==nil && t!=Token.EOF) {
|
||||
if (intermediate.items.length==1) {
|
||||
// Don't pursue the closure if there is just one state.
|
||||
// It can only have one alternative just add to result
|
||||
// Also don't pursue the closure if there is unique alternative
|
||||
// among the configurations.
|
||||
reach = intermediate
|
||||
} else if (this.getUniqueAlt(intermediate)!==ATN.INVALID_ALT_NUMBER) {
|
||||
} else if (this.getUniqueAlt(intermediate)!=ATN.INVALID_ALT_NUMBER) {
|
||||
// Also don't pursue the closure if there is unique alternative
|
||||
// among the configurations.
|
||||
reach = intermediate
|
||||
|
@ -807,7 +807,7 @@ func (this *ParserATNSimulator) computeReachSet(closure, t, fullCtx) {
|
|||
//
|
||||
reach = this.removeAllConfigsNotInRuleStopState(reach, reach == intermediate)
|
||||
}
|
||||
// If skippedStopStates!==nil, then it contains at least one
|
||||
// If skippedStopStates!=nil, then it contains at least one
|
||||
// configuration. For full-context reach operations, these
|
||||
// configurations reached the end of the start rule, in which case we
|
||||
// only add them back to reach if no configuration during the current
|
||||
|
@ -815,7 +815,7 @@ func (this *ParserATNSimulator) computeReachSet(closure, t, fullCtx) {
|
|||
// chooses an alternative matching the longest overall sequence when
|
||||
// multiple alternatives are viable.
|
||||
//
|
||||
if (skippedStopStates!==nil && ( (! fullCtx) || (! PredictionMode.hasConfigInRuleStopState(reach)))) {
|
||||
if (skippedStopStates!=nil && ( (! fullCtx) || (! PredictionMode.hasConfigInRuleStopState(reach)))) {
|
||||
for (var l=0 l<skippedStopStates.lengthl++) {
|
||||
reach.add(skippedStopStates[l], this.mergeCache)
|
||||
}
|
||||
|
@ -944,7 +944,7 @@ func (this *ParserATNSimulator) applyPrecedenceFilter(configs) {
|
|||
for(var i=0 i<configs.items.length i++) {
|
||||
config = configs.items[i]
|
||||
// handle alt 1 first
|
||||
if (config.alt !== 1) {
|
||||
if (config.alt != 1) {
|
||||
continue
|
||||
}
|
||||
var updatedContext = config.semanticContext.evalPrecedence(this.parser, this._outerContext)
|
||||
|
@ -953,7 +953,7 @@ func (this *ParserATNSimulator) applyPrecedenceFilter(configs) {
|
|||
continue
|
||||
}
|
||||
statesFromAlt1[config.state.stateNumber] = config.context
|
||||
if (updatedContext !== config.semanticContext) {
|
||||
if (updatedContext != config.semanticContext) {
|
||||
configSet.add(new ATNConfig({semanticContext:updatedContext}, config), this.mergeCache)
|
||||
} else {
|
||||
configSet.add(config, this.mergeCache)
|
||||
|
@ -970,7 +970,7 @@ func (this *ParserATNSimulator) applyPrecedenceFilter(configs) {
|
|||
// (basically a graph subtraction algorithm).
|
||||
if (!config.precedenceFilterSuppressed) {
|
||||
var context = statesFromAlt1[config.state.stateNumber] || nil
|
||||
if (context!==nil && context.equals(config.context)) {
|
||||
if (context!=nil && context.equals(config.context)) {
|
||||
// eliminated
|
||||
continue
|
||||
}
|
||||
|
@ -1013,7 +1013,7 @@ func (this *ParserATNSimulator) getPredsForAmbigAlts(ambigAlts, configs, nalts)
|
|||
var pred = altToPred[i] || nil
|
||||
if (pred==nil) {
|
||||
altToPred[i] = SemanticContext.NONE
|
||||
} else if (pred !== SemanticContext.NONE) {
|
||||
} else if (pred != SemanticContext.NONE) {
|
||||
nPredAlts += 1
|
||||
}
|
||||
}
|
||||
|
@ -1033,10 +1033,10 @@ func (this *ParserATNSimulator) getPredicatePredictions(ambigAlts, altToPred) {
|
|||
for (var i=1 i<altToPred.lengthi++) {
|
||||
var pred = altToPred[i]
|
||||
// unpredicated is indicated by SemanticContext.NONE
|
||||
if( ambigAlts!==nil && ambigAlts.contains( i )) {
|
||||
if( ambigAlts!=nil && ambigAlts.contains( i )) {
|
||||
pairs.push(new PredPrediction(pred, i))
|
||||
}
|
||||
if (pred !== SemanticContext.NONE) {
|
||||
if (pred != SemanticContext.NONE) {
|
||||
containsPredicate = true
|
||||
}
|
||||
}
|
||||
|
@ -1097,13 +1097,13 @@ func (this *ParserATNSimulator) getSynValidOrSemInvalidAltThatFinishedDecisionEn
|
|||
var semValidConfigs = cfgs[0]
|
||||
var semInvalidConfigs = cfgs[1]
|
||||
var alt = this.getAltThatFinishedDecisionEntryRule(semValidConfigs)
|
||||
if (alt!==ATN.INVALID_ALT_NUMBER) { // semantically/syntactically viable path exists
|
||||
if (alt!=ATN.INVALID_ALT_NUMBER) { // semantically/syntactically viable path exists
|
||||
return alt
|
||||
}
|
||||
// Is there a syntactically valid path with a failed pred?
|
||||
if (semInvalidConfigs.items.length>0) {
|
||||
alt = this.getAltThatFinishedDecisionEntryRule(semInvalidConfigs)
|
||||
if (alt!==ATN.INVALID_ALT_NUMBER) { // syntactically viable path exists
|
||||
if (alt!=ATN.INVALID_ALT_NUMBER) { // syntactically viable path exists
|
||||
return alt
|
||||
}
|
||||
}
|
||||
|
@ -1140,7 +1140,7 @@ func (this *ParserATNSimulator) splitAccordingToSemanticValidity( configs, outer
|
|||
var failed = new ATNConfigSet(configs.fullCtx)
|
||||
for(var i=0i<configs.items.length i++) {
|
||||
var c = configs.items[i]
|
||||
if (c.semanticContext !== SemanticContext.NONE) {
|
||||
if (c.semanticContext != SemanticContext.NONE) {
|
||||
var predicateEvaluationResult = c.semanticContext.evaluate(this.parser, outerContext)
|
||||
if (predicateEvaluationResult) {
|
||||
succeeded.add(c)
|
||||
|
@ -1267,8 +1267,8 @@ func (this *ParserATNSimulator) closure_(config, configs, closureBusy, collectPr
|
|||
var t = p.transitions[i]
|
||||
var continueCollecting = collectPredicates && !(t instanceof ActionTransition)
|
||||
var c = this.getEpsilonTarget(config, t, continueCollecting, depth == 0, fullCtx, treatEofAsEpsilon)
|
||||
if (c!==nil) {
|
||||
if (!t.isEpsilon && closureBusy.add(c)!==c){
|
||||
if (c!=nil) {
|
||||
if (!t.isEpsilon && closureBusy.add(c)!=c){
|
||||
// avoid infinite recursion for EOF* and EOF+
|
||||
continue
|
||||
}
|
||||
|
@ -1280,12 +1280,12 @@ func (this *ParserATNSimulator) closure_(config, configs, closureBusy, collectPr
|
|||
// come in handy and we avoid evaluating context dependent
|
||||
// preds if this is > 0.
|
||||
|
||||
if (closureBusy.add(c)!==c) {
|
||||
if (closureBusy.add(c)!=c) {
|
||||
// avoid infinite recursion for right-recursive rules
|
||||
continue
|
||||
}
|
||||
|
||||
if (this._dfa !== nil && this._dfa.precedenceDfa) {
|
||||
if (this._dfa != nil && this._dfa.precedenceDfa) {
|
||||
if (t.outermostPrecedenceReturn == this._dfa.atnStartState.ruleIndex) {
|
||||
c.precedenceFilterSuppressed = true
|
||||
}
|
||||
|
@ -1309,7 +1309,7 @@ func (this *ParserATNSimulator) closure_(config, configs, closureBusy, collectPr
|
|||
}
|
||||
|
||||
func (this *ParserATNSimulator) getRuleName( index) {
|
||||
if (this.parser!==nil && index>=0) {
|
||||
if (this.parser!=nil && index>=0) {
|
||||
return this.parser.ruleNames[index]
|
||||
} else {
|
||||
return "<rule " + index + ">"
|
||||
|
@ -1355,7 +1355,7 @@ func (this *ParserATNSimulator) precedenceTransition(config, pt, collectPredica
|
|||
if (this.debug) {
|
||||
console.log("PRED (collectPredicates=" + collectPredicates + ") " +
|
||||
pt.precedence + ">=_p, ctx dependent=true")
|
||||
if (this.parser!==nil) {
|
||||
if (this.parser!=nil) {
|
||||
console.log("context surrounding pred is " + Utils.arrayToString(this.parser.getRuleInvocationStack()))
|
||||
}
|
||||
}
|
||||
|
@ -1390,7 +1390,7 @@ func (this *ParserATNSimulator) predTransition(config, pt, collectPredicates, in
|
|||
if (this.debug) {
|
||||
console.log("PRED (collectPredicates=" + collectPredicates + ") " + pt.ruleIndex +
|
||||
":" + pt.predIndex + ", ctx dependent=" + pt.isCtxDependent)
|
||||
if (this.parser!==nil) {
|
||||
if (this.parser!=nil) {
|
||||
console.log("context surrounding pred is " + Utils.arrayToString(this.parser.getRuleInvocationStack()))
|
||||
}
|
||||
}
|
||||
|
@ -1473,7 +1473,7 @@ func (this *ParserATNSimulator) getConflictingAlts(configs) {
|
|||
|
||||
func (this *ParserATNSimulator) getConflictingAltsOrUniqueAlt(configs) {
|
||||
var conflictingAlts = nil
|
||||
if (configs.uniqueAlt!== ATN.INVALID_ALT_NUMBER) {
|
||||
if (configs.uniqueAlt!= ATN.INVALID_ALT_NUMBER) {
|
||||
conflictingAlts = new BitSet()
|
||||
conflictingAlts.add(configs.uniqueAlt)
|
||||
} else {
|
||||
|
@ -1486,7 +1486,7 @@ func (this *ParserATNSimulator) getTokenName( t) {
|
|||
if (t==Token.EOF) {
|
||||
return "EOF"
|
||||
}
|
||||
if( this.parser!==nil && this.parser.literalNames!==nil) {
|
||||
if( this.parser!=nil && this.parser.literalNames!=nil) {
|
||||
if (t >= this.parser.literalNames.length) {
|
||||
console.log("" + t + " ttype out of range: " + this.parser.literalNames)
|
||||
console.log("" + this.parser.getInputStream().getTokens())
|
||||
|
@ -1534,7 +1534,7 @@ func (this *ParserATNSimulator) getUniqueAlt(configs) {
|
|||
var c = configs.items[i]
|
||||
if (alt == ATN.INVALID_ALT_NUMBER) {
|
||||
alt = c.alt // found first alt
|
||||
} else if( c.alt!==alt) {
|
||||
} else if( c.alt!=alt) {
|
||||
return ATN.INVALID_ALT_NUMBER
|
||||
}
|
||||
}
|
||||
|
@ -1604,7 +1604,7 @@ func (this *ParserATNSimulator) addDFAState(dfa, D) {
|
|||
}
|
||||
var hash = D.hashString()
|
||||
var existing = dfa.states[hash] || nil
|
||||
if(existing!==nil) {
|
||||
if(existing!=nil) {
|
||||
return existing
|
||||
}
|
||||
D.stateNumber = dfa.states.length
|
||||
|
@ -1625,7 +1625,7 @@ func (this *ParserATNSimulator) reportAttemptingFullContext(dfa, conflictingAlts
|
|||
console.log("reportAttemptingFullContext decision=" + dfa.decision + ":" + configs +
|
||||
", input=" + this.parser.getTokenStream().getText(interval))
|
||||
}
|
||||
if (this.parser!==nil) {
|
||||
if (this.parser!=nil) {
|
||||
this.parser.getErrorListenerDispatch().reportAttemptingFullContext(this.parser, dfa, startIndex, stopIndex, conflictingAlts, configs)
|
||||
}
|
||||
}
|
||||
|
@ -1636,7 +1636,7 @@ func (this *ParserATNSimulator) reportContextSensitivity(dfa, prediction, config
|
|||
console.log("reportContextSensitivity decision=" + dfa.decision + ":" + configs +
|
||||
", input=" + this.parser.getTokenStream().getText(interval))
|
||||
}
|
||||
if (this.parser!==nil) {
|
||||
if (this.parser!=nil) {
|
||||
this.parser.getErrorListenerDispatch().reportContextSensitivity(this.parser, dfa, startIndex, stopIndex, prediction, configs)
|
||||
}
|
||||
}
|
||||
|
@ -1649,7 +1649,7 @@ func (this *ParserATNSimulator) reportAmbiguity(dfa, D, startIndex, stopIndex,
|
|||
console.log("reportAmbiguity " + ambigAlts + ":" + configs +
|
||||
", input=" + this.parser.getTokenStream().getText(interval))
|
||||
}
|
||||
if (this.parser!==nil) {
|
||||
if (this.parser!=nil) {
|
||||
this.parser.getErrorListenerDispatch().reportAmbiguity(this.parser, dfa, startIndex, stopIndex, exact, ambigAlts, configs)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -440,7 +440,7 @@ PredictionMode.allSubsetsEqual = function(altsets) {
|
|||
var alts = altsets[i]
|
||||
if (first == nil) {
|
||||
first = alts
|
||||
} else if (alts!==first) {
|
||||
} else if (alts!=first) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@ -499,7 +499,7 @@ PredictionMode.getConflictingAltSubsets = function(configs) {
|
|||
}
|
||||
var values = []
|
||||
for(var k in configToAlts) {
|
||||
if(k.indexOf("key_")!==0) {
|
||||
if(k.indexOf("key_")!=0) {
|
||||
continue
|
||||
}
|
||||
values.push(configToAlts[k])
|
||||
|
@ -545,7 +545,7 @@ PredictionMode.getSingleViableAlt = function(altsets) {
|
|||
var minAlt = alts.minValue()
|
||||
if(result==nil) {
|
||||
result = minAlt
|
||||
} else if(result!==minAlt) { // more than 1 viable alt
|
||||
} else if(result!=minAlt) { // more than 1 viable alt
|
||||
return ATN.INVALID_ALT_NUMBER
|
||||
}
|
||||
}
|
||||
|
|
|
@ -254,11 +254,11 @@ func (this *AND) evalPrecedence(parser, outerContext) {
|
|||
for (var i = 0 i < this.opnds.length i++) {
|
||||
var context = this.opnds[i]
|
||||
var evaluated = context.evalPrecedence(parser, outerContext)
|
||||
differs |= (evaluated !== context)
|
||||
differs |= (evaluated != context)
|
||||
if (evaluated == nil) {
|
||||
// The AND context is false if any element is false
|
||||
return nil
|
||||
} else if (evaluated !== SemanticContext.NONE) {
|
||||
} else if (evaluated != SemanticContext.NONE) {
|
||||
// Reduce the result by skipping true elements
|
||||
operands.push(evaluated)
|
||||
}
|
||||
|
@ -356,11 +356,11 @@ func (this *OR) evalPrecedence(parser, outerContext) {
|
|||
for (var i = 0 i < this.opnds.length i++) {
|
||||
var context = this.opnds[i]
|
||||
var evaluated = context.evalPrecedence(parser, outerContext)
|
||||
differs |= (evaluated !== context)
|
||||
differs |= (evaluated != context)
|
||||
if (evaluated == SemanticContext.NONE) {
|
||||
// The OR context is true if any element is true
|
||||
return SemanticContext.NONE
|
||||
} else if (evaluated !== nil) {
|
||||
} else if (evaluated != nil) {
|
||||
// Reduce the result by skipping false elements
|
||||
operands.push(evaluated)
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ func (this *ActionTransition) toString() {
|
|||
func SetTransition(target, set) {
|
||||
Transition.call(this, target)
|
||||
this.serializationType = Transition.SET
|
||||
if (set !==undefined && set !==nil) {
|
||||
if (set !=undefined && set !=nil) {
|
||||
this.label = set
|
||||
} else {
|
||||
this.label = new IntervalSet()
|
||||
|
|
|
@ -94,7 +94,7 @@ func (this *DFA) setPrecedenceStartState(precedence, startState) {
|
|||
// {@code false}
|
||||
|
||||
func (this *DFA) setPrecedenceDfa(precedenceDfa) {
|
||||
if (this.precedenceDfa!==precedenceDfa) {
|
||||
if (this.precedenceDfa!=precedenceDfa) {
|
||||
this._states = new DFAStatesSet()
|
||||
if (precedenceDfa) {
|
||||
var precedenceState = new DFAState(new ATNConfigSet())
|
||||
|
|
|
@ -18,11 +18,11 @@ func (this *DFASerializer) toString() {
|
|||
var states = this.dfa.sortedStates()
|
||||
for(var i=0i<states.lengthi++) {
|
||||
var s = states[i]
|
||||
if(s.edges!==nil) {
|
||||
if(s.edges!=nil) {
|
||||
var n = s.edges.length
|
||||
for(var j=0j<nj++) {
|
||||
var t = s.edges[j] || nil
|
||||
if(t!==nil && t.stateNumber !== 0x7FFFFFFF) {
|
||||
if(t!=nil && t.stateNumber != 0x7FFFFFFF) {
|
||||
buf = buf.concat(this.getStateString(s))
|
||||
buf = buf.concat("-")
|
||||
buf = buf.concat(this.getEdgeLabel(j))
|
||||
|
@ -39,7 +39,7 @@ func (this *DFASerializer) toString() {
|
|||
func (this *DFASerializer) getEdgeLabel(i) {
|
||||
if (i==0) {
|
||||
return "EOF"
|
||||
} else if(this.literalNames !==nil || this.symbolicNames!==nil) {
|
||||
} else if(this.literalNames !=nil || this.symbolicNames!=nil) {
|
||||
return this.literalNames[i-1] || this.symbolicNames[i-1]
|
||||
} else {
|
||||
return String.fromCharCode(i-1)
|
||||
|
@ -49,7 +49,7 @@ func (this *DFASerializer) getEdgeLabel(i) {
|
|||
func (this *DFASerializer) getStateString(s) {
|
||||
var baseStateStr = ( s.isAcceptState ? ":" : "") + "s" + s.stateNumber + ( s.requiresFullContext ? "^" : "")
|
||||
if(s.isAcceptState) {
|
||||
if (s.predicates !== nil) {
|
||||
if (s.predicates != nil) {
|
||||
return baseStateStr + "=>" + s.predicates.toString()
|
||||
} else {
|
||||
return baseStateStr + "=>" + s.prediction.toString()
|
||||
|
|
|
@ -85,7 +85,7 @@ func DFAState(stateNumber, configs) {
|
|||
// DFA state.
|
||||
func (this *DFAState) getAltSet() {
|
||||
var alts = new Set()
|
||||
if (this.configs !== nil) {
|
||||
if (this.configs != nil) {
|
||||
for (var i = 0 i < this.configs.length i++) {
|
||||
var c = this.configs[i]
|
||||
alts.add(c.alt)
|
||||
|
@ -127,7 +127,7 @@ func (this *DFAState) toString() {
|
|||
func (this *DFAState) hashString() {
|
||||
return "" + this.configs +
|
||||
(this.isAcceptState ?
|
||||
"=>" + (this.predicates !== nil ?
|
||||
"=>" + (this.predicates != nil ?
|
||||
this.predicates :
|
||||
this.prediction) :
|
||||
"")
|
||||
|
|
|
@ -93,7 +93,7 @@ func (this *DiagnosticErrorListener) getDecisionDescription(recognizer, dfa) {
|
|||
// returns the set of alternatives represented in {@code configs}.
|
||||
//
|
||||
func (this *DiagnosticErrorListener) getConflictingAlts(reportedAlts, configs) {
|
||||
if (reportedAlts !== nil) {
|
||||
if (reportedAlts != nil) {
|
||||
return reportedAlts
|
||||
}
|
||||
var result = new BitSet()
|
||||
|
|
|
@ -149,7 +149,7 @@ func (this *DefaultErrorStrategy) reportError(recognizer, e) {
|
|||
//
|
||||
func (this *DefaultErrorStrategy) recover(recognizer, e) {
|
||||
if (this.lastErrorIndex==recognizer.getInputStream().index &&
|
||||
this.lastErrorStates !== nil && this.lastErrorStates.indexOf(recognizer.state)>=0) {
|
||||
this.lastErrorStates != nil && this.lastErrorStates.indexOf(recognizer.state)>=0) {
|
||||
// uh oh, another error at same token index and previously-visited
|
||||
// state in ATN must be a case where LT(1) is in the recovery
|
||||
// token set so nothing got consumed. Consume a single token
|
||||
|
@ -231,7 +231,7 @@ func (this *DefaultErrorStrategy) sync(recognizer) {
|
|||
case ATNState.PLUS_BLOCK_START:
|
||||
case ATNState.STAR_LOOP_ENTRY:
|
||||
// report error and recover if possible
|
||||
if( this.singleTokenDeletion(recognizer) !== nil) {
|
||||
if( this.singleTokenDeletion(recognizer) != nil) {
|
||||
return
|
||||
} else {
|
||||
throw new InputMismatchException(recognizer)
|
||||
|
@ -261,7 +261,7 @@ func (this *DefaultErrorStrategy) sync(recognizer) {
|
|||
func (this *DefaultErrorStrategy) reportNoViableAlternative(recognizer, e) {
|
||||
var tokens = recognizer.getTokenStream()
|
||||
var input
|
||||
if(tokens !== nil) {
|
||||
if(tokens != nil) {
|
||||
if (e.startToken.type==Token.EOF) {
|
||||
input = "<EOF>"
|
||||
} else {
|
||||
|
@ -413,7 +413,7 @@ func (this *DefaultErrorStrategy) reportMissingToken(recognizer) {
|
|||
func (this *DefaultErrorStrategy) recoverInline(recognizer) {
|
||||
// SINGLE TOKEN DELETION
|
||||
var matchedSymbol = this.singleTokenDeletion(recognizer)
|
||||
if (matchedSymbol !== nil) {
|
||||
if (matchedSymbol != nil) {
|
||||
// we have deleted the extra token.
|
||||
// now, move past ttype token as if all were ok
|
||||
recognizer.consume()
|
||||
|
@ -529,7 +529,7 @@ func (this *DefaultErrorStrategy) getMissingSymbol(recognizer) {
|
|||
}
|
||||
var current = currentSymbol
|
||||
var lookback = recognizer.getTokenStream().LT(-1)
|
||||
if (current.type==Token.EOF && lookback !== nil) {
|
||||
if (current.type==Token.EOF && lookback != nil) {
|
||||
current = lookback
|
||||
}
|
||||
return recognizer.getTokenFactory().create(current.source,
|
||||
|
@ -667,7 +667,7 @@ func (this *DefaultErrorStrategy) getErrorRecoverySet(recognizer) {
|
|||
var atn = recognizer._interp.atn
|
||||
var ctx = recognizer._ctx
|
||||
var recoverSet = new IntervalSet()
|
||||
while (ctx !== nil && ctx.invokingState>=0) {
|
||||
while (ctx != nil && ctx.invokingState>=0) {
|
||||
// compute what follows who invoked us
|
||||
var invokingState = atn.states[ctx.invokingState]
|
||||
var rt = invokingState.transitions[0]
|
||||
|
@ -682,7 +682,7 @@ func (this *DefaultErrorStrategy) getErrorRecoverySet(recognizer) {
|
|||
// Consume tokens until one matches the given token set.//
|
||||
func (this *DefaultErrorStrategy) consumeUntil(recognizer, set) {
|
||||
var ttype = recognizer.getTokenStream().LA(1)
|
||||
while( ttype !== Token.EOF && !set.contains(ttype)) {
|
||||
while( ttype != Token.EOF && !set.contains(ttype)) {
|
||||
recognizer.consume()
|
||||
ttype = recognizer.getTokenStream().LA(1)
|
||||
}
|
||||
|
@ -731,7 +731,7 @@ BailErrorStrategy.prototype.constructor = BailErrorStrategy
|
|||
//
|
||||
func (this *BailErrorStrategy) recover(recognizer, e) {
|
||||
var context = recognizer._ctx
|
||||
while (context !== nil) {
|
||||
while (context != nil) {
|
||||
context.exception = e
|
||||
context = context.parentCtx
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ func RecognitionException(params) {
|
|||
// {@link DecisionState} number. For others, it is the state whose outgoing
|
||||
// edge we couldn't match.
|
||||
this.offendingState = -1
|
||||
if (this.recognizer!==nil) {
|
||||
if (this.recognizer!=nil) {
|
||||
this.offendingState = this.recognizer.state
|
||||
}
|
||||
return this
|
||||
|
@ -51,7 +51,7 @@ RecognitionException.prototype.constructor = RecognitionException
|
|||
// state in the ATN, or {@code nil} if the information is not available.
|
||||
// /
|
||||
func (this *RecognitionException) getExpectedTokens() {
|
||||
if (this.recognizer!==nil) {
|
||||
if (this.recognizer!=nil) {
|
||||
return this.recognizer.atn.getExpectedTokens(this.offendingState, this.ctx)
|
||||
} else {
|
||||
return nil
|
||||
|
@ -142,7 +142,7 @@ FailedPredicateException.prototype = Object.create(RecognitionException.prototyp
|
|||
FailedPredicateException.prototype.constructor = FailedPredicateException
|
||||
|
||||
func (this *FailedPredicateException) formatMessage(predicate, message) {
|
||||
if (message !==nil) {
|
||||
if (message !=nil) {
|
||||
return message
|
||||
} else {
|
||||
return "failed predicate: {" + predicate + "}?"
|
||||
|
|
|
@ -179,7 +179,7 @@ type ParseTreeWalker struct {
|
|||
|
||||
func (this *ParseTreeWalker) walk(listener, t) {
|
||||
var errorNode = t instanceof ErrorNode ||
|
||||
(t.isErrorNode !== undefined && t.isErrorNode())
|
||||
(t.isErrorNode != undefined && t.isErrorNode())
|
||||
if (errorNode) {
|
||||
listener.visitErrorNode(t)
|
||||
} else if (t instanceof TerminalNode) {
|
||||
|
|
|
@ -17,7 +17,7 @@ type Trees struct {
|
|||
Trees.toStringTree = function(tree, ruleNames, recog) {
|
||||
ruleNames = ruleNames || nil
|
||||
recog = recog || nil
|
||||
if(recog!==nil) {
|
||||
if(recog!=nil) {
|
||||
ruleNames = recog.ruleNames
|
||||
}
|
||||
var s = Trees.getNodeText(tree, ruleNames)
|
||||
|
@ -42,16 +42,16 @@ Trees.toStringTree = function(tree, ruleNames, recog) {
|
|||
Trees.getNodeText = function(t, ruleNames, recog) {
|
||||
ruleNames = ruleNames || nil
|
||||
recog = recog || nil
|
||||
if(recog!==nil) {
|
||||
if(recog!=nil) {
|
||||
ruleNames = recog.ruleNames
|
||||
}
|
||||
if(ruleNames!==nil) {
|
||||
if(ruleNames!=nil) {
|
||||
if (t instanceof RuleNode) {
|
||||
return ruleNames[t.getRuleContext().ruleIndex]
|
||||
} else if ( t instanceof ErrorNode) {
|
||||
return t.toString()
|
||||
} else if(t instanceof TerminalNode) {
|
||||
if(t.symbol!==nil) {
|
||||
if(t.symbol!=nil) {
|
||||
return t.symbol.text
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ Trees.getChildren = function(t) {
|
|||
Trees.getAncestors = function(t) {
|
||||
var ancestors = []
|
||||
t = t.getParent()
|
||||
while(t!==nil) {
|
||||
while(t!=nil) {
|
||||
ancestors = [t].concat(ancestors)
|
||||
t = t.getParent()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue