1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

Hook up new token location data to parser.

This commit is contained in:
Jason Walton 2012-11-21 16:57:30 -05:00
parent 969e45a599
commit 3142b237f5
2 changed files with 7 additions and 10 deletions

View file

@ -153,14 +153,10 @@
parser.lexer = {
lex: function() {
var tag, _ref1;
_ref1 = this.tokens[this.pos++] || [''], tag = _ref1[0], this.yytext = _ref1[1], this.yylineno = _ref1[2];
this.yylloc = {
first_line: this.yylineno,
last_line: this.yylineno,
first_column: 0,
last_column: 0
};
var tag, token;
token = this.tokens[this.pos++] || [''];
tag = token[0], this.yytext = token[1], this.yylineno = token[2];
this.yylloc = token.locationData;
return tag;
},
setInput: function(tokens) {

View file

@ -120,8 +120,9 @@ lexer = new Lexer
# directly as a "Jison lexer".
parser.lexer =
lex: ->
[tag, @yytext, @yylineno] = @tokens[@pos++] or ['']
@yylloc = {first_line: @yylineno, last_line: @yylineno, first_column: 0, last_column: 0}
token = @tokens[@pos++] or ['']
[tag, @yytext, @yylineno] = token
@yylloc = token.locationData
tag
setInput: (@tokens) ->
@pos = 0