Permalink
Browse files

Merge pull request #248 from WolfgangKluge/endpos-in-tokens

Keep the end position of each token
  • Loading branch information...
2 parents 9d4d768 + f74e6bc commit 00a7bebe5c076b9176bad6f0417b9635383368a7 @mishoo committed Dec 2, 2011
Showing with 9 additions and 9 deletions.
  1. +9 −9 lib/parse-js.js
View
@@ -326,12 +326,13 @@ function tokenizer($TEXT) {
(type == "keyword" && HOP(KEYWORDS_BEFORE_EXPRESSION, value)) ||
(type == "punc" && HOP(PUNC_BEFORE_EXPRESSION, value)));
var ret = {
- type : type,
- value : value,
- line : S.tokline,
- col : S.tokcol,
- pos : S.tokpos,
- nlb : S.newline_before
+ type : type,
+ value : value,
+ line : S.tokline,
+ col : S.tokcol,
+ pos : S.tokpos,
+ endpos : S.pos,
+ nlb : S.newline_before
};
if (!is_comment) {
ret.comments_before = S.comments_before;
@@ -468,8 +469,7 @@ function tokenizer($TEXT) {
next();
return with_eof_error("Unterminated multiline comment", function(){
var i = find("*/", true),
- text = S.text.substring(S.pos, i),
- tok = token("comment2", text, true);
+ text = S.text.substring(S.pos, i);
S.pos = i + 2;
S.line += text.split("\n").length - 1;
S.newline_before = text.indexOf("\n") >= 0;
@@ -481,7 +481,7 @@ function tokenizer($TEXT) {
warn("*** UglifyJS DISCARDS ALL COMMENTS. This means your code might no longer work properly in Internet Explorer.");
}
- return tok;
+ return token("comment2", text, true);
});
};

0 comments on commit 00a7beb

Please sign in to comment.