summaryrefslogtreecommitdiffstats
path: root/Tools/peg_generator
Commit message (Collapse)AuthorAgeFilesLines
* Update grammar_grapher with the new forced (&&) directive (#31704)Luca Chiodini2022-03-061-0/+3
|
* Allow the parser to avoid nested processing of invalid rules (GH-31252)Pablo Galindo Salgado2022-02-101-2/+15
|
* bpo-46576: bpo-46524: Disable compiler optimization within ↵Gregory P. Smith2022-02-021-0/+10
| | | | | | | | | | | | | | | | | | | | test_peg_generator. (#31015) Disable compiler optimization within test_peg_generator. This speed up test_peg_generator by always disabling compiler optimizations by using -O0 or equivalent when the test is building its own C extensions. A build not using --with-pydebug in order to speed up test execution winds up with this test taking a very long time as it would do repeated compilation of parser C code using the same optimization flags as CPython was built with. This speeds the test up 6-8x on gps-raspbian. Also incorporate's #31017's win32 conditional and flags. Co-authored-by: Kumar Aditya kumaraditya303
* bpo-46110: Restore commit e9898bf153d26059261ffef11f7643ae991e2a4cPablo Galindo Salgado2022-01-031-4/+11
| | | This restores commit e9898bf153d26059261ffef11f7643ae991e2a4c .
* Revert "bpo-46110: Add a recursion check to avoid stack overflow in the PEG ↵Pablo Galindo Salgado2022-01-031-11/+4
| | | | | parser (GH-30177)" (GH-30363) This reverts commit e9898bf153d26059261ffef11f7643ae991e2a4c temporarily as we want to confirm if this commit is the cause of a slowdown at startup time.
* bpo-46110: Add a recursion check to avoid stack overflow in the PEG parser ↵Pablo Galindo Salgado2021-12-201-4/+11
| | | | | (GH-30177) Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
* bpo-45866: pegen strips directory of "generated from" header (GH-29777)Victor Stinner2021-11-263-3/+7
| | | | | "make regen-all" now produces the same output when run from a directory other than the source tree: when building Python out of the source tree.
* Refactor parser compilation units into specific components (GH-29676)Pablo Galindo Salgado2021-11-212-1/+3
|
* bpo-44257: fix "assigment_expr" typo + regenerate the grammar, and remove ↵wim glenn2021-11-031-2/+0
| | | | | | unused imports (GH-29393) Co-authored-by: Wim Glenn <wglenn@jumptrading.com>
* bpo-45494: Fix parser crash when reporting errors involving invalid ↵Pablo Galindo Salgado2021-10-191-1/+1
| | | | | | | | | | | | continuation characters (GH-28993) There are two errors that this commit fixes: * The parser was not correctly computing the offset and the string source for E_LINECONT errors due to the incorrect usage of strtok(). * The parser was not correctly unwinding the call stack when a tokenizer exception happened in rules involving optionals ('?', [...]) as we always make them return valid results by using the comma operator. We need to check first if we don't have an error before continuing.
* Fix typos in the Tools directory (GH-28769)Christian Clauss2021-10-063-3/+3
| | | | | | | Like #28744 but for the Tools directory. [skip issue] Opening a related issue is pending python/psf-infra-meta#130 Automerge-Triggered-By: GH:pablogsal
* [Tools/peg_generator/pegen/parser.py] Fix typo: s/wether/whether/ (GH-28739)Ikko Ashimine2021-10-051-1/+1
|
* Extract visitors from the grammar nodes and call makers in the peg generator ↵Pablo Galindo Salgado2021-09-0511-240/+244
| | | | | (GH-28172) Simplify the peg generator logic by extracting as much visitors as possible to disentangle the flow and separate concerns.
* Update pegen to use the latest upstream developments (GH-27586)Pablo Galindo Salgado2021-08-1219-397/+549
|
* bpo-44345: Fix 'generated by' comment in parser.c (GH-26615)Akira Nonaka2021-06-091-1/+1
|
* bpo-44180: Fix edge cases in invalid assigment rules in the parser (GH-26283)Pablo Galindo2021-05-211-0/+2
| | | | | | | | | | | | | | | The invalid assignment rules are very delicate since the parser can easily raise an invalid assignment when a keyword argument is provided. As they are very deep into the grammar tree, is very difficult to specify in which contexts these rules can be used and in which don't. For that, we need to use a different version of the rule that doesn't do error checking in those situations where we don't want the rule to raise (keyword arguments and generator expressions). We also need to check if we are in left-recursive rule, as those can try to eagerly advance the parser even if the parse will fail at the end of the expression. Failing to do this allows the parser to start parsing a call as a tuple and incorrectly identify a keyword argument as an invalid assignment, before it realizes that it was not a tuple after all.
* bpo-38605: Revert making 'from __future__ import annotations' the default ↵Pablo Galindo2021-04-212-2/+2
| | | | | | (GH-25490) This reverts commits 044a1048ca93d466965afc027b91a5a9eb9ce23c and 1be456ae9d53bb1cba2b24fc86175c282d1c2169, adapting the code to changes that happened after it.
* bpo-43822: Improve syntax errors for missing commas (GH-25377)Pablo Galindo2021-04-151-0/+12
|
* Sanitize macros and debug functions in pegen.c (GH-25291)Pablo Galindo2021-04-091-0/+8
|
* bpo-43244: Remove the pyarena.h header (GH-25007)Victor Stinner2021-03-241-4/+4
| | | | | | | | | | | | | | | | | | Remove the pyarena.h header file with functions: * PyArena_New() * PyArena_Free() * PyArena_Malloc() * PyArena_AddPyObject() These functions were undocumented, excluded from the limited C API, and were only used internally by the compiler. Add pycore_pyarena.h header. Rename functions: * PyArena_New() => _PyArena_New() * PyArena_Free() => _PyArena_Free() * PyArena_Malloc() => _PyArena_Malloc() * PyArena_AddPyObject() => _PyArena_AddPyObject()
* bpo-43244: Remove parser_interface.h header file (GH-25001)Victor Stinner2021-03-241-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | Remove parser functions using the "struct _mod" type, because the AST C API was removed: * PyParser_ASTFromFile() * PyParser_ASTFromFileObject() * PyParser_ASTFromFilename() * PyParser_ASTFromString() * PyParser_ASTFromStringObject() These functions were undocumented and excluded from the limited C API. Add pycore_parser.h internal header file. Rename functions: * PyParser_ASTFromFileObject() => _PyParser_ASTFromFile() * PyParser_ASTFromStringObject() => _PyParser_ASTFromString() These functions are no longer exported (replace PyAPI_FUNC() with extern). Remove also _PyPegen_run_parser_from_file() function. Update test_peg_generator to use _PyPegen_run_parser_from_file_pointer() instead.
* bpo-43244: Add pycore_compile.h header file (GH-25000)Victor Stinner2021-03-231-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Remove the compiler functions using "struct _mod" type, because the public AST C API was removed: * PyAST_Compile() * PyAST_CompileEx() * PyAST_CompileObject() * PyFuture_FromAST() * PyFuture_FromASTObject() These functions were undocumented and excluded from the limited C API. Rename functions: * PyAST_CompileObject() => _PyAST_Compile() * PyFuture_FromASTObject() => _PyFuture_FromAST() Moreover, _PyFuture_FromAST() is no longer exported (replace PyAPI_FUNC() with extern). _PyAST_Compile() remains exported for test_peg_generator. Remove also compatibility functions: * PyAST_Compile() * PyAST_CompileEx() * PyFuture_FromAST()
* bpo-43244: Fix test_peg_generators on Windows (GH-24913)Victor Stinner2021-03-181-3/+2
| | | | Don't redefine Py_DebugFlag, it's already defined in pydebug.h which is included by Python.h
* bpo-43244: Fix test_peg_generator for PyAST_Validate() (GH-24912)Victor Stinner2021-03-181-0/+3
| | | | | | | | | test_peg_generator now defines _Py_TEST_PEGEN macro when building C code to not call PyAST_Validate() in Parser/pegen.c. Moreover, it defines Py_BUILD_CORE_MODULE macro to get access to the internal C API. Remove "global_ast_state" from Python-ast.c when it's built by test_peg_generator: always get the AST state from the current interpreter.
* Remove unnecessary imports in the grammar parser (GH-24904)Elisha Hollander2021-03-172-8/+2
|
* bpo-11717: fix ssize_t redefinition error when targeting 32bit Windows app ↵Jozef Grajciar2021-03-011-2/+2
| | | | (GH-24479)
* bpo-42997: Improve error message for missing : before suites (GH-24292)Pablo Galindo2021-02-024-2/+70
| | | | | | | | * Add to the peg generator a new directive ('&&') that allows to expect a token and hard fail the parsing if the token is not found. This allows to quickly emmit syntax errors for missing tokens. * Use the new grammar element to hard-fail if the ':' is missing before suites.
* Add small validator utility for PEG grammars (GH-23519)Pablo Galindo2020-12-262-0/+55
|
* bpo-42218: Correctly handle errors in left-recursive rules (GH-23065)Lysandros Nikolaou2020-10-311-0/+3
| | | | | | | Left-recursive rules need to check for errors explicitly, since even if the rule returns NULL, the parsing might continue and lead to long-distance failures. Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-42123: Run the parser two times and only enable invalid rules on the ↵Lysandros Nikolaou2020-10-261-1/+4
| | | | | | | | | | second run (GH-22111) * Implement running the parser a second time for the errors messages The first parser run is only responsible for detecting whether there is a `SyntaxError` or not. If there isn't the AST gets returned. Otherwise, the parser is run a second time with all the `invalid_*` rules enabled so that all the customized error messages get produced.
* Revert "Fix all Python Cookbook links (#22205)" (GH-22424)Andre Delfino2020-09-271-2/+2
| | | This commit reverts commit ac0333e1e117b7f61ed7ef1dbcdb6e515ada603b as the original links are working again and they provide extended features such as comments and alternative versions.
* bpo-41746: Add type information to asdl_seq objects (GH-22223)Pablo Galindo2020-09-164-6/+56
| | | | | | | | | | | | | * Add new capability to the PEG parser to type variable assignments. For instance: ``` | a[asdl_stmt_seq*]=';'.small_stmt+ [';'] NEWLINE { a } ``` * Add new sequence types from the asdl definition (automatically generated) * Make `asdl_seq` type a generic aliasing pointer type. * Create a new `asdl_generic_seq` for the generic case using `void*`. * The old `asdl_seq_GET`/`ast_seq_SET` macros now are typed. * New `asdl_seq_GET_UNTYPED`/`ast_seq_SET_UNTYPED` macros for dealing with generic sequences. * Changes all possible `asdl_seq` types to use specific versions everywhere.
* Fix all Python Cookbook links (#22205)Andre Delfino2020-09-151-2/+2
|
* Fix 'gather' rules in the python parser generator (GH-22021)Pablo Galindo2020-09-031-0/+3
| | | | | | Currently, empty sequences in gather rules make the conditional for gather rules fail as empty sequences evaluate as "False". We need to explicitly check for "None" (the failure condition) to avoid false negatives.
* Delete remaining references to Grammar/Grammar from docs (#21624)Guido van Rossum2020-07-261-1/+1
| | | (Ironically, the file itself remains, see https://github.com/we-like-parsers/cpython/issues/135.)
* bpo-41215: Don't use NULL by default in the PEG parser keyword list (GH-21355)Pablo Galindo2020-07-061-1/+1
| | | Automerge-Triggered-By: @lysnikolaou
* bpo-41044: Generate valid PEG python parsers for opt+seq rules (GH-20995)Batuhan Taskaya2020-06-201-1/+7
| | | Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-41043: Escape literal part of the path for glob(). (GH-20994)Serhiy Storchaka2020-06-201-2/+2
|
* Fix trailing whitespace in keyword.py (GH-20881)Pablo Galindo2020-06-151-2/+2
|
* Include soft keywords in keyword.py (GH-20877)Pablo Galindo2020-06-152-4/+13
|
* bpo-40939: Clean and adapt the peg_generator directory after deleting the ↵Pablo Galindo2020-06-126-304/+30
| | | | old parser (GH-20822)
* bpo-40939: Remove the old parser (GH-20768)Pablo Galindo2020-06-111-3/+2
| | | This commit removes the old parser, the deprecated parser module, the old parser compatibility flags and environment variables and all associated support code and documentation.
* bpo-40939: Generate keyword.py using the new parser (GH-20800)Lysandros Nikolaou2020-06-111-0/+73
|
* Refactor scripts in Tools/peg_generator/scripts (GH-20401)Lysandros Nikolaou2020-06-066-140/+131
|
* Fix lookahead of soft keywords in the PEG parser (GH-20436)Pablo Galindo2020-05-261-2/+9
| | | Automerge-Triggered-By: @gvanrossum
* Add soft keywords (GH-20370)Guido van Rossum2020-05-261-4/+20
| | | | | | | These are like keywords but they only work in context; they are not reserved except when there is an exact match. This would enable things like match statements without reserving `match` (which would be bad for the `re.match()` function and probably lots of other places). Automerge-Triggered-By: @gvanrossum
* Fix peg_generator compiler warnings under MSVC (GH-20405)Ammar Askar2020-05-261-4/+4
|
* bpo-40688: Use the correct parser in the peg_generator scripts (GH-20235)Lysandros Nikolaou2020-05-255-120/+55
| | | | | | | 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.
* bpo-40750: Do not expand the new parser debug flags if Py_BUILD_CORE is not ↵Pablo Galindo2020-05-251-1/+1
| | | | defined (GH-20393)
* bpo-40750: Support -d flag in the new parser (GH-20340)Pablo Galindo2020-05-252-25/+61
|