Fix inputscanner

This commit is contained in:
L. D. MacKrell 2018-07-09 11:07:53 -07:00
parent 91ffb9babd
commit c0d6989d7a
5 changed files with 9 additions and 8 deletions

View File

@ -32,7 +32,7 @@ function InputScanner(input) {
var _position = 0; var _position = 0;
this.back = function() { this.back = function() {
if (_position > 0){ if (_position > 0) {
_position -= 1; _position -= 1;
} }
}; };
@ -73,11 +73,12 @@ function InputScanner(input) {
this.test = function(pattern, index) { this.test = function(pattern, index) {
index = index || 0; index = index || 0;
pattern.lastIndex = _position + index; index += _position;
pattern.lastIndex = index;
if (index >= 0 && index < _input_length) { if (index >= 0 && index < _input_length) {
var pattern_match = pattern.exec(_input); var pattern_match = pattern.exec(_input);
return pattern_match && pattern_match.index === _position + index; return pattern_match && pattern_match.index === index;
} else { } else {
return false; return false;
} }
@ -102,4 +103,4 @@ function InputScanner(input) {
} }
module.exports.InputScanner = InputScanner; module.exports.InputScanner = InputScanner;

View File

@ -50,4 +50,4 @@ function mergeOpts(allOptions, childFieldName) {
return finalOpts; return finalOpts;
} }
module.exports.mergeOpts = mergeOpts; module.exports.mergeOpts = mergeOpts;

View File

@ -502,4 +502,4 @@ function Beautifier(source_text, options) {
}; };
} }
module.exports.Beautifier = Beautifier; module.exports.Beautifier = Beautifier;

View File

@ -1049,4 +1049,4 @@ function Beautifier(html_source, options, js_beautify, css_beautify) {
}; };
} }
module.exports.Beautifier = Beautifier; module.exports.Beautifier = Beautifier;

View File

@ -625,4 +625,4 @@ function Tokenizer(input_string, opts) {
} }
} }
module.exports.Tokenizer = Tokenizer; module.exports.Tokenizer = Tokenizer;