Fix parsing of alternations in character classes

This commit is contained in:
Joe Farebrother
2022-03-08 16:23:24 +00:00
parent 5ba6bafbef
commit 49374b877a
3 changed files with 4 additions and 1 deletions

View File

@@ -807,6 +807,7 @@ abstract class RegexString extends StringLiteral {
}
private predicate topLevel(int start, int end) {
not this.inCharSet(start) and
this.subalternation(start, end, _) and
not this.isOptionDivider(end)
}

View File

@@ -139,3 +139,5 @@ parseFailures
| Test.java:19:26:19:30 | \\077 | [RegExpConstant,RegExpEscape] |
| Test.java:19:31:19:31 | 7 | [RegExpConstant,RegExpNormalChar] |
| Test.java:19:32:19:37 | \u1337 | [RegExpConstant,RegExpNormalChar] |
| Test.java:20:10:20:12 | [\|] | [RegExpCharacterClass] |
| Test.java:20:11:20:11 | \| | [RegExpConstant,RegExpNormalChar] |

View File

@@ -17,7 +17,7 @@ class Test {
"(?i)(?=a)(?!b)(?<=c)(?<!d)",
"a||b|c(d|e|)f|g",
"\\018\\033\\0377\\0777\u1337",
"[|]"
};
void test() {