Module

parser.blocks.variables

Variable block parsing for Kida parser.

Provides mixin for parsing variable assignment statements (set, let, export).

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

Classes

VariableBlockParsingMixin 4
Mixin for parsing variable assignment blocks. Host attributes and cross-mixin dependencies are dec…

Mixin for parsing variable assignment blocks.

Host attributes and cross-mixin dependencies are declared via inline TYPE_CHECKING blocks. Inherits block stack management from BlockStackMixin.

Methods

Internal Methods 4
_parse_set 0 list[Set]
Parse {% set x = expr %} or {% set x = 1, y = 2, z = 3 %}. Multi-set syntax al…
def _parse_set(self) -> list[Set]

Parse {% set x = expr %} or {% set x = 1, y = 2, z = 3 %}.

Multi-set syntax allows comma-separated independent assignments: {% set a = 1, b = 2, c = 3 %}

Tuple unpacking remains unchanged: {% set a, b = 1, 2 %}

IMPORTANT: For multi-set, uses _parse_expression() (not _parse_tuple_or_expression()) to prevent commas from being consumed as tuple elements.

Returns
list[Set] List of Set nodes (one per assignment in multi-set, or single for regular set).
_is_multi_set_continuation 0 bool
Check if comma is followed by 'NAME =' pattern (multi-set). Uses 2-token looka…
def _is_multi_set_continuation(self) -> bool

Check if comma is followed by 'NAME =' pattern (multi-set).

Uses 2-token lookahead without consuming tokens.

Returns True for: a = 1, b = 2 Returns False for: a = 1, 2, 3 (tuple value) Returns False for: a = 1, (trailing comma)

Returns
bool
_parse_let 0 Let | list[Let]
Parse {% let x = expr %} or {% let x = 1, y = 2, z = 3 %}. Multi-let syntax al…
def _parse_let(self) -> Let | list[Let]

Parse {% let x = expr %} or {% let x = 1, y = 2, z = 3 %}.

Multi-let syntax allows comma-separated independent assignments: {% let a = 1, b = 2, c = 3 %}

Supports tuple unpacking: {% let a, b = 1, 2 %}

Returns
Let | list[Let] Single Let node or list of Let nodes for multi-let.
_parse_export 0 Export
Parse {% export x = expr %}. Supports tuple unpacking: {% export a, b = 1,…
def _parse_export(self) -> Export

Parse {% export x = expr %}.

Supports tuple unpacking:

{% export a, b = 1, 2 %}
Returns
Export