Fixed to allow tokenizing of an empty line. eg. a rule with a regex of ^$
This commit is contained in:
parent
a9bbd7995a
commit
ae4b171065
1 changed files with 5 additions and 4 deletions
|
|
@ -74,11 +74,8 @@ 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"); }
|
|
||||||
lastIndex = re.lastIndex;
|
|
||||||
|
|
||||||
for ( var i = 0; i < state.length; i++) {
|
for ( var i = 0; i < state.length; i++) {
|
||||||
if (match[i + 1]) {
|
if (match[i + 1] !== undefined) {
|
||||||
if (typeof state[i].token == "function") {
|
if (typeof state[i].token == "function") {
|
||||||
type = state[i].token(match[0]);
|
type = state[i].token(match[0]);
|
||||||
}
|
}
|
||||||
|
|
@ -110,6 +107,10 @@ var Tokenizer = function(rules) {
|
||||||
} else {
|
} else {
|
||||||
token.value += value;
|
token.value += value;
|
||||||
}
|
}
|
||||||
|
if (lastIndex == line.length) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
lastIndex = re.lastIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (token.type) {
|
if (token.type) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue