@@ -124,23 +124,14 @@ abstract class RegexString extends Expr {
124
124
)
125
125
}
126
126
127
- /** Escaped characters without any special handling (yet) */
128
- private predicate singleEscape ( int i ) {
129
- exists ( string c |
130
- c = this .getChar ( i ) and
131
- c != "x" and c != "u" and c != "U" and c != "N"
132
- )
133
- }
134
-
135
127
/** Named unicode characters, eg \N{degree sign} */
136
128
private predicate escapedName ( int start , int end ) {
129
+ this .escapingChar ( start ) and
137
130
this .getChar ( start + 1 ) = "N" and
138
131
this .getChar ( start + 2 ) = "{" and
139
132
this .getChar ( end - 1 ) = "}" and
140
133
end > start and
141
- not exists ( int i |
142
- i > start + 2 and
143
- i < end - 1 and
134
+ not exists ( int i | start + 2 < i and i < end - 1 |
144
135
this .getChar ( i ) = "}"
145
136
)
146
137
}
@@ -156,16 +147,17 @@ abstract class RegexString extends Expr {
156
147
end in [ start + 2 .. start + 4 ] and
157
148
exists ( this .getText ( ) .substring ( start + 1 , end ) .toInt ( ) )
158
149
or
159
- // 16-bit hex value
150
+ // 16-bit hex value \uhhhh
160
151
this .getChar ( start + 1 ) = "u" and end = start + 6
161
152
or
162
- // 32-bit hex value
153
+ // 32-bit hex value \Uhhhhhhhh
163
154
this .getChar ( start + 1 ) = "U" and end = start + 10
164
155
or
165
156
escapedName ( start , end )
166
157
or
167
- // single character not handled above, update when adding a new case
168
- this .singleEscape ( start + 1 ) and end = start + 2
158
+ // escape not handled above, update when adding a new case
159
+ not this .getChar ( start + 1 ) in [ "x" , "u" , "U" , "N" ] and
160
+ end = start + 2
169
161
)
170
162
}
171
163
0 commit comments