aboutsummaryrefslogtreecommitdiff
path: root/lib/mozilla-ast.js
diff options
context:
space:
mode:
authorkzc <zaxxon2011@gmail.com>2015-11-02 12:24:09 -0500
committerkzc <zaxxon2011@gmail.com>2015-11-02 12:24:09 -0500
commit94c4daaf9ea67875ab1b720d1d7bceef7c690552 (patch)
tree05a15046ebf0196ece423dd052a336b199da66fe /lib/mozilla-ast.js
parent37ee9de9021f1f34ed7d2f453f58348f2e74764f (diff)
downloadtracifyjs-94c4daaf9ea67875ab1b720d1d7bceef7c690552.tar.gz
tracifyjs-94c4daaf9ea67875ab1b720d1d7bceef7c690552.zip
Have mozilla AST RegExpLiteral parser use regex.pattern and regex.flags rather than non-standard `raw` property.
Diffstat (limited to 'lib/mozilla-ast.js')
-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",