Improved documentation, removed union fram change note.

This commit is contained in:
Napalys
2025-03-11 08:27:38 +01:00
parent 9c8e0a5537
commit 08c07f815f
5 changed files with 16 additions and 6 deletions

View File

@@ -3,6 +3,10 @@ package com.semmle.js.ast.regexp;
import com.semmle.js.ast.SourceLocation;
import java.util.List;
/**
* A character class intersection in a regular expression available only with the `v` flag.
* Example: [[abc]&&[ab]&&[b]] matches character `b` only.
*/
public class CharacterClassIntersection extends RegExpTerm {
private final List<RegExpTerm> elements;

View File

@@ -3,8 +3,11 @@ package com.semmle.js.ast.regexp;
import com.semmle.js.ast.SourceLocation;
/**
* A '\q{}' escape sequence in a regular expression, which is a special extension
* to standard regular expressions.
* A quoted string escape sequence '\q{}' in a regular expression.
* This feature is a non-standard extension that requires the 'v' flag.
*
* Example: [\q{abc|def}] creates a character class that matches either the string
* "abc" or "def". Within the quoted string, only the alternation operator '|' is supported.
*/
public class CharacterClassQuotedString extends RegExpTerm {
private final RegExpTerm term;
@@ -17,7 +20,7 @@ public class CharacterClassQuotedString extends RegExpTerm {
public RegExpTerm getTerm() {
return term;
}
@Override
public void accept(Visitor v) {
v.visit(this);

View File

@@ -3,6 +3,10 @@ package com.semmle.js.ast.regexp;
import com.semmle.js.ast.SourceLocation;
import java.util.List;
/**
* A character class subtraction in a regular expression available only with the `v` flag.
* Example: [[abc]--[a]--[b]] matches character `c` only.
*/
public class CharacterClassSubtraction extends RegExpTerm {
private final List<RegExpTerm> elements;

View File

@@ -297,8 +297,8 @@ public class RegExpParser {
disjuncts.add(this.parseAlternativeInsideQuotedString());
}
if (disjuncts.size() == 1) return disjuncts.get(0);
return this.finishTerm(new Disjunction(loc, disjuncts));
}
return this.finishTerm(new Disjunction(loc, disjuncts));
}
private RegExpTerm parseAlternativeInsideQuotedString() {
SourceLocation loc = new SourceLocation(pos());

View File

@@ -4,5 +4,4 @@ category: feature
* Added ability to parse new ECMA 2024 `v` flag operations:
- Intersection `&&`
- Subtraction `--`
- Union
- `\q` quoted string