JavaScript: Distinguish {lo} and {lo,} in the regular expression parser.

This commit is contained in:
Max Schaefer
2020-02-14 14:08:31 +00:00
parent 9e3ed214d0
commit 4346691cdc
7 changed files with 45 additions and 6 deletions

View File

@@ -37,7 +37,7 @@ public class Main {
* A version identifier that should be updated every time the extractor changes in such a way that
* it may produce different tuples for the same file under the same {@link ExtractorConfig}.
*/
public static final String EXTRACTOR_VERSION = "2020-02-05";
public static final String EXTRACTOR_VERSION = "2020-02-14";
public static final Pattern NEWLINE = Pattern.compile("\n");

View File

@@ -281,8 +281,19 @@ public class RegExpParser {
if (this.match("+")) return this.finishTerm(new Plus(loc, atom, !this.match("?")));
if (this.match("?")) return this.finishTerm(new Opt(loc, atom, !this.match("?")));
if (this.match("{")) {
Double lo = toNumber(this.readDigits(false)), hi = null;
if (this.match(",") && !this.lookahead("}")) hi = toNumber(this.readDigits(false));
Double lo = toNumber(this.readDigits(false)), hi;
if (this.match(",")) {
if (!this.lookahead("}")) {
// atom{lo, hi}
hi = toNumber(this.readDigits(false));
} else {
// atom{lo,}
hi = null;
}
} else {
// atom{lo}
hi = lo;
}
this.expectRBrace();
return this.finishTerm(new Range(loc, atom, !this.match("?"), lo, hi));
}