Python parser #4

Merged
HEL merged 27 commits from feat/python-parser into main 2026-05-26 08:28:42 +00:00
Owner

This PR adds a simple parser which takes in a Python Module (an AST node) and converts it to our own internal AST structure.
This is done for two reasons:

  • Parse custom type annotation into a more semantically explicit structure (Frame[name: Type] is a Frame with a column named name of type Type, not a subscript with a slice)
  • Simplify Python constructs to expose typed operations (e.g. assignments, annotations, function definitions and calls, etc.)

The latter might not be fully required, as it involves a lot of redundancy with Python's own AST nodes, but it provides a more consistent interface with custom types

This PR also adds a utility gen/gen.py script to help generate AST node classes from simple templates.
Finally, it also adds a new utility command midas utils highlight -o OUTPUT SOURCE_FILE which runs the Midas or Python parser against the provided source file and outputs the highlighted code as a standalone HTML file.

This PR adds a simple parser which takes in a Python Module (an AST node) and converts it to our own internal AST structure. This is done for two reasons: - Parse custom type annotation into a more semantically explicit structure (`Frame[name: Type]` is a `Frame` with a column named `name` of type `Type`, not a subscript with a slice) - Simplify Python constructs to expose typed operations (e.g. assignments, annotations, function definitions and calls, etc.) The latter might not be fully required, as it involves a lot of redundancy with Python's own AST nodes, but it provides a more consistent interface with custom types This PR also adds a utility `gen/gen.py` script to help generate AST node classes from simple templates. Finally, it also adds a new utility command `midas utils highlight -o OUTPUT SOURCE_FILE` which runs the Midas or Python parser against the provided source file and outputs the highlighted code as a standalone HTML file.
HEL self-assigned this 2026-05-26 08:27:48 +00:00
HEL added 27 commits 2026-05-26 08:27:48 +00:00
make the generation script more flexible
use the generation script to create Python AST node classes, also distinguish between Midas type annotation nodes and statements
remove the parent NodeVisitor class from PythonParser and implement all custom recursive methods instead
HEL merged commit ec079f32ca into main 2026-05-26 08:28:42 +00:00
HEL deleted branch feat/python-parser 2026-05-26 08:28:42 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: HEL/midas#4