tweak to parser.lexer

This commit is contained in:
Jeremy Ashkenas 2010-11-02 00:05:06 -04:00
parent 987aaa0e19
commit a257f5993a
2 changed files with 11 additions and 17 deletions

View File

@ -55,15 +55,12 @@
lexer = new Lexer;
parser.lexer = {
lex: function() {
var token;
token = this.tokens[this.pos] || [""];
this.pos += 1;
this.yylineno = token[2];
this.yytext = token[1];
return token[0];
var tag, _ref;
_ref = this.tokens[this.pos++] || [''], tag = _ref[0], this.yytext = _ref[1], this.yylineno = _ref[2];
return tag;
},
setInput: function(tokens) {
this.tokens = tokens;
setInput: function(_arg) {
this.tokens = _arg;
return this.pos = 0;
},
upcomingInput: function() {

View File

@ -76,14 +76,11 @@ lexer = new Lexer
# directly as a "Jison lexer".
parser.lexer =
lex: ->
token = @tokens[@pos] or [""]
@pos += 1
this.yylineno = token[2]
this.yytext = token[1]
token[0]
setInput: (tokens) ->
@tokens = tokens
@pos = 0
upcomingInput: -> ""
[tag, @yytext, @yylineno] = @tokens[@pos++] or ['']
tag
setInput: (@tokens) ->
@pos = 0
upcomingInput: ->
""
parser.yy = require './nodes'