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", {
prefix: true,
argument: {
type: "Literal",
- value: -value
+ value: -value,
+ raw: M.start.raw
}
};
}
return {
type: "Literal",
- value: value
+ value: value,
+ raw: M.start.raw
};
});
/* -----[ 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;
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),
});
};
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),
});
};
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()));
}
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;