mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Update pegen to use the latest upstream developments (GH-27586)
This commit is contained in:
parent
8e832fb2a2
commit
953d27261e
26 changed files with 1243 additions and 673 deletions
|
@ -18,7 +18,7 @@ from pegen.python_generator import PythonParserGenerator
|
|||
from pegen.tokenizer import Tokenizer
|
||||
|
||||
ALL_TOKENS = token.tok_name
|
||||
EXACT_TOKENS = token.EXACT_TOKEN_TYPES # type: ignore
|
||||
EXACT_TOKENS = token.EXACT_TOKEN_TYPES
|
||||
NON_EXACT_TOKENS = {
|
||||
name for index, name in token.tok_name.items() if index not in EXACT_TOKENS.values()
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ def run_parser(file: IO[bytes], parser_class: Type[Parser], *, verbose: bool = F
|
|||
parser = parser_class(tokenizer, verbose=verbose)
|
||||
result = parser.start()
|
||||
if result is None:
|
||||
raise parser.make_syntax_error()
|
||||
raise parser.make_syntax_error("invalid syntax")
|
||||
return result
|
||||
|
||||
|
||||
|
@ -66,6 +66,7 @@ def import_file(full_name: str, path: str) -> Any:
|
|||
"""Import a python module from a path"""
|
||||
|
||||
spec = importlib.util.spec_from_file_location(full_name, path)
|
||||
assert spec is not None
|
||||
mod = importlib.util.module_from_spec(spec)
|
||||
|
||||
# We assume this is not None and has an exec_module() method.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue