check for valid start state in tokenizer
This commit is contained in:
parent
d03e5d1120
commit
1704cbdcc2
1 changed files with 5 additions and 1 deletions
|
|
@ -95,7 +95,7 @@ var Tokenizer = function(rules) {
|
||||||
if (matchcount > 1) {
|
if (matchcount > 1) {
|
||||||
if (/\\\d/.test(rule.regex)) {
|
if (/\\\d/.test(rule.regex)) {
|
||||||
// Replace any backreferences and offset appropriately.
|
// Replace any backreferences and offset appropriately.
|
||||||
adjustedregex = rule.regex.replace(/\\([0-9]+)/g, function (match, digit) {
|
adjustedregex = rule.regex.replace(/\\([0-9]+)/g, function(match, digit) {
|
||||||
return "\\" + (parseInt(digit, 10) + matchTotal + 1);
|
return "\\" + (parseInt(digit, 10) + matchTotal + 1);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -222,6 +222,10 @@ var Tokenizer = function(rules) {
|
||||||
|
|
||||||
var currentState = startState || "start";
|
var currentState = startState || "start";
|
||||||
var state = this.states[currentState];
|
var state = this.states[currentState];
|
||||||
|
if (!state) {
|
||||||
|
currentState = "start";
|
||||||
|
state = this.states[currentState];
|
||||||
|
}
|
||||||
var mapping = this.matchMappings[currentState];
|
var mapping = this.matchMappings[currentState];
|
||||||
var re = this.regExps[currentState];
|
var re = this.regExps[currentState];
|
||||||
re.lastIndex = 0;
|
re.lastIndex = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue