From 3142b237f54f89359a9a0113cc8a6d72244a7e4e Mon Sep 17 00:00:00 2001 From: Jason Walton Date: Wed, 21 Nov 2012 16:57:30 -0500 Subject: [PATCH] Hook up new token location data to parser. --- lib/coffee-script/coffee-script.js | 12 ++++-------- src/coffee-script.coffee | 5 +++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/coffee-script/coffee-script.js b/lib/coffee-script/coffee-script.js index 9b915d58..a76d5b8e 100644 --- a/lib/coffee-script/coffee-script.js +++ b/lib/coffee-script/coffee-script.js @@ -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) { diff --git a/src/coffee-script.coffee b/src/coffee-script.coffee index 6eae6286..6a3a2582 100644 --- a/src/coffee-script.coffee +++ b/src/coffee-script.coffee @@ -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