lexanth / python-ast

Python (3) Parser for JavaScript/TypeScript (based on antlr4ts)
MIT License
14 stars 5 forks source link

Walrus operator throws #3

Open artificial-smahon opened 1 year ago

artificial-smahon commented 1 year ago

Parsing python that uses the walrus operator is throwing errors.

if e := tc.get("exception"):

line 78:18 extraneous input '=' expecting {STRING, NUMBER, 'return', 'raise', 'from', 'import', 'global', 'nonlocal', 'assert', 'lambda', 'not', 'None', 'True', 'False', 'yield', 'del', 'pass', 'continue', 'break', 'await', NEWLINE, NAME, '...', '*', '(', '[', '+', '-', '~', '{'}

lexanth commented 1 year ago

This package just wraps the grammar from https://github.com/antlr/grammars-v4/tree/master/python/python3-ts

That hasn't been updated to support newer syntax yet - once it has been, I'll update this package to support it.

RobEin commented 1 year ago

I recommend these two parsers: https://github.com/RobEin/ANTLR4-Python-grammar-by-PEG https://github.com/RobEin/ANTLR4-parser-for-Python-3.8.12