| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
| |
parser (GH-27392)
(cherry picked from commit ecc3c8e4216958d85385bf2467441c975128f26c)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
|
|
|
|
|
|
|
| |
(GH-27389). (GH-27391)
(cherry picked from commit 6948964ecf94e858448dd28eea634317226d2913)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
|
|
|
|
|
|
|
| |
patterns (GH-26793)
(cherry picked from commit 0acc258fe6f0ec200ca2f6f9294adbf52a244802)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
|
|
|
|
|
|
|
| |
(GH-26632) (GH-26792)
(cherry picked from commit 05073036dcecefc00b0c3e7397601809da41e2f1)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
|
|
|
|
|
|
| |
Automerge-Triggered-By: GH:lysnikolaou
(cherry picked from commit e7b4644607789848f9752a3bd20ff216e25b4156)
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
|
|
|
|
|
|
|
| |
finally (GH-26523) (GH-26524)
(cherry picked from commit b250f89bb7e05e72a4641d44b988866b919575db)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
(cherry picked from commit c878a9796841c1f4726e6dd5ac49a478af4c8504)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
|
|
|
|
|
|
|
|
|
| |
expressions (GH-26210) (GH-26247)
(cherry picked from commit 33c0c90dea06fda1df99482521559ebef7210bea)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
|
|
|
|
|
|
|
|
|
|
| |
(GH-25996) GH-25997)
Automerge-Triggered-By: GH:pablogsal
(cherry picked from commit 6692dc1ca99fb34a19d0a4b93cf8e10619490001)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
|
| |
|
|
|
| |
Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
To improve the user experience understanding what part of the error messages associated with SyntaxErrors is wrong, we can highlight the whole error range and not only place the caret at the first character. In this way:
>>> foo(x, z for z in range(10), t, w)
File "<stdin>", line 1
foo(x, z for z in range(10), t, w)
^
SyntaxError: Generator expression must be parenthesized
becomes
>>> foo(x, z for z in range(10), t, w)
File "<stdin>", line 1
foo(x, z for z in range(10), t, w)
^^^^^^^^^^^^^^^^^^^^
SyntaxError: Generator expression must be parenthesized
|
| |
|
|
|
|
| |
(GH-25427)
|
| |
|
| |
|
|
|
|
| |
generators (GH-25390)
|
|
|
|
| |
(GH-25375)
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* bpo-43797: Improve syntax error for invalid comparisons
* Update Lib/test/test_fstring.py
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
* Apply review comments
* can't -> cannot
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
|
|
|
|
|
|
|
| |
* Add source location attributes to alias.
* Move alias star construction to pegen helper.
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
|
|
|
|
|
|
| |
Rename AST functions of pycore_ast.h to use the "_PyAST_" prefix.
Remove macros creating aliases without prefix. For example, Module()
becomes _PyAST_Module(). Update Grammar/python.gram to use
_PyAST_xxx() functions.
|
|
|
|
| |
(GH-25006)
|
| |
|
|
|
|
|
| |
Co-authored-by: Guido van Rossum <guido@python.org>
Co-authored-by: Talin <viridia@gmail.com>
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
|
|
|
|
| |
(GH-24467)
|
| |
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
| |
comprehensions (GH24314)
|
|
|
|
|
|
| |
This is only there so that alternative implementations written in statically-typed languages can use this grammar without
having type errors in the way.
Automerge-Triggered-By: GH:lysnikolaou
|
| |
|
|
|
| |
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Currently walruses are not allowerd in set literals and set comprehensions:
>>> {y := 4, 4**2, 3**3}
File "<stdin>", line 1
{y := 4, 4**2, 3**3}
^
SyntaxError: invalid syntax
but they should be allowed as well per PEP 572
|
| |
|
|
|
|
|
| |
This fixes a regression that was introduced by the new parser.
Automerge-Triggered-By: GH:lysnikolaou
|
|
|
|
| |
barry_as_flufl rule (GH-23048)
|
| |
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
| |
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
| |
parser (GH-22077)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(GH-22053)
This program can segfault the parser by stack overflow:
```
import ast
code = "f(" + ",".join(['a' for _ in range(100000)]) + ")"
print("Ready!")
ast.parse(code)
```
the reason is that the rule for arguments has a simple recursion when collecting args:
args[expr_ty]:
[...]
| a=named_expression b=[',' c=args { c }] {
[...] }
|
|
|
|
|
|
|
| |
(GH-19969)
(We censor the heck out of actions and some other stuff using a custom "highlighter".)
Co-authored-by: Guido van Rossum <guido@python.org>
|
|
|
| |
(Ironically, the file itself remains, see https://github.com/we-like-parsers/cpython/issues/135.)
|
|
|
|
| |
assignment rule (GH-20387)
|
|
|
|
| |
(GH-21160)
|
|
|
|
|
|
|
|
|
| |
(GH-21020)
`GET_INVALID_TARGET` might unexpectedly return `NULL`, which if not
caught will cause a SEGFAULT. Therefore, this commit introduces a new
inline function `RAISE_SYNTAX_ERROR_INVALID_TARGET` that always
checks for `GET_INVALID_TARGET` returning NULL and can be used in
the grammar, replacing the long C ternary operation used till now.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The following error messages get produced:
- `cannot delete ...` for invalid `del` targets
- `... is an illegal 'for' target` for invalid targets in for
statements
- `... is an illegal 'with' target` for invalid targets in
with statements
Additionally, a few `cut`s were added in various places before the
invocation of the `invalid_*` rule, in order to speed things
up.
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
|
| |
|