Information used to resolve or unescape macro arguments.
| 46 | |
| 47 | @dataclass(frozen=True, slots=True) |
| 48 | class MacroArg: |
| 49 | """Information used to resolve or unescape macro arguments.""" |
| 50 | |
| 51 | # The starting index of this argument in the macro value |
| 52 | start_index: int |
| 53 | |
| 54 | # The number string that appears between the braces |
| 55 | # This is a string instead of an int because we support unicode digits and must be able |
| 56 | # to reproduce this string later |
| 57 | number_str: str |
| 58 | |
| 59 | # Tells if this argument is escaped and therefore needs to be unescaped |
| 60 | is_escaped: bool |
| 61 | |
| 62 | # Matches normal args like {5} |
| 63 | # Uses lookarounds to ensure exactly one brace. |
| 64 | # (?<!{){ -> Match '{' not preceded by '{' |
| 65 | # \d+ -> Match digits |
| 66 | # }(?!}) -> Match '}' not followed by '}' |
| 67 | macro_normal_arg_pattern: ClassVar[re.Pattern[str]] = re.compile(r"(?<!{){\d+}|{\d+}(?!})") |
| 68 | |
| 69 | # Matches escaped args like {{5}} |
| 70 | # Specifically looking for exactly two braces on each side. |
| 71 | macro_escaped_arg_pattern: ClassVar[re.Pattern[str]] = re.compile(r"{{2}\d+}{2}") |
| 72 | |
| 73 | # Finds a string of digits |
| 74 | digit_pattern: ClassVar[re.Pattern[str]] = re.compile(r"\d+") |
| 75 | |
| 76 | |
| 77 | @dataclass(frozen=True, slots=True) |
no outgoing calls
no test coverage detected
searching dependent graphs…