Parse Python 3.9+ parenthesized context managers

Since the upstream grammar for this is not LR(1), we abuse LALRPOP
macros and the Into/TryInto traits to build a cover grammar that
converts to either tuples or `with` items after additional validation.
It’s annoying and ugly, but something like this is basically our only
option short of switching to a more powerful parser algorithm.

Fixes #4145.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg 2022-12-11 02:55:56 -08:00
parent 751f9d304f
commit 052dee72b8
4 changed files with 2412 additions and 85 deletions

View file

@ -33,3 +33,4 @@ mod python;
mod context;
mod string;
pub mod token;
mod with;