aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/mozilla-ast.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/mozilla-ast.js b/lib/mozilla-ast.js
index 15be4581..7ce6e78d 100644
--- a/lib/mozilla-ast.js
+++ b/lib/mozilla-ast.js
@@ -146,7 +146,17 @@
case "boolean":
return new (val ? AST_True : AST_False)(args);
default:
- args.value = M.regex && M.raw ? M.raw : val;
+ var rx = M.regex;
+ if (rx && rx.pattern) {
+ // RegExpLiteral as per ESTree AST spec
+ args.value = "/" + rx.pattern + "/";
+ if (rx.flags) {
+ args.value += rx.flags;
+ }
+ } else {
+ // support legacy RegExp
+ args.value = M.regex && M.raw ? M.raw : val;
+ }
return new AST_RegExp(args);
}
},
@@ -334,7 +344,7 @@
};
});
- def_to_moz(AST_RegExp, function To_Moz_RegExp(M) {
+ def_to_moz(AST_RegExp, function To_Moz_RegExpLiteral(M) {
var value = M.value;
return {
type: "Literal",