diff --git a/src/parse/gast_builder.ts b/src/parse/gast_builder.ts index 909cbf6b8..9d028ab36 100644 --- a/src/parse/gast_builder.ts +++ b/src/parse/gast_builder.ts @@ -238,7 +238,7 @@ namespace chevrotain.gastBuilder { let optionRanges = createOptionRanges(text) let orRanges = createOrRanges(text) - return _.union(terminalRanges, refsRanges, atLeastOneRanges, atLeastOneSepRanges, + return [].concat(terminalRanges, refsRanges, atLeastOneRanges, atLeastOneSepRanges, manyRanges, manySepRanges, optionRanges, orRanges) } @@ -275,7 +275,7 @@ namespace chevrotain.gastBuilder { // have to split up the OR cases into separate FLAT productions // (A |BB | CDE) ==> or.def[0] --> FLAT(A) , or.def[1] --> FLAT(BB) , or.def[2] --> FLAT(CCDE) let orSubPartsRanges = createOrPartRanges(orRanges) - return _.union(orRanges, orSubPartsRanges) + return orRanges.concat(orSubPartsRanges) } let findClosingCurly:(start:number, text:string) => number = _.partial(findClosingOffset, "{", "}") @@ -292,7 +292,7 @@ namespace chevrotain.gastBuilder { orPart.range.start += currOrRangeStart orPart.range.end += currOrRangeStart }) - orPartRanges = _.union(orPartRanges, currOrParts) + orPartRanges = orPartRanges.concat(currOrParts) }) let uniqueOrPartRanges = _.uniq(orPartRanges, (prodRange:IProdRange) => { diff --git a/src/scan/lexer.ts b/src/scan/lexer.ts index cc72e2c6a..6b8349519 100644 --- a/src/scan/lexer.ts +++ b/src/scan/lexer.ts @@ -179,12 +179,14 @@ namespace chevrotain { let found = [] let identicalPatterns = utils.map(tokenClasses, (outerClass:any) => { return _.reduce(tokenClasses, (result, innerClass:any) => { - if ((outerClass.PATTERN.source === innerClass.PATTERN.source) && !utils.contains(found, innerClass) && + if ((outerClass.PATTERN.source === innerClass.PATTERN.source) && + !utils.contains(found, innerClass) && innerClass.PATTERN !== Lexer.NA) { // this avoids duplicates in the result, each class may only appear in one "set" // in essence we are creating Equivalence classes on equality relation. found.push(innerClass) - return _.union(result, [innerClass]) + result.push(innerClass) + return result } return result }, [])