AST and Bytecode Tools
Edit this pageInspect parser and compiler output using AST and bytecode CLI tools.
PYRS includes built-in inspection modes for parser and compiler debugging.
Inspection Flags
| Flag | Output |
|---|---|
—ast path.py | Parses source and prints the module AST structure. |
—bytecode path.py | Compiles source and prints disassembly of emitted code objects. |
PYRS_BYTECODE_SHOW_TABLES=1 | Includes names/constants tables in disassembly output. |
Common Commands
Shell
$ pyrs --ast path/to/script.py $ pyrs --bytecode path/to/script.py $ PYRS_BYTECODE_SHOW_TABLES=1 pyrs --bytecode path/to/script.py When To Use Each Tool
| Use case | Recommended mode |
|---|---|
| Validate parser behavior and syntax lowering | —ast |
| Debug opcode emission and nested code-object structure | —bytecode |
| Inspect compiler constant/name indexing details | —bytecode + PYRS_BYTECODE_SHOW_TABLES=1 |