Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,191 changes: 1,191 additions & 0 deletions javascript/downgrades/eda7d3dc42baf69d0acb592072d7136acf61d903/old.dbscheme

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
description: Adds support for ECMAScript 2024 v Flag Intersection
compatibility: backwards
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.semmle.js.ast.regexp;

import com.semmle.js.ast.SourceLocation;
import java.util.List;

public class Intersection extends RegExpTerm {
private final List<RegExpTerm> intersections;

public Intersection(SourceLocation loc, List<RegExpTerm> intersections) {
super(loc, "Intersection");
this.intersections = intersections;
}

@Override
public void accept(Visitor v) {
v.visit(this);
}

public List<RegExpTerm> getIntersections() {
return intersections;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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.
*/
public class StringDisjunction extends RegExpTerm {
private final RegExpTerm term;

public StringDisjunction(SourceLocation loc, RegExpTerm term) {
super(loc, "StringDisjunction");
this.term = term;
}

public RegExpTerm getTerm() {
return term;
}

@Override
public void accept(Visitor v) {
v.visit(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.semmle.js.ast.regexp;

import com.semmle.js.ast.SourceLocation;
import java.util.List;

public class Subtraction extends RegExpTerm {
private final List<RegExpTerm> subtraction;

public Subtraction(SourceLocation loc, List<RegExpTerm> subtraction) {
super(loc, "Intersection");
this.subtraction = subtraction;
}

@Override
public void accept(Visitor v) {
v.visit(this);
}

public List<RegExpTerm> getSubtraction() {
return subtraction;
}
}
22 changes: 22 additions & 0 deletions javascript/extractor/src/com/semmle/js/ast/regexp/Union.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.semmle.js.ast.regexp;

import com.semmle.js.ast.SourceLocation;
import java.util.List;

public class Union extends RegExpTerm {
private final List<RegExpTerm> union;

public Union(SourceLocation loc, List<RegExpTerm> union) {
super(loc, "Union");
this.union = union;
}

@Override
public void accept(Visitor v) {
v.visit(this);
}

public List<RegExpTerm> getUnion() {
return union;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,12 @@ public interface Visitor {
public void visit(ZeroWidthNegativeLookbehind nd);

public void visit(UnicodePropertyEscape nd);

public void visit(Intersection nd);

public void visit(Subtraction nd);

public void visit(Union nd);

public void visit(StringDisjunction nd);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import com.semmle.js.ast.regexp.Group;
import com.semmle.js.ast.regexp.HexEscapeSequence;
import com.semmle.js.ast.regexp.IdentityEscape;
import com.semmle.js.ast.regexp.Intersection;
import com.semmle.js.ast.regexp.Subtraction;
import com.semmle.js.ast.regexp.Union;
import com.semmle.js.ast.regexp.Literal;
import com.semmle.js.ast.regexp.NamedBackReference;
import com.semmle.js.ast.regexp.NonWordBoundary;
Expand All @@ -33,6 +36,7 @@
import com.semmle.js.ast.regexp.RegExpTerm;
import com.semmle.js.ast.regexp.Sequence;
import com.semmle.js.ast.regexp.Star;
import com.semmle.js.ast.regexp.StringDisjunction;
import com.semmle.js.ast.regexp.UnicodeEscapeSequence;
import com.semmle.js.ast.regexp.UnicodePropertyEscape;
import com.semmle.js.ast.regexp.Visitor;
Expand Down Expand Up @@ -92,6 +96,10 @@ public RegExpExtractor(TrapWriter trapwriter, LocationManager locationManager) {
termkinds.put("ZeroWidthPositiveLookbehind", 25);
termkinds.put("ZeroWidthNegativeLookbehind", 26);
termkinds.put("UnicodePropertyEscape", 27);
termkinds.put("Intersection", 28);
termkinds.put("Subtraction", 29);
termkinds.put("Union", 30);
termkinds.put("StringDisjunction", 31); // Add StringDisjunction to the kind map
}

private static final String[] errmsgs =
Expand Down Expand Up @@ -290,6 +298,12 @@ public void visit(UnicodePropertyEscape nd) {
if (nd.hasValue()) trapwriter.addTuple("unicode_property_escapevalue", lbl, nd.getValue());
}

@Override
public void visit(StringDisjunction nd) {
Label lbl = extractTerm(nd, parent, idx);
visit(nd.getTerm(), lbl, 0);
}

@Override
public void visit(DecimalEscape nd) {
visit((Literal) nd);
Expand Down Expand Up @@ -344,6 +358,30 @@ public void visit(CharacterClassRange nd) {
visit(nd.getLeft(), lbl, 0);
visit(nd.getRight(), lbl, 1);
}

@Override
public void visit(Intersection nd) {
Label lbl = extractTerm(nd, parent, idx);
int i = 0;
for (RegExpTerm element : nd.getIntersections())
visit(element, lbl, i++);
}

@Override
public void visit(Subtraction nd) {
Label lbl = extractTerm(nd, parent, idx);
int i = 0;
for (RegExpTerm element : nd.getSubtraction())
visit(element, lbl, i++);
}

@Override
public void visit(Union nd) {
Label lbl = extractTerm(nd, parent, idx);
int i = 0;
for (RegExpTerm element : nd.getUnion())
visit(element, lbl, i++);
}
}

public void extract(String src, SourceMap sourceMap, Node parent, boolean isSpeculativeParsing) {
Expand Down
Loading