pyk.kast.pretty module¶
- class PrettyPrinter(definition: KDefinition, extra_unparsing_modules: Iterable[KFlatModule] = (), patch_symbol_table: Callable[[SymbolTable], None] | None = None, unalias: bool = True, sort_collections: bool = False)[source]¶
Bases:
object
- definition: KDefinition¶
- print(kast: KAst) str [source]¶
Print out KAST terms/outer syntax. - Input: KAST term. - Output: Best-effort string representation of KAST term.
- property symbol_table: dict[str, Callable[[...], str]]¶
- build_symbol_table(definition: KDefinition, extra_modules: Iterable[KFlatModule] = (), opinionated: bool = False) SymbolTable [source]¶
Build the unparsing symbol table given a JSON encoded definition.
Input: JSON encoded K definition.
Return: Python dictionary mapping klabels to automatically generated unparsers.
- unparser_for_production(prod: KProduction) Callable[[...], str] [source]¶