Skip to content

Commit

Permalink
Remove usage of lodash _.union.
Browse files Browse the repository at this point in the history
relates to #68
  • Loading branch information
Shahar Soel committed Jan 6, 2016
1 parent 3818bfb commit 1fb5d51
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/parse/gast_builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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 = <any>_.partial(findClosingOffset, "{", "}")
Expand All @@ -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) => {
Expand Down
6 changes: 4 additions & 2 deletions src/scan/lexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}, [])
Expand Down

0 comments on commit 1fb5d51

Please sign in to comment.