@@ -100,9 +100,7 @@ abstract class RegExp extends StringLiteral {
100100 ( this .nonEscapedCharAt ( p ) = "[" or this .nonEscapedCharAt ( p ) = "]" ) and
101101 // Brackets that are part of POSIX expressions should not count as
102102 // char-set delimiters.
103- not exists ( int x , int y |
104- this .posixStyleNamedCharacterProperty ( x , y , _) and pos >= x and pos < y
105- )
103+ not exists ( int x , int y | this .posixStyleProperty ( x , y , _, _) and pos >= x and pos < y )
106104 ) and
107105 (
108106 this .nonEscapedCharAt ( pos ) = "[" and result = true
@@ -132,9 +130,7 @@ abstract class RegExp extends StringLiteral {
132130 min ( int e |
133131 e > innerStart and
134132 this .nonEscapedCharAt ( e ) = "]" and
135- not exists ( int x , int y |
136- this .posixStyleNamedCharacterProperty ( x , y , _) and e >= x and e < y
137- )
133+ not exists ( int x , int y | this .posixStyleProperty ( x , y , _, _) and e >= x and e < y )
138134 |
139135 e
140136 )
@@ -160,7 +156,7 @@ abstract class RegExp extends StringLiteral {
160156 (
161157 this .escapedCharacter ( start , end )
162158 or
163- this .namedCharacterProperty ( start , end , _)
159+ this .namedCharacterProperty ( start , end , _, _ )
164160 or
165161 exists ( this .nonEscapedCharAt ( start ) ) and end = start + 1
166162 )
@@ -169,7 +165,7 @@ abstract class RegExp extends StringLiteral {
169165 (
170166 this .escapedCharacter ( start , end )
171167 or
172- this .namedCharacterProperty ( start , end , _)
168+ this .namedCharacterProperty ( start , end , _, _ )
173169 or
174170 exists ( this .nonEscapedCharAt ( start ) ) and
175171 end = start + 1 and
@@ -282,28 +278,34 @@ abstract class RegExp extends StringLiteral {
282278 )
283279 }
284280
285- /** Matches named character properties such as `[[ :digit:] ]`. */
286- predicate namedCharacterProperty ( int start , int end , string name ) {
287- this .posixStyleNamedCharacterProperty ( start , end , name )
281+ /** Matches named character properties such as `[:digit:]`. */
282+ predicate namedCharacterProperty ( int start , int end , string symbol , string name ) {
283+ this .posixStyleProperty ( start , end , symbol , name )
288284 }
289285
290286 /** Gets the name of the character property in start,end */
291287 string getCharacterPropertyName ( int start , int end ) {
292- this .namedCharacterProperty ( start , end , result )
288+ this .namedCharacterProperty ( start , end , _, result )
289+ }
290+
291+ /** Gets the symbol of the character property in start,end */
292+ string getCharacterPropertySymbol ( int start , int end ) {
293+ this .namedCharacterProperty ( start , end , result , _)
293294 }
294295
295296 /** Matches a POSIX bracket expression such as `[:alnum:]` within a character class. */
296- private predicate posixStyleNamedCharacterProperty ( int start , int end , string name ) {
297+ private predicate posixStyleProperty ( int start , int end , string symbol , string name ) {
297298 this .getChar ( start ) = "[" and
298- this .getChar ( start + 1 ) = ":" and
299+ this .getChar ( start + 1 ) = symbol and
299300 end =
300301 min ( int e |
301302 e > start and
302- this .getChar ( e - 2 ) = ":" and
303+ this .getChar ( e - 2 ) = symbol and
303304 this .getChar ( e - 1 ) = "]"
304305 |
305306 e
306307 ) and
308+ symbol in [ ":" , "." , "=" ] and
307309 name = this .getText ( ) .substring ( start + 2 , end - 2 )
308310 }
309311
@@ -348,9 +350,7 @@ abstract class RegExp extends StringLiteral {
348350 * Holds if the character at `index` is inside a posix bracket.
349351 */
350352 predicate inPosixBracket ( int index ) {
351- exists ( int x , int y |
352- this .posixStyleNamedCharacterProperty ( x , y , _) and index in [ x + 1 .. y - 2 ]
353- )
353+ exists ( int x , int y | this .posixStyleProperty ( x , y , _, _) and index in [ x + 1 .. y - 2 ] )
354354 }
355355
356356 /**
@@ -361,7 +361,7 @@ abstract class RegExp extends StringLiteral {
361361 not this .charSet ( start , _) and
362362 not this .charSet ( _, start + 1 ) and
363363 not exists ( int x , int y |
364- this .posixStyleNamedCharacterProperty ( x , y , _) and
364+ this .posixStyleProperty ( x , y , _ , _) and
365365 start >= x and
366366 end <= y
367367 ) and
@@ -731,7 +731,7 @@ abstract class RegExp extends StringLiteral {
731731 this .isGroupStart ( start ) or
732732 this .charSet ( start , _) or
733733 this .backreference ( start , _) or
734- this .namedCharacterProperty ( start , _, _)
734+ this .namedCharacterProperty ( start , _, _, _ )
735735 }
736736
737737 private predicate itemEnd ( int end ) {
0 commit comments