Skip to content

Commit a79e5ed

Browse files
author
Ioan CHIRIAC
committed
fix glayzzle#58 - lexer unput after reaching end of stream
1 parent be94293 commit a79e5ed

File tree

5 files changed

+140
-123
lines changed

5 files changed

+140
-123
lines changed

dist/php-parser.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3269,6 +3269,9 @@ lexer.prototype.lex = function() {
32693269
this.yylloc.prev_line = this.yylloc.first_line;
32703270
this.yylloc.prev_column = this.yylloc.first_column;
32713271
}
3272+
/*else if (this.yylloc.prev_offset === this.offset && this.offset !== this.size) {
3273+
throw new Error('Infinite loop @ ' + this.offset + ' / ' + this.size);
3274+
}*/
32723275
return token;
32733276
};
32743277

@@ -3332,11 +3335,13 @@ lexer.prototype.next = function () {
33323335
} else {
33333336
tName = '"'+tName+'"';
33343337
}
3335-
console.log(
3336-
tName,
3337-
'from ' + this.yylloc.first_line + ',' + this.yylloc.first_column,
3338-
' - to ' + this.yylloc.last_line + ',' + this.yylloc.last_column
3338+
var e = new Error(
3339+
tName +
3340+
'\tfrom ' + this.yylloc.first_line + ',' + this.yylloc.first_column +
3341+
'\t - to ' + this.yylloc.last_line + ',' + this.yylloc.last_column +
3342+
'\t"'+this.yytext+'"'
33393343
);
3344+
console.log(e.stack);
33403345
}
33413346
return token;
33423347
};
@@ -4228,7 +4233,7 @@ module.exports = {
42284233
return this.ST_DOUBLE_QUOTES();
42294234
} else if (ch === '\'') {
42304235
return this.T_CONSTANT_ENCAPSED_STRING();
4231-
} else {
4236+
} else if (ch) {
42324237
this.unput(1);
42334238
}
42344239
}

0 commit comments

Comments
 (0)