Skip to content

Parser Pipeline

This page describes how custom Tython syntax is processed internally.

parse_custom Flow

  1. Normalize source input.
  2. Rewrite custom syntax:
  3. strict import forms (import pkg/mod as alias, import "./file.ty" as alias, pyimport module [as alias])
  4. brace blocks ({})
  5. func declarations
  6. checked error syntax (throws, catch, try expr)
  7. record declarations and literals
  8. class declarations (init, setup, pub, is)
  9. enums
  10. const / var binding declarations
  11. lowercase literals (true, false, none)
  12. Parse rewritten code into Python AST.
  13. Run semantic checks (scope, naming, mutability, declarations, conservative typing, class/record conformance).
  14. Lower custom IR nodes (bindings, enums, records/classes, record literals, strict imports) into final Python AST.

Stable Public API

The parser-facing API remains:

  • parse
  • parse_custom
  • lower

from parser/core.py.