I loathe storing the product.

This commit is contained in:
Elf M. Sternberg 2012-05-04 13:28:12 -07:00
parent c6aa50fc11
commit b43f34afa8
1 changed files with 25 additions and 29 deletions

View File

@ -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 {