diff options
-rw-r--r-- | lib/ast.js | 2 | ||||
-rw-r--r-- | lib/mozilla-ast.js | 18 | ||||
-rw-r--r-- | lib/output.js | 4 | ||||
-rw-r--r-- | lib/parse.js | 2 |
4 files changed, 18 insertions, 8 deletions
@@ -85,7 +85,7 @@ function DEFNODE(type, props, methods, base) { return ctor; }; -var AST_Token = DEFNODE("Token", "type value line col pos endline endcol endpos nlb comments_before file literal", { +var AST_Token = DEFNODE("Token", "type value line col pos endline endcol endpos nlb comments_before file raw", { }, null); var AST_Node = DEFNODE("Node", "start end", { diff --git a/lib/mozilla-ast.js b/lib/mozilla-ast.js index 2bb469fb..c1b2b683 100644 --- a/lib/mozilla-ast.js +++ b/lib/mozilla-ast.js @@ -363,13 +363,15 @@ prefix: true, argument: { type: "Literal", - value: -value + value: -value, + raw: M.start.raw } }; } return { type: "Literal", - value: value + value: value, + raw: M.start.raw }; }); @@ -389,6 +391,12 @@ /* -----[ tools ]----- */ + function raw_token(moznode) { + if (moznode.type == "Literal") { + return moznode.raw != null ? moznode.raw : moznode.value + ""; + } + } + function my_start_token(moznode) { var loc = moznode.loc, start = loc && loc.start; var range = moznode.range; @@ -399,7 +407,8 @@ pos : range ? range[0] : moznode.start, endline : start && start.line, endcol : start && start.column, - endpos : range ? range[0] : moznode.start + endpos : range ? range[0] : moznode.start, + raw : raw_token(moznode), }); }; @@ -413,7 +422,8 @@ pos : range ? range[1] : moznode.end, endline : end && end.line, endcol : end && end.column, - endpos : range ? range[1] : moznode.end + endpos : range ? range[1] : moznode.end, + raw : raw_token(moznode), }); }; diff --git a/lib/output.js b/lib/output.js index 9dadf0e5..f10c918a 100644 --- a/lib/output.js +++ b/lib/output.js @@ -1178,8 +1178,8 @@ function OutputStream(options) { output.print_string(self.getValue(), self.quote); }); DEFPRINT(AST_Number, function(self, output){ - if (use_asm) { - output.print(self.start.literal); + if (use_asm && self.start.raw != null) { + output.print(self.start.raw); } else { output.print(make_num(self.getValue())); } diff --git a/lib/parse.js b/lib/parse.js index 901d10a3..de27d987 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -286,7 +286,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) { file : filename }; if (/^(?:num|string|regexp)$/i.test(type)) { - ret.literal = $TEXT.substring(ret.pos, ret.endpos); + ret.raw = $TEXT.substring(ret.pos, ret.endpos); } if (!is_comment) { ret.comments_before = S.comments_before; |