I'm currently looking at the work done to write the Python 3.8 grammar with Lark, and I'm wondering how that can be done with the Python 3.9 grammar specification which looks a bit simpler to me. Note that I'm not sure of whether my approach described below is correct or not.
In the Python 3.9 grammar specification, we have rules that use a negative lookahead like this one:
named_expression:
| NAME ':=' ~ expression
| expression !':=' <--- This rule
I've tried to use a regex to define this negative lookahead like this:
negative_lookahead: /(?!:=)/
But it generates the following exception: LexError: Lexer does not allow zero-width terminals.
Is there a way to define lookaheads with Lark?