@@ -31,36 +31,39 @@ predicate matchesString(Expr e, string s) {
3131 */
3232language [ monotonicAggregates]
3333predicate regExpMatchesString ( RegExpTerm t , string s ) {
34- // constants match themselves
35- s = t .( RegExpConstant ) .getValue ( )
36- or
37- // assertions match the empty string
34+ t .isPartOfRegExpLiteral ( ) and
3835 (
39- t instanceof RegExpCaret or
40- t instanceof RegExpDollar or
41- t instanceof RegExpWordBoundary or
42- t instanceof RegExpNonWordBoundary or
43- t instanceof RegExpLookahead or
44- t instanceof RegExpLookbehind
45- ) and
46- s = ""
47- or
48- // groups match their content
49- regExpMatchesString ( t .( RegExpGroup ) .getAChild ( ) , s )
50- or
51- // single-character classes match that character
52- exists ( RegExpCharacterClass recc | recc = t and not recc .isInverted ( ) |
53- recc .getNumChild ( ) = 1 and
54- regExpMatchesString ( recc .getChild ( 0 ) , s )
55- )
56- or
57- // sequences match the concatenation of their elements
58- exists ( RegExpSequence seq | seq = t |
59- s = concat ( int i , RegExpTerm child |
60- child = seq .getChild ( i )
61- |
62- any ( string subs | regExpMatchesString ( child , subs ) ) order by i
63- )
36+ // constants match themselves
37+ s = t .( RegExpConstant ) .getValue ( )
38+ or
39+ // assertions match the empty string
40+ (
41+ t instanceof RegExpCaret or
42+ t instanceof RegExpDollar or
43+ t instanceof RegExpWordBoundary or
44+ t instanceof RegExpNonWordBoundary or
45+ t instanceof RegExpLookahead or
46+ t instanceof RegExpLookbehind
47+ ) and
48+ s = ""
49+ or
50+ // groups match their content
51+ regExpMatchesString ( t .( RegExpGroup ) .getAChild ( ) , s )
52+ or
53+ // single-character classes match that character
54+ exists ( RegExpCharacterClass recc | recc = t and not recc .isInverted ( ) |
55+ recc .getNumChild ( ) = 1 and
56+ regExpMatchesString ( recc .getChild ( 0 ) , s )
57+ )
58+ or
59+ // sequences match the concatenation of their elements
60+ exists ( RegExpSequence seq | seq = t |
61+ s = concat ( int i , RegExpTerm child |
62+ child = seq .getChild ( i )
63+ |
64+ any ( string subs | regExpMatchesString ( child , subs ) ) order by i
65+ )
66+ )
6467 )
6568}
6669
0 commit comments