aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/mozilla-ast.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/mozilla-ast.js b/lib/mozilla-ast.js
index ac53ca27..0a439a59 100644
--- a/lib/mozilla-ast.js
+++ b/lib/mozilla-ast.js
@@ -146,7 +146,7 @@
case "boolean":
return new (val ? AST_True : AST_False)(args);
default:
- args.value = val;
+ args.value = M.regex && M.raw ? M.raw : val;
return new AST_RegExp(args);
}
},
@@ -334,6 +334,19 @@
};
});
+ def_to_moz(AST_RegExp, function To_Moz_Literal(M) {
+ var value = M.value;
+ return {
+ type: "Literal",
+ value: value,
+ raw: value.toString(),
+ regex: {
+ pattern: value.source,
+ flags: value.toString().match(/[gimuy]*$/)[0]
+ }
+ };
+ });
+
def_to_moz(AST_Constant, function To_Moz_Literal(M) {
var value = M.value;
if (typeof value === 'number' && (value < 0 || (value === 0 && 1 / value < 0))) {