# variables

URL: /kida/api/parser/blocks/variables/
Section: blocks
Description: 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

---

> For a complete page index, fetch /kida/llms.txt.

Open LLM text
(/kida/api/parser/blocks/variables/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fparser%2Fblocks%2Fvariables%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fparser%2Fblocks%2Fvariables%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fparser%2Fblocks%2Fvariables%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fparser%2Fblocks%2Fvariables%2Findex.txt)

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

1Class

## 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 ??= expr %} or {% set x = 1, y = 2, z = 3 …

`def _parse_set(self) -> list[Set]`

Parse {% set x = expr %} or {% 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 %}

Nullish assignment (??=) assigns only if the variable is undefined or None:
{% set x ??= "default" %}

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 =' or 'NAME ??=' pattern (multi-set).

Uses…

`def _is_multi_set_continuation(self) -> bool`

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

Uses 2-token lookahead without consuming tokens.

Returns True for: a = 1, b = 2
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 ??= expr %}.

Multi-let syntax allows comm…

`def _parse_let(self) -> Let | list[Let]`

Parse {% let x = expr %} or {% let x ??= expr %}.

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

Nullish assignment (??=) assigns only if the variable is undefined or None:
{% let x ??= "default" %}

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 %} or {% export x ??= expr %}.

Supports tuple unpacki…

`def _parse_export(self) -> Export`

Parse {% export x = expr %} or {% export x ??= expr %}.

Supports tuple unpacking:

```
{% export a, b = 1, 2 %}
```

Nullish assignment (??=) exports only if the variable is undefined or None:
{% export x ??= "default" %}

##### Returns

`Export`
