Skip to content

Commit

Permalink
[amd] [parser] refs brython-dev#188 - Accurate positioning of new lin…
Browse files Browse the repository at this point in the history
…e chars generated for encoding declaration comments
  • Loading branch information
olemis committed Feb 13, 2016
1 parent 4d23475 commit 5691a80
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions www/src/amd/brython/tkn.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
yield [PyLex.token_types.ENCODING, encoding, [0,0], [0,0], 0]
}
else {
re = /^(?:(#.*?)(\r|\n|\r\n))?(#.*coding[=:]\s*([-\w.]+).*?)(\r|\n|\r\n)?/gm
re = /^(?:(#.*?)(\r|\n|\r\n))?(#.*coding[=:]\s*([-\w.]+).*)(\r|\n|\r\n)?/gm
match = this.trymatch(re);
if (match) {
encoding = match[4];
Expand All @@ -115,14 +115,13 @@
text = match[1];
pos = [1,text.length];
yield [PyLex.token_types.COMMENT, text, [1,0], pos, 1];
yield this.newline(f, match[2], [1,text.length - 1]);
++this._row;
yield this.newline(f, match[2], [1,text.length]);
}
text = match[3];
yield [PyLex.token_types.COMMENT, text, [this._row,0],
[this._row,text.length], 1];
if (text = match[5]) {
yield this.newline(f, match[2], [0,text.length - 1]);
if (match[5]) {
yield this.newline(f, match[5], [this._row,text.length]);
}
self._lpos = re.lastIndex;
}
Expand Down

0 comments on commit 5691a80

Please sign in to comment.