fix tokenizer check

This commit is contained in:
Fabian Jakobs 2011-02-08 12:32:47 +01:00
commit 554dafd1bf

View file

@ -74,6 +74,10 @@ var Tokenizer = function(rules) {
var type = "text"; var type = "text";
var value = match[0]; var value = match[0];
if (re.lastIndex == lastIndex) {
throw new Error("tokenizer error before line: '" + line + "'");
}
for ( var i = 0; i < state.length; i++) { for ( var i = 0; i < state.length; i++) {
if (match[i + 1] !== undefined) { if (match[i + 1] !== undefined) {
if (typeof state[i].token == "function") { if (typeof state[i].token == "function") {
@ -110,9 +114,7 @@ var Tokenizer = function(rules) {
if (lastIndex == line.length) { if (lastIndex == line.length) {
break; break;
} else if (re.lastIndex == lastIndex) { }
throw new Error("tokenizer error");
}
lastIndex = re.lastIndex; lastIndex = re.lastIndex;
}; };