summaryrefslogtreecommitdiffstats
path: root/Grammar
Commit message (Collapse)AuthorAgeFilesLines
* bpo-44947: Refine the syntax error for trailing commas in import statements ↵Pablo Galindo Salgado2021-08-181-1/+1
| | | | (GH-27814)
* bpo-44838: Refine the custom syntax errors for invalid 'if' expressions ↵Pablo Galindo Salgado2021-08-051-1/+1
| | | | (GH-27615)
* bpo-44792: Improve syntax errors for if expressions (GH-27506)Miguel Brito2021-08-021-0/+1
|
* bpo-34013: Don't consider a grouped expression when reporting legacy print ↵Pablo Galindo Salgado2021-08-011-1/+1
| | | | syntax errors (GH-27521)
* Divide the grammar into sections to improve readability (GH-27502)Pablo Galindo Salgado2021-07-311-221/+446
|
* bpo-34013: Move the Python 2 hints from the exception constructor to the ↵Pablo Galindo Salgado2021-07-271-3/+4
| | | | parser (GH-27392)
* bpo-34013: Generalize the invalid legacy statement error message (GH-27389)Pablo Galindo Salgado2021-07-271-1/+6
|
* Remove unnecessary 'invalid_primary' rule in the parser (GH-27186)Pablo Galindo Salgado2021-07-161-3/+0
|
* bpo-44456: Improve the syntax error when mixing keyword and positional ↵Pablo Galindo2021-06-241-0/+8
| | | | patterns (GH-26793)
* bpo-44368: Improve syntax errors with invalid as pattern targets (GH-26632)Pablo Galindo2021-06-101-0/+4
|
* bpo-44385: Remove unused grammar rules (GH-26655)Lysandros Nikolaou2021-06-101-11/+0
| | | Automerge-Triggered-By: GH:lysnikolaou
* bpo-44305: Improve syntax error for try blocks without except or finally ↵Pablo Galindo2021-06-031-0/+1
| | | | (GH-26523)
* bpo-44180: Fix edge cases in invalid assigment rules in the parser (GH-26283)Pablo Galindo2021-05-211-14/+24
| | | | | | | | | | | | | | | 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-44168: Fix error message in the parser for keyword arguments for invalid ↵Pablo Galindo2021-05-191-1/+1
| | | | expressions (GH-26210)
* bpo-43149: Correct the syntax error message for multiple exception types ↵Pablo Galindo2021-05-081-1/+1
| | | | | (GH-25996) Automerge-Triggered-By: GH:pablogsal
* bpo-43892: Validate the first term of complex literal value patterns (GH-25735)Brandt Bucher2021-04-301-6/+15
|
* bpo-43892: Make match patterns explicit in the AST (GH-25585)Nick Coghlan2021-04-291-54/+101
| | | Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
* bpo-43914: Highlight invalid ranges in SyntaxErrors (#25525)Pablo Galindo2021-04-231-24/+27
| | | | | | | | | | | | | | | | | 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
* bpo-43859: Improve the error message for IndentationError exceptions (GH-25431)Pablo Galindo2021-04-211-12/+58
|
* bpo-43823: Fix location of one of the errors for invalid dictionary literals ↵Pablo Galindo2021-04-151-1/+2
| | | | (GH-25427)
* bpo-43822: Improve syntax errors for missing commas (GH-25377)Pablo Galindo2021-04-152-0/+10
|
* bpo-43823: Improve syntax errors for invalid dictionary literals (GH-25378)Pablo Galindo2021-04-151-0/+11
|
* bpo-43797: Handle correctly invalid assignments inside function calls and ↵Pablo Galindo2021-04-131-1/+1
| | | | generators (GH-25390)
* Ensure that early = are not matched by the parser as invalid comparisons ↵Pablo Galindo2021-04-131-1/+5
| | | | (GH-25375)
* bpo-43797: Improve syntax error for invalid comparisons (#25317)Pablo Galindo2021-04-121-9/+24
| | | | | | | | | | | | | * 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>
* bpo-43798: Add source location attributes to alias (GH-25324)Matthew Suozzo2021-04-101-3/+3
| | | | | | | * 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>
* bpo-43244: Rename pycore_ast.h functions to _PyAST_xxx() (GH-25252)Victor Stinner2021-04-071-148/+148
| | | | | | 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.
* bpo-41064: Improve syntax error for invalid usage of '**' in f-strings ↵Pablo Galindo2021-03-241-0/+2
| | | | (GH-25006)
* bpo-42128: Add 'missing :' syntax error message to match statements (GH-24733)Pablo Galindo2021-03-181-0/+8
|
* bpo-42128: Structural Pattern Matching (PEP 634) (GH-22917)Brandt Bucher2021-02-261-1/+110
| | | | | Co-authored-by: Guido van Rossum <guido@python.org> Co-authored-by: Talin <viridia@gmail.com> Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* bpo-43149: Improve error message for exception group without parentheses ↵Pablo Galindo2021-02-071-2/+9
| | | | (GH-24467)
* bpo-43121: Fix incorrect SyntaxError message for missing comma (GH-24436)Pablo Galindo2021-02-031-1/+1
|
* bpo-42997: Improve error message for missing : before suites (GH-24292)Pablo Galindo2021-02-021-16/+22
| | | | | | | | * 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.
* bpo-43017: Improve error message for unparenthesised tuples in ↵Pablo Galindo2021-01-311-3/+5
| | | | comprehensions (GH24314)
* bpo-42860: Remove type error from grammar (GH-24156)Lysandros Nikolaou2021-01-071-2/+8
| | | | | | 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
* bpo-40631: Disallow single parenthesized star target (GH-24027)Lysandros Nikolaou2021-01-021-4/+9
|
* bpo-30858: Improve error location for expressions with assignments (GH-23753)Pablo Galindo2020-12-131-1/+1
| | | Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
* Refactor the grammar to match the language specification docs (GH-23574)Pablo Galindo2020-11-301-7/+7
|
* bpo-42381: Allow walrus in set literals and set comprehensions (GH-23332)Pablo Galindo2020-11-171-3/+2
| | | | | | | | | | | 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
* bpo-42316: Allow unparenthesized walrus operator in indexes (GH-23317)Lysandros Nikolaou2020-11-161-1/+1
|
* bpo-42374: Allow unparenthesized walrus in genexps (GH-23319)Lysandros Nikolaou2020-11-161-1/+1
| | | | | This fixes a regression that was introduced by the new parser. Automerge-Triggered-By: GH:lysnikolaou
* bpo-42214: Fix check for NOTEQUAL token in the PEG parser for the ↵Pablo Galindo2020-10-301-1/+1
| | | | barry_as_flufl rule (GH-23048)
* bpo-41659: Disallow curly brace directly after primary (GH-22996)Lysandros Nikolaou2020-10-271-0/+3
|
* bpo-42123: Run the parser two times and only enable invalid rules on the ↵Lysandros Nikolaou2020-10-261-2/+2
| | | | | | | | | | 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.
* bpo-41746: Cast to typed seqs in CHECK macros to avoid type erasure (GH-22864)Lysandros Nikolaou2020-10-211-38/+57
|
* bpo-41979: Accept star-unpacking on with-item targets (GH-22611)Batuhan Taskaya2020-10-091-1/+1
| | | Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-41746: Add type information to asdl_seq objects (GH-22223)Pablo Galindo2020-09-161-61/+61
| | | | | | | | | | | | | * 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.
* bpo-41697: Correctly handle KeywordOrStarred when parsing arguments in the ↵Pablo Galindo2020-09-031-1/+1
| | | | parser (GH-22077)
* bpo-41690: Use a loop to collect args in the parser instead of recursion ↵Pablo Galindo2020-09-021-12/+1
| | | | | | | | | | | | | | | | | | | | | (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 }] { [...] }
* bpo-40939: Use the new grammar for the grammar specification documentation ↵Pablo Galindo2020-07-271-206/+0
| | | | | | | (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>