Skip to content

Commit

Permalink
Update lib/jison/lexer.js
Browse files Browse the repository at this point in the history
Odd case where oldLines[?].length didn't exist, so return a length of 0 if there is no length.
  • Loading branch information
robertleeplummerjr committed Sep 3, 2012
1 parent bdc9422 commit 3d1a0b7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/jison/lexer.js
Expand Up @@ -193,12 +193,13 @@ RegExpLexer.prototype = {


if (lines.length-1) this.yylineno -= lines.length-1; if (lines.length-1) this.yylineno -= lines.length-1;
var r = this.yylloc.range; var r = this.yylloc.range;
var oldLinesLength = (oldLines[oldLines.length - lines.length] ? oldLines[oldLines.length - lines.length].length : 0);


this.yylloc = {first_line: this.yylloc.first_line, this.yylloc = {first_line: this.yylloc.first_line,
last_line: this.yylineno+1, last_line: this.yylineno+1,
first_column: this.yylloc.first_column, first_column: this.yylloc.first_column,
last_column: lines ? last_column: lines ?
(lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length: (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLinesLength - lines[0].length:
this.yylloc.first_column - len this.yylloc.first_column - len
}; };


Expand Down

1 comment on commit 3d1a0b7

@zaach
Copy link

@zaach zaach commented on 3d1a0b7 Sep 10, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have the case for when this causes an error? I'd like to add a test case for this before fixing.

Please sign in to comment.