mirror of
https://github.com/python/cpython.git
synced 2025-09-23 08:53:45 +00:00
bpo-40688: Use the correct parser in the peg_generator scripts (GH-20235)
The scripts in `Tools/peg_generator/scripts` mostly assume that
`ast.parse` and `compile` use the old parser, since this was the
state of things, while we were developing them. They need to be
updated to always use the correct parser. `_peg_parser` is being
extended to support both parsing and compiling with both parsers.
(cherry picked from commit 9645930b5b
)
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
This commit is contained in:
parent
318a18eb88
commit
3c6c86ab77
6 changed files with 151 additions and 187 deletions
|
@ -54,7 +54,7 @@ def find_dirname(package_name: str) -> str:
|
|||
assert False # This is to fix mypy, should never be reached
|
||||
|
||||
|
||||
def run_tests(dirname: str, tree: int, extension: Any) -> int:
|
||||
def run_tests(dirname: str, tree: int) -> int:
|
||||
return test_parse_directory.parse_directory(
|
||||
dirname,
|
||||
HERE / ".." / ".." / ".." / "Grammar" / "python.gram",
|
||||
|
@ -72,7 +72,6 @@ def run_tests(dirname: str, tree: int, extension: Any) -> int:
|
|||
skip_actions=False,
|
||||
tree_arg=tree,
|
||||
short=True,
|
||||
extension=extension,
|
||||
mode=1,
|
||||
parser="pegen",
|
||||
)
|
||||
|
@ -82,13 +81,6 @@ def main() -> None:
|
|||
args = argparser.parse_args()
|
||||
tree = args.tree
|
||||
|
||||
extension = build.build_c_parser_and_generator(
|
||||
HERE / ".." / ".." / ".." / "Grammar" / "python.gram",
|
||||
HERE / ".." / ".." / ".." / "Grammar" / "Tokens",
|
||||
"peg_extension/parse.c",
|
||||
compile_extension=True,
|
||||
)
|
||||
|
||||
for package in get_packages():
|
||||
print(f"Extracting files from {package}... ", end="")
|
||||
try:
|
||||
|
@ -100,7 +92,7 @@ def main() -> None:
|
|||
|
||||
print(f"Trying to parse all python files ... ")
|
||||
dirname = find_dirname(package)
|
||||
status = run_tests(dirname, tree, extension)
|
||||
status = run_tests(dirname, tree)
|
||||
if status == 0:
|
||||
shutil.rmtree(dirname)
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue