# core

URL: /kida/api/parser/blocks/core/
Section: blocks
Description: Core block stack management for Kida parser.

Provides base mixin for managing block stack and unified {% end %} syntax.

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/core/index.txt)

Share with AI

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

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

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

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

Module

#
`parser.blocks.core`

Core block stack management for Kida parser.

Provides base mixin for managing block stack and unified {% end %} syntax.

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

1Class

## Classes

`BlockStackMixin`

9

▼

Mixin for block stack management.

Host attributes and cross-mixin dependencies are declared via in…

Mixin for block stack management.

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

#### Attributes

Name
Type
Description

`_end_keywords`

`frozenset[str]`

—

`_END_KEYWORDS`

`frozenset[str]`

—

`_CONTINUATION_KEYWORDS`

`frozenset[str]`

—

`_LOOP_BLOCKS`

`frozenset[str]`

—

#### Methods

Internal Methods
5

▼

`_push_block`

2

▼

Push a block onto the stack when opening it.

`def _push_block(self, block_type: str, token: Token | None = None) -> None`

##### Parameters

Name
Type
Description

`block_type`
`—`

Type of block (if, for, def, etc.)

`token`
`—`

Token for error reporting (defaults to current token)

Default:`None`

`_pop_block`

1

`str`

▼

Pop a block from the stack when closing it.

`def _pop_block(self, expected: str | None = None) -> str`

##### Parameters

Name
Type
Description

`expected`
`—`

If provided, validates that the closing block matches. Use None to accept any block type (unified {% end %}).

Default:`None`

##### Returns

`str`

The block type that was popped.

`_format_open_blocks`

0

`str`

▼

Format the current block stack for error messages.

`def _format_open_blocks(self) -> str`

##### Returns

`str`

`_in_loop`

0

`bool`

▼

Check if currently inside a loop block.

Used by break/continue to validate the…

`def _in_loop(self) -> bool`

Check if currently inside a loop block.

Used by break/continue to validate they are inside a loop.
Part of RFC: kida-modern-syntax-features.

##### Returns

`bool`

`_consume_end_tag`

1

▼

Consume an end tag ({% end %} or {% endXXX %}) and pop from stack.

`def _consume_end_tag(self, block_type: str) -> None`

##### Parameters

Name
Type
Description

`block_type`
`—`

The expected block type being closed. This method handles both unified {% end %} and explicit {% endif %} etc.
