@@ -218,7 +218,7 @@ private newtype TInputSymbol =
218
218
recc instanceof RegExpCharacterClass and
219
219
not recc .( RegExpCharacterClass ) .isUniversalClass ( )
220
220
or
221
- recc instanceof RegExpCharacterClassEscape
221
+ isEscapeClass ( recc , _ )
222
222
)
223
223
} or
224
224
/** An input symbol representing all characters matched by `.`. */
@@ -340,13 +340,13 @@ private module CharacterClasses {
340
340
char <= hi
341
341
)
342
342
or
343
- exists ( RegExpCharacterClassEscape escape | escape = child |
344
- escape . getValue ( ) = escape . getValue ( ) . toLowerCase ( ) and
345
- classEscapeMatches ( escape . getValue ( ) , char )
343
+ exists ( string charClass | isEscapeClass ( child , charClass ) |
344
+ charClass . toLowerCase ( ) = charClass and
345
+ classEscapeMatches ( charClass , char )
346
346
or
347
347
char = getARelevantChar ( ) and
348
- escape . getValue ( ) = escape . getValue ( ) . toUpperCase ( ) and
349
- not classEscapeMatches ( escape . getValue ( ) . toLowerCase ( ) , char )
348
+ charClass . toUpperCase ( ) = charClass and
349
+ not classEscapeMatches ( charClass , char )
350
350
)
351
351
)
352
352
}
@@ -409,10 +409,10 @@ private module CharacterClasses {
409
409
or
410
410
child .( RegExpCharacterRange ) .isRange ( _, result )
411
411
or
412
- exists ( RegExpCharacterClassEscape escape | child = escape |
413
- result = min ( string s | classEscapeMatches ( escape . getValue ( ) .toLowerCase ( ) , s ) )
412
+ exists ( string charClass | isEscapeClass ( child , charClass ) |
413
+ result = min ( string s | classEscapeMatches ( charClass .toLowerCase ( ) , s ) )
414
414
or
415
- result = max ( string s | classEscapeMatches ( escape . getValue ( ) .toLowerCase ( ) , s ) )
415
+ result = max ( string s | classEscapeMatches ( charClass .toLowerCase ( ) , s ) )
416
416
)
417
417
)
418
418
}
@@ -466,33 +466,36 @@ private module CharacterClasses {
466
466
* An implementation of `CharacterClass` for \d, \s, and \w.
467
467
*/
468
468
private class PositiveCharacterClassEscape extends CharacterClass {
469
- RegExpCharacterClassEscape cc ;
469
+ RegExpTerm cc ;
470
+ string charClass ;
470
471
471
472
PositiveCharacterClassEscape ( ) {
472
- this = getCanonicalCharClass ( cc ) and cc .getValue ( ) = [ "d" , "s" , "w" ]
473
+ isEscapeClass ( cc , charClass ) and
474
+ this = getCanonicalCharClass ( cc ) and
475
+ charClass = [ "d" , "s" , "w" ]
473
476
}
474
477
475
478
override string getARelevantChar ( ) {
476
- cc . getValue ( ) = "d" and
479
+ charClass = "d" and
477
480
result = [ "0" , "9" ]
478
481
or
479
- cc . getValue ( ) = "s" and
482
+ charClass = "s" and
480
483
result = " "
481
484
or
482
- cc . getValue ( ) = "w" and
485
+ charClass = "w" and
483
486
result = [ "a" , "Z" , "_" , "0" , "9" ]
484
487
}
485
488
486
- override predicate matches ( string char ) { classEscapeMatches ( cc . getValue ( ) , char ) }
489
+ override predicate matches ( string char ) { classEscapeMatches ( charClass , char ) }
487
490
488
491
override string choose ( ) {
489
- cc . getValue ( ) = "d" and
492
+ charClass = "d" and
490
493
result = "9"
491
494
or
492
- cc . getValue ( ) = "s" and
495
+ charClass = "s" and
493
496
result = " "
494
497
or
495
- cc . getValue ( ) = "w" and
498
+ charClass = "w" and
496
499
result = "a"
497
500
}
498
501
}
@@ -501,26 +504,29 @@ private module CharacterClasses {
501
504
* An implementation of `CharacterClass` for \D, \S, and \W.
502
505
*/
503
506
private class NegativeCharacterClassEscape extends CharacterClass {
504
- RegExpCharacterClassEscape cc ;
507
+ RegExpTerm cc ;
508
+ string charClass ;
505
509
506
510
NegativeCharacterClassEscape ( ) {
507
- this = getCanonicalCharClass ( cc ) and cc .getValue ( ) = [ "D" , "S" , "W" ]
511
+ isEscapeClass ( cc , charClass ) and
512
+ this = getCanonicalCharClass ( cc ) and
513
+ charClass = [ "D" , "S" , "W" ]
508
514
}
509
515
510
516
override string getARelevantChar ( ) {
511
- cc . getValue ( ) = "D" and
517
+ charClass = "D" and
512
518
result = [ "a" , "Z" , "!" ]
513
519
or
514
- cc . getValue ( ) = "S" and
520
+ charClass = "S" and
515
521
result = [ "a" , "9" , "!" ]
516
522
or
517
- cc . getValue ( ) = "W" and
523
+ charClass = "W" and
518
524
result = [ " " , "!" ]
519
525
}
520
526
521
527
bindingset [ char]
522
528
override predicate matches ( string char ) {
523
- not classEscapeMatches ( cc . getValue ( ) .toLowerCase ( ) , char )
529
+ not classEscapeMatches ( charClass .toLowerCase ( ) , char )
524
530
}
525
531
}
526
532
}
@@ -599,7 +605,7 @@ predicate delta(State q1, EdgeLabel lbl, State q2) {
599
605
q2 = after ( cc )
600
606
)
601
607
or
602
- exists ( RegExpCharacterClassEscape cc |
608
+ exists ( RegExpTerm cc | isEscapeClass ( cc , _ ) |
603
609
q1 = before ( cc ) and
604
610
lbl = CharClass ( cc .getRawValue ( ) + "|" + getCanonicalizationFlags ( cc .getRootTerm ( ) ) ) and
605
611
q2 = after ( cc )
0 commit comments