Skip to content

Commit

Permalink
feat: support modifiers proposal (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxingbaoyu authored and nicolo-ribaudo committed Jan 25, 2023
1 parent 96bb99d commit be86643
Show file tree
Hide file tree
Showing 8 changed files with 619 additions and 9 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"devDependencies": {
"codecov": "^3.8.3",
"nyc": "^15.1.0",
"regjsparser": "^0.8.2",
"regjsparser": "^0.9.1",
"request": "^2.88.2"
}
}
9 changes: 8 additions & 1 deletion regjsgen.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,14 @@
}
break;
case 'ignore':
result += '?:';
if (node.modifierFlags) {
result += '?';
if(node.modifierFlags.enabling) result += node.modifierFlags.enabling;
if(node.modifierFlags.disabling) result += "-" + node.modifierFlags.disabling;
result += ':';
} else {
result += '?:';
}
break;
case 'lookahead':
result += '?=';
Expand Down
4 changes: 4 additions & 0 deletions tests/equiv.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ function astNodesAreEquivalent(a, b) {
var bNames = Object.keys(b).filter(function(name) { return name != "range" && name != "raw"; });
var aNameCount = aNames.length;

if(a.type == "quantifier" && b.type == "quantifier" && a.symbol == null && b.symbol == "+"){
b.symbol = undefined;
}

if (aNameCount == bNames.length) {
for (var i = 0; i < aNameCount; ++i) {
var name = aNames[i];
Expand Down
Loading

0 comments on commit be86643

Please sign in to comment.