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:
Nikita Sobolev 2023-03-22 17:59:32 +03:00 committed by GitHub
parent 7559f5fda9
commit 1ca315538f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 3 additions and 335 deletions

View file

@ -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)

View file

@ -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,
';': ...,
},
'': {
},
}

View file

@ -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