@@ -296,9 +296,6 @@ def __init__(self, string, in_argument=False):
296
296
GROUP_CLOSE ,
297
297
ESCAPE_CHAR ,
298
298
)
299
- special_char_re = re .compile (
300
- rf"[{ '' .join (re .escape (c ) for c in special_chars )} ]|\Z"
301
- )
302
299
escapable_chars = (SYMBOL_DELIM , FUNC_DELIM , GROUP_CLOSE , ARG_SEP )
303
300
terminator_chars = (GROUP_CLOSE ,)
304
301
@@ -310,20 +307,18 @@ def parse_expression(self):
310
307
"""
311
308
# Append comma (ARG_SEP) to the list of special characters only when
312
309
# parsing function arguments.
313
- extra_special_chars = ()
314
- special_char_re = self .special_char_re
315
- if self .in_argument :
316
- special_chars = (* self .special_chars , ARG_SEP )
317
- special_char_re = re .compile (
318
- rf"[{ '' .join (map (re .escape , special_chars ))} ]|\Z"
319
- )
310
+ extra_special_chars = (ARG_SEP ,) if self .in_argument else ()
311
+ special_chars = (* self .special_chars , * extra_special_chars )
312
+ special_char_re = re .compile (
313
+ rf"[{ '' .join (map (re .escape , special_chars ))} ]|\Z"
314
+ )
320
315
321
316
text_parts = []
322
317
323
318
while self .pos < len (self .string ):
324
319
char = self .string [self .pos ]
325
320
326
- if char not in self . special_chars + extra_special_chars :
321
+ if char not in special_chars :
327
322
# A non-special character. Skip to the next special
328
323
# character, treating the interstice as literal text.
329
324
next_pos = (
0 commit comments