mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
gh-102033: Fix syntax error in Tools/c-analyzer (GH-102066)
The easiest way to format strings with `{}` meaningful chars is via `%`.
This commit is contained in:
parent
7559f5fda9
commit
1ca315538f
14 changed files with 3 additions and 335 deletions
|
|
@ -1,6 +0,0 @@
|
|||
|
||||
def _parse(srclines, anon_name):
|
||||
text = ' '.join(l for _, l in srclines)
|
||||
|
||||
from ._delim import parse
|
||||
yield from parse(text, anon_name)
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
import re
|
||||
import textwrap
|
||||
|
||||
from ._regexes import _ind, STRING_LITERAL
|
||||
|
||||
|
||||
def parse(text, anon_name):
|
||||
context = None
|
||||
data = None
|
||||
for m in DELIMITER_RE.find_iter(text):
|
||||
before, opened, closed = m.groups()
|
||||
delim = opened or closed
|
||||
|
||||
handle_segment = HANDLERS[context][delim]
|
||||
result, context, data = handle_segment(before, delim, data)
|
||||
if result:
|
||||
yield result
|
||||
|
||||
|
||||
DELIMITER = textwrap.dedent(rf'''
|
||||
(
|
||||
(?:
|
||||
[^'"()\[\]{};]*
|
||||
{_ind(STRING_LITERAL, 3)}
|
||||
}*
|
||||
[^'"()\[\]{};]+
|
||||
)? # <before>
|
||||
(?:
|
||||
(
|
||||
[(\[{]
|
||||
) # <open>
|
||||
|
|
||||
(
|
||||
[)\]};]
|
||||
) # <close>
|
||||
)?
|
||||
''')
|
||||
DELIMITER_RE = re.compile(DELIMITER, re.VERBOSE)
|
||||
|
||||
_HANDLERS = {
|
||||
None: { # global
|
||||
# opened
|
||||
'{': ...,
|
||||
'[': None,
|
||||
'(': None,
|
||||
# closed
|
||||
'}': None,
|
||||
']': None,
|
||||
')': None,
|
||||
';': ...,
|
||||
},
|
||||
'': {
|
||||
},
|
||||
}
|
||||
|
|
@ -9,7 +9,6 @@ from ._common import (
|
|||
set_capture_groups,
|
||||
)
|
||||
from ._compound_decl_body import DECL_BODY_PARSERS
|
||||
#from ._func_body import parse_function_body
|
||||
from ._func_body import parse_function_statics as parse_function_body
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue