forked from jasder/antlr
Fix issue printing tokens from IntervalSet
This commit is contained in:
parent
fa46c498af
commit
ddd706baf2
|
@ -1 +1 @@
|
|||
1 + 2 + 32 + (1 + 2) = 3 + 5
|
||||
fail 1 + 2 + 32 + (1 + 2) = 3 + 5 ok-fkj
|
||||
|
|
|
@ -347,7 +347,6 @@ func (this *DefaultErrorStrategy) ReportUnwantedToken(recognizer Parser) {
|
|||
var expecting = this.getExpectedTokens(recognizer)
|
||||
var msg = "extraneous input " + tokenName + " expecting " +
|
||||
expecting.StringVerbose(recognizer.GetLiteralNames(), recognizer.GetSymbolicNames(), false)
|
||||
panic(msg)
|
||||
recognizer.NotifyErrorListeners(msg, t, nil)
|
||||
}
|
||||
|
||||
|
|
|
@ -282,8 +282,7 @@ func (is *IntervalSet) toIndexString() string {
|
|||
|
||||
func (is *IntervalSet) toTokenString(literalNames []string, symbolicNames []string) string {
|
||||
var names = make([]string, 0)
|
||||
for i := 0; i < len(is.intervals); i++ {
|
||||
var v = is.intervals[i]
|
||||
for _,v := range is.intervals {
|
||||
for j := v.start; j < v.stop; j++ {
|
||||
names = append(names, is.elementName(literalNames, symbolicNames, j))
|
||||
}
|
||||
|
@ -301,7 +300,7 @@ func (i *IntervalSet) elementName(literalNames []string, symbolicNames []string,
|
|||
} else if a == TokenEpsilon {
|
||||
return "<EPSILON>"
|
||||
} else {
|
||||
if literalNames[a] != "" {
|
||||
if a < len(literalNames) && literalNames[a] != "" {
|
||||
return literalNames[a]
|
||||
} else {
|
||||
return symbolicNames[a]
|
||||
|
|
|
@ -69,7 +69,7 @@ func (this *BaseRecognizer) GetTokenNames() []string {
|
|||
}
|
||||
|
||||
func (this *BaseRecognizer) GetSymbolicNames() []string {
|
||||
return this.LiteralNames
|
||||
return this.SymbolicNames
|
||||
}
|
||||
|
||||
func (this *BaseRecognizer) GetLiteralNames() []string {
|
||||
|
|
|
@ -274,6 +274,11 @@ IntervalSet.prototype.toIndexString = function() {
|
|||
|
||||
|
||||
IntervalSet.prototype.toTokenString = function(literalNames, symbolicNames) {
|
||||
console.log(symbolicNames)
|
||||
console.log(literalNames)
|
||||
console.log(symbolicNames.length)
|
||||
console.log(literalNames.length)
|
||||
console.log(this.toString())
|
||||
var names = [];
|
||||
for (var i = 0; i < this.intervals.length; i++) {
|
||||
var v = this.intervals[i];
|
||||
|
|
|
@ -1 +1 @@
|
|||
1 + 2 + 32 + (1 + 2) = 3 + 5
|
||||
fail 1 + 2 + 32 + (1 + 2) = 3 + 5 ok-fkj
|
Loading…
Reference in New Issue