Trying a different check for regex productions.

This commit is contained in:
Elf M. Sternberg 2012-05-04 14:01:52 -07:00
parent 6c58f8b8a3
commit 26e7b3936e
2 changed files with 4 additions and 4 deletions

View File

@ -111,10 +111,10 @@
return this.fail();
}
this.input = this.input.substr(((probe[1] != null) && putback ? probe[1].length : probe[0].length));
if (probe[1] != null) {
return probe[1];
} else {
if (probe[1] === undefined) {
return probe[0];
} else {
return probe[1];
}
};

View File

@ -79,7 +79,7 @@ exports.ReParse = class ReParse
probe = @input.match pattern
return @fail() unless probe
@input = @input.substr (if probe[1]? and putback then probe[1].length else probe[0].length)
if probe[1]? then probe[1] else probe[0]
if probe[1] is `undefined` then probe[0] else probe[1]
# Attempts to apply the method and produce a value. If it fails,
# restores the input to the previous state.