Skip to content

Commit

Permalink
Don't add flag y if allowUnhandledGAnchors and has alts with and with…
Browse files Browse the repository at this point in the history
…out leading \G
  • Loading branch information
slevithan committed Dec 19, 2024
1 parent 3ee05b2 commit a3f62d3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,14 @@ const FirstPassVisitor = {
hasAltWithoutLeadG = true;
}
}
if (hasAltWithLeadG && hasAltWithoutLeadG && !allowUnhandledGAnchors) {
throw new Error(r`Uses "\G" in a way that's unsupported`);
if (hasAltWithLeadG) {
if (!hasAltWithoutLeadG) {
// Supported `\G` nodes will be removed (and add flag y) when traversed; others will error
leadingGs.forEach(g => supportedGNodes.add(g));
} else if (!allowUnhandledGAnchors) {
throw new Error(r`Uses "\G" in a way that's unsupported`);
}
}
// Supported `\G` nodes will be removed when traversed; others will error
leadingGs.forEach(g => supportedGNodes.add(g))
},

Quantifier({node}) {
Expand Down

0 comments on commit a3f62d3

Please sign in to comment.