Skip to content

Commit 788b95b

Browse files
committed
test2
1 parent 17b7d8f commit 788b95b

File tree

17 files changed

+579
-326
lines changed

17 files changed

+579
-326
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.semmle.js.ast.regexp;
2+
3+
import com.semmle.js.ast.SourceLocation;
4+
5+
/**
6+
* A '\q{}' escape sequence in a regular expression, which is a special extension
7+
* to standard regular expressions.
8+
*/
9+
public class StringDisjunction extends RegExpTerm {
10+
private final RegExpTerm term;
11+
12+
public StringDisjunction(SourceLocation loc, RegExpTerm term) {
13+
super(loc, "StringDisjunction");
14+
this.term = term;
15+
}
16+
17+
public RegExpTerm getTerm() {
18+
return term;
19+
}
20+
21+
@Override
22+
public void accept(Visitor v) {
23+
v.visit(this);
24+
}
25+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.semmle.js.ast.regexp;
2+
3+
import com.semmle.js.ast.SourceLocation;
4+
import java.util.List;
5+
6+
public class Subtraction extends RegExpTerm {
7+
private final List<RegExpTerm> subtraction;
8+
9+
public Subtraction(SourceLocation loc, List<RegExpTerm> subtraction) {
10+
super(loc, "Intersection");
11+
this.subtraction = subtraction;
12+
}
13+
14+
@Override
15+
public void accept(Visitor v) {
16+
v.visit(this);
17+
}
18+
19+
public List<RegExpTerm> getSubtraction() {
20+
return subtraction;
21+
}
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.semmle.js.ast.regexp;
2+
3+
import com.semmle.js.ast.SourceLocation;
4+
import java.util.List;
5+
6+
public class Union extends RegExpTerm {
7+
private final List<RegExpTerm> union;
8+
9+
public Union(SourceLocation loc, List<RegExpTerm> union) {
10+
super(loc, "Union");
11+
this.union = union;
12+
}
13+
14+
@Override
15+
public void accept(Visitor v) {
16+
v.visit(this);
17+
}
18+
19+
public List<RegExpTerm> getUnion() {
20+
return union;
21+
}
22+
}

javascript/extractor/src/com/semmle/js/ast/regexp/Visitor.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,10 @@ public interface Visitor {
6363
public void visit(UnicodePropertyEscape nd);
6464

6565
public void visit(Intersection nd);
66+
67+
public void visit(Subtraction nd);
68+
69+
public void visit(Union nd);
70+
71+
public void visit(StringDisjunction nd);
6672
}

javascript/extractor/src/com/semmle/js/extractor/RegExpExtractor.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import com.semmle.js.ast.regexp.HexEscapeSequence;
2424
import com.semmle.js.ast.regexp.IdentityEscape;
2525
import com.semmle.js.ast.regexp.Intersection;
26+
import com.semmle.js.ast.regexp.Subtraction;
27+
import com.semmle.js.ast.regexp.Union;
2628
import com.semmle.js.ast.regexp.Literal;
2729
import com.semmle.js.ast.regexp.NamedBackReference;
2830
import com.semmle.js.ast.regexp.NonWordBoundary;
@@ -34,6 +36,7 @@
3436
import com.semmle.js.ast.regexp.RegExpTerm;
3537
import com.semmle.js.ast.regexp.Sequence;
3638
import com.semmle.js.ast.regexp.Star;
39+
import com.semmle.js.ast.regexp.StringDisjunction;
3740
import com.semmle.js.ast.regexp.UnicodeEscapeSequence;
3841
import com.semmle.js.ast.regexp.UnicodePropertyEscape;
3942
import com.semmle.js.ast.regexp.Visitor;
@@ -94,6 +97,9 @@ public RegExpExtractor(TrapWriter trapwriter, LocationManager locationManager) {
9497
termkinds.put("ZeroWidthNegativeLookbehind", 26);
9598
termkinds.put("UnicodePropertyEscape", 27);
9699
termkinds.put("Intersection", 28);
100+
termkinds.put("Subtraction", 29);
101+
termkinds.put("Union", 30);
102+
termkinds.put("StringDisjunction", 31); // Add StringDisjunction to the kind map
97103
}
98104

99105
private static final String[] errmsgs =
@@ -292,6 +298,12 @@ public void visit(UnicodePropertyEscape nd) {
292298
if (nd.hasValue()) trapwriter.addTuple("unicode_property_escapevalue", lbl, nd.getValue());
293299
}
294300

301+
@Override
302+
public void visit(StringDisjunction nd) {
303+
Label lbl = extractTerm(nd, parent, idx);
304+
visit(nd.getTerm(), lbl, 0);
305+
}
306+
295307
@Override
296308
public void visit(DecimalEscape nd) {
297309
visit((Literal) nd);
@@ -354,6 +366,22 @@ public void visit(Intersection nd) {
354366
for (RegExpTerm element : nd.getIntersections())
355367
visit(element, lbl, i++);
356368
}
369+
370+
@Override
371+
public void visit(Subtraction nd) {
372+
Label lbl = extractTerm(nd, parent, idx);
373+
int i = 0;
374+
for (RegExpTerm element : nd.getSubtraction())
375+
visit(element, lbl, i++);
376+
}
377+
378+
@Override
379+
public void visit(Union nd) {
380+
Label lbl = extractTerm(nd, parent, idx);
381+
int i = 0;
382+
for (RegExpTerm element : nd.getUnion())
383+
visit(element, lbl, i++);
384+
}
357385
}
358386

359387
public void extract(String src, SourceMap sourceMap, Node parent, boolean isSpeculativeParsing) {

0 commit comments

Comments
 (0)