Module

compiler.statements.basic

Basic statement compilation for Kida compiler.

Provides mixin for compiling basic output statements (data, output).

Uses inline TYPE_CHECKING declarations for host attributes. See: plan/rfc-mixin-protocol-typing.md

Classes

BasicStatementMixin 3
Mixin for compiling basic output statements. Host attributes and cross-mixin dependencies are decl…

Mixin for compiling basic output statements.

Host attributes and cross-mixin dependencies are declared via inline TYPE_CHECKING blocks.

Methods

Internal Methods 3
_compile_data 1 list[ast.stmt]
Compile raw text data. StringBuilder mode: _append("literal text") Streaming m…
def _compile_data(self, node: Data) -> list[ast.stmt]

Compile raw text data.

StringBuilder mode: _append("literal text") Streaming mode: yield "literal text"

Parameters
Name Type Description
node
Returns
list[ast.stmt]
_expr_may_produce_none 1 bool
Check if an expression involves optional chaining that may produce None. When …
staticmethod
def _expr_may_produce_none(node: Expr) -> bool

Check if an expression involves optional chaining that may produce None.

When optional chaining (?., ?[, ?|>) is the outermost expression in {{ ... }} output (not wrapped in ??), str(None) renders as "None". We detect this and use _str_safe to render "" instead.

Parameters
Name Type Description
node
Returns
bool
_compile_output 1 list[ast.stmt]
Compile {{ expression }} output. StringBuilder mode: _append(_e(expr)) or _app…
def _compile_output(self, node: Output) -> list[ast.stmt]

Compile {{ expression }} output.

StringBuilder mode: _append(_e(expr)) or _append(_s(expr)) Streaming mode: yield _e(expr) or yield _s(expr)

When the expression involves optional chaining (?., ?[) without null coalescing (??), uses _str_safe instead of _s so that None renders as "" instead of "None".

Parameters
Name Type Description
node
Returns
list[ast.stmt]