Skip to content

Modules

module what it derives
grammar the declaration itself, and every structural query
lang_py Python's grammar: roles authored, sorts and shapes from ast._field_types
lang_ssa a read-only mirror of a typed SSA IR, as evidence one notation covers both a tree and a flat IR
rewriting the rule engine; target_fields gives fix_contexts its binding positions
scopes the scope tree and the names each block binds, from roles plus a scope-layer list
hygiene fresh names, renaming across every declared slot, capture-avoiding substitution
coverage what a dispatch table covers of a grammar, and what it does not
emit / emit_py documents, and brackets from a precedence table
emit_rules emission as guarded rules over the grammar
tables Family, for the tables no grammar derives
generate programs exercising every declared position, with missing_coverage as the obligation

Entry points

from astero import Pass, Match, rules, rewrite      # the rule engine
from astero.grammar import Grammar, from_dataclasses, defines, uses, Present, Absent
from astero.lang_py import PY, VARS, build
from astero.scopes import scope_tree, bound_names
from astero.hygiene import substitute, rename, Fresh, free_names
from astero.coverage import Coverage, dispatch, handlers, match_arms
from astero.emit_rules import Emitter, All, Both, Either, Not, Is, OpIs, Const, Has
from astero.emit import Level, Assoc, needs_parens
from astero.tables import Family

Version sensitivity

_field_types is 3.13+, so on earlier interpreters shapes are UNKNOWN. Comprehensions stopped opening scopes in 3.12 (PEP 709). PEP 695 type-parameter blocks are spelled type parameter on 3.12 and type parameters from 3.13. PEP 649 adds annotation blocks from 3.14. symtable.get_type() returns a string before 3.13 and an enum after.

astero is tested on 3.11 through 3.15.