File tree Expand file tree Collapse file tree 3 files changed +373
-88
lines changed
Expand file tree Collapse file tree 3 files changed +373
-88
lines changed Original file line number Diff line number Diff line change @@ -226,18 +226,18 @@ private <T extends RegExpTerm> T finishTerm(T term) {
226226 private RegExpTerm parseDisjunction () {
227227 SourceLocation loc = new SourceLocation (pos ());
228228 List <RegExpTerm > disjuncts = new ArrayList <>();
229- disjuncts .add (this .parseIntersection ());
229+ disjuncts .add (this .parseAlternative ());
230230 while (this .match ("|" )) {
231- disjuncts .add (this .parseIntersection ());
231+ disjuncts .add (this .parseAlternative ());
232232 }
233233 if (disjuncts .size () == 1 ) return disjuncts .get (0 );
234234 return this .finishTerm (new Disjunction (loc , disjuncts ));
235- }
235+ }
236236
237237 private RegExpTerm parseAlternative () {
238238 SourceLocation loc = new SourceLocation (pos ());
239239 List <RegExpTerm > elements = new ArrayList <>();
240- while (!this .lookahead (null , "|" , "&&" , " )" )) elements .add (this .parseTerm ());
240+ while (!this .lookahead (null , "|" , ")" )) elements .add (this .parseTerm ());
241241 if (elements .size () == 1 ) return elements .get (0 );
242242 return this .finishTerm (new Sequence (loc , elements ));
243243 }
Original file line number Diff line number Diff line change 1- / [ [ a b c ] & & [ b c d ] ] / v
1+ / [ [ a b c ] & & [ b c d ] ] / v; // Valid use of intersection operator, matches b or c
2+ / a b c & & b c d / v; //Valid regex, but no intersection operation: Matches the literal string "abc&&bcd"
3+ / [ a b c ] & & [ b c d ] / v; // Valid regex, but incorrect intersection operation:
4+ // - Matches a single character from [abc]
5+ // - Then the literal "&&"
6+ // - Then a single character from [bcd]
7+ / [ a b c & & b c d ] / v; // Compilation error due to invalid use of intersection operation
You can’t perform that action at this time.
0 commit comments