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.choice = __bind(this.choice, this);
this.match = __bind(this.match, this);
this.between = __bind(this.between, this); this.between = __bind(this.between, this);
this.option = __bind(this.option, this); this.option = __bind(this.option, this);
this.maybe = __bind(this.maybe, this); this.maybe = __bind(this.maybe, this);
this.match = __bind(this.match, this);
this.start = __bind(this.start, this); this.start = __bind(this.start, this);
this.produce = __bind(this.produce, this); this.produce = __bind(this.produce, this);
@ -101,6 +101,20 @@
throw new Error("Could not parse '" + this.input + "'."); 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) { ReParse.prototype.maybe = function(method) {
var input; var input;
input = this.input; input = this.input;
@ -142,20 +156,6 @@
return this.fail(input); 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() { ReParse.prototype.choice = function() {
var arg, input, _i, _len; var arg, input, _i, _len;
input = this.input; input = this.input;
@ -233,12 +233,10 @@
min = null; min = null;
} }
input = this.input; input = this.input;
result = (function() { result = [];
var _results;
_results = [];
while (!this.eof()) { while (!this.eof()) {
try { try {
this.maybe(method); result.push(this.maybe(method));
} catch (err) { } catch (err) {
if (err !== this.fail) { if (err !== this.fail) {
throw err; throw err;
@ -246,8 +244,6 @@
} }
break; break;
} }
return _results;
}).call(this);
if (min && (result.length < min)) { if (min && (result.length < min)) {
return this.fail(input); return this.fail(input);
} else { } else {