Skip to content

Commit

Permalink
Fix another bug in normalization exposed by the previous bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnh committed Aug 29, 2018
1 parent fc0f3c6 commit 248e6c7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ function noSkipAfter(node) {
let normalizeExpr = exports.normalizeExpr = function(expr, ruleName, superGrammar, skip, prefix) {
if (expr.type == "StringMatch" && expr.value.length > 1 && expr.value.indexOf("\n") > -1) {
let exprs = []
expr.value.split(/(?=\n)/).forEach(part => {
exprs.push(build("StringMatch", expr, {value: "\n"}))
if (part.length > 1) exprs.push(build("StringMatch", expr, {value: part.slice(1)}))
expr.value.split(/\n/).forEach((part, i) => {
if (i) exprs.push(build("StringMatch", expr, {value: "\n"}))
if (part.length) exprs.push(build("StringMatch", expr, {value: part}))
})
return build("SequenceMatch", expr, {exprs})
} else if (expr.type == "RuleIdentifier") {
Expand Down

0 comments on commit 248e6c7

Please sign in to comment.