compiler/stage2_l0/src/ast_printer.l0
Module ast_printer
Overview Symbols grouped by source file: compiler/stage2_l0/src/ast_printer.l0
Module: ast_printer
Source: compiler/stage2_l0/src/ast_printer.l0 Language: Dea/L0
Imports / Includes
parseraststd.vectorstd.textstd.stringstd.io
Symbols
- ap_bool_str
- ap_span_suffix
- ap_indent_str
- ap_print_line
- ap_print_label
- ap_quote_string
- ap_module_prefix
- ap_full_name
- ap_print_type_ref
- ap_print_import
- ap_print_param
- ap_print_field_decl
- ap_print_enum_variant
- ap_print_pattern
- ap_print_expr
- ap_print_stmt
- ap_print_func_decl
- ap_print_struct_decl
- ap_print_enum_decl
- ap_print_type_alias_decl
- ap_print_let_decl
- ap_print_top_level_decl
- ap_print_module
Function ap_bool_str
func ap_bool_str(b: bool) -> string
Return "True" or "False" for a boolean value.
Parameters:
b: Boolean value.
Returns: String representation matching Python repr(bool) style.
Function ap_span_suffix
func ap_span_suffix(span: Span) -> string
Build a span-suffix annotation string @sl:sc-el:ec .
Parameters:
span: Source span.
Returns: Formatted span annotation.
Function ap_indent_str
func ap_indent_str(n: int) -> string
Build an indentation prefix string (2 spaces per level).
Parameters:
n: Indent level.
Returns: Indentation string.
Function ap_print_line
func ap_print_line(indent: int, text: string)
Print a line at the given indent level.
Parameters:
indent: Indent level (2 spaces each).text: Text to print after the indentation.
Function ap_print_label
func ap_print_label(indent: int, name: string)
Print a child-field label at indent + 1 .
Parameters:
indent: Parent node indent level.name: Label name without colon.
Function ap_quote_string
func ap_quote_string(s: string) -> string
Return a single-quoted escaped representation of a string.
Parameters:
s: String to quote.
Returns: Single-quoted escaped string.
Function ap_module_prefix
func ap_module_prefix(module_path: StringVector*?) -> string
Build the module qualifier prefix from an optional path vector.
For a module path ["std", "io"] this returns "std.io::" . Returns "" when the path is null or empty.
Parameters:
module_path: Optional module path segments.
Returns: Formatted prefix ending with "::", or empty string.
Function ap_full_name
func ap_full_name(text_value: string, module_path: StringVector*?, name_qualifier: StringVector*?) -> string
Build the full qualified name for a variable reference or similar node.
Combines module_path, name_qualifier segments, and the local name into a display string like "std.io::SomeType" or "Enum::Variant" .
Parameters:
text_value: Base name.module_path: Optional module path segments.name_qualifier: Optional name qualifier segments.
Returns: Fully qualified display name.
Function ap_print_type_ref
func ap_print_type_ref(tr: TypeRef*, indent: int)
Print a type reference node.
Parameters:
tr: Type reference to print.indent: Indent level.
Function ap_print_import
func ap_print_import(imp: Import*, indent: int)
Print an import node.
Parameters:
imp: Import to print.indent: Indent level.
Function ap_print_param
func ap_print_param(p: Param*, indent: int)
Print a parameter node, including its type annotation.
Parameters:
p: Parameter to print.indent: Indent level.
Function ap_print_field_decl
func ap_print_field_decl(fd: FieldDecl*, indent: int)
Print a field declaration node.
Parameters:
fd: Field declaration to print.indent: Indent level.
Function ap_print_enum_variant
func ap_print_enum_variant(ev: EnumVariant*, indent: int)
Print an enum variant node, including any payload fields.
Parameters:
ev: Enum variant to print.indent: Indent level.
Function ap_print_pattern
func ap_print_pattern(id: PatternId, pr: ParseResult*, indent: int)
Print a pattern node by arena id.
Parameters:
id: Pattern id in the arena.pr: Parse result providing the pattern arena.indent: Indent level.
Function ap_print_expr
func ap_print_expr(id: ExprId, pr: ParseResult*, indent: int)
Print an expression node by arena id.
Recursively prints child expressions and child type references.
Parameters:
id: Expression id in the arena.pr: Parse result providing the expression arena.indent: Indent level.
Function ap_print_stmt
func ap_print_stmt(id: StmtId, pr: ParseResult*, indent: int)
Print a statement node by arena id.
Recursively prints child statements, expressions, and patterns.
Parameters:
id: Statement id in the arena.pr: Parse result providing all AST arenas.indent: Indent level.
Function ap_print_func_decl
func ap_print_func_decl(fd: FuncDecl*, pr: ParseResult*, indent: int)
Print a function declaration including params, return type, and body.
Parameters:
fd: Function declaration to print.pr: Parse result providing statement arenas.indent: Indent level.
Function ap_print_struct_decl
func ap_print_struct_decl(sd: StructDecl*, indent: int)
Print a struct declaration including its fields.
Parameters:
sd: Struct declaration to print.indent: Indent level.
Function ap_print_enum_decl
func ap_print_enum_decl(ed: EnumDecl*, indent: int)
Print an enum declaration including its variants.
Parameters:
ed: Enum declaration to print.indent: Indent level.
Function ap_print_type_alias_decl
func ap_print_type_alias_decl(ta: TypeAliasDecl*, indent: int)
Print a type-alias declaration.
Parameters:
ta: Type-alias declaration to print.indent: Indent level.
Function ap_print_let_decl
func ap_print_let_decl(ld: LetDecl*, pr: ParseResult*, indent: int)
Print a top-level let declaration.
Parameters:
ld: Let declaration to print.pr: Parse result providing expression arenas.indent: Indent level.
Function ap_print_top_level_decl
func ap_print_top_level_decl(tld: TopLevelDecl*, pr: ParseResult*, indent: int)
Dispatch to the correct per-kind declaration printer.
Parameters:
tld: Top-level declaration wrapper.pr: Parse result providing all AST arenas.indent: Indent level.
Function ap_print_module
func ap_print_module(mod: Module*, pr: ParseResult*)
Print the AST of a parsed module.
Mirrors the Stage 1 format_module() output contract:
- Module header with scalar fields and span on one line.
- imports: label and each Import child at indent 2.
- decls: label and each top-level declaration at indent 2.
- Empty imports or decls lists are omitted (no label printed).
Parameters:
mod: Module to print.pr: Parse result providing all AST arenas (expr, stmt, pattern).