diff --git a/lib/reparse.js b/lib/reparse.js index 423e5a7..55e8f27 100644 --- a/lib/reparse.js +++ b/lib/reparse.js @@ -38,14 +38,14 @@ this.choice = __bind(this.choice, this); - this.match = __bind(this.match, this); - this.between = __bind(this.between, this); this.option = __bind(this.option, this); this.maybe = __bind(this.maybe, this); + this.match = __bind(this.match, this); + this.start = __bind(this.start, this); this.produce = __bind(this.produce, this); @@ -101,6 +101,20 @@ throw new Error("Could not parse '" + this.input + "'."); }; + ReParse.prototype.match = function(pattern) { + var probe; + probe = this.input.match(pattern); + if (!probe) { + return this.fail(); + } + this.input = this.input.substr(probe[0].length); + if (probe[1] === undefined) { + return probe[0]; + } else { + return probe[1]; + } + }; + ReParse.prototype.maybe = function(method) { var input; input = this.input; @@ -142,20 +156,6 @@ return this.fail(input); }; - ReParse.prototype.match = function(pattern) { - var probe; - probe = this.input.match(pattern); - if (!probe) { - return this.fail(); - } - this.input = this.input.substr(probe[0].length); - if (probe[1] === undefined) { - return probe[0]; - } else { - return probe[1]; - } - }; - ReParse.prototype.choice = function() { var arg, input, _i, _len; input = this.input; @@ -233,21 +233,17 @@ min = null; } input = this.input; - result = (function() { - var _results; - _results = []; - while (!this.eof()) { - try { - this.maybe(method); - } catch (err) { - if (err !== this.fail) { - throw err; - } + result = []; + while (!this.eof()) { + try { + result.push(this.maybe(method)); + } catch (err) { + if (err !== this.fail) { + throw err; } - break; } - return _results; - }).call(this); + break; + } if (min && (result.length < min)) { return this.fail(input); } else {