DotPrompt. AST
(anantha_dot_prompt v1.1.0)
Copy Markdown
AST node handlers for the DotPrompt compiler.
Purpose
Provides recursive compilation functions for each AST node type produced
by the DotPrompt parser. Each handle_* function processes a specific
node (text, if, case, vary, fragment) and returns compiled output along
with tracking state (vary map, used variables, file metadata).
Key Functions
handle_text_node/3— Interpolates@paramreferences in raw texthandle_if_node/6— Compiles conditional branches and emits section annotations for traceabilityhandle_case_node/4— Compiles case/match branches with section annotationshandle_vary_node/4— Compiles all vary branches for at-runtime selectionhandle_static_fragment/3— Expands static{fragment}includeshandle_dynamic_fragment/3— Expands dynamic{{fragment}}includesextract_vary_vars/1— Collects all vary variable names from the AST
Internal Use
This module is called by DotPrompt.Compiler.compile_ast/2 during the
compilation phase. Each handler recursively compiles child nodes and
accumulates state through a reduce-while pattern.