# statements URL: /api/parser/statements/ Section: parser -------------------------------------------------------------------------------- statements - Kida window.BENGAL_THEME_DEFAULTS = { appearance: 'light', palette: 'brown-bengal' }; window.Bengal = window.Bengal || {}; window.Bengal.enhanceBaseUrl = '/kida/assets/js/enhancements'; window.Bengal.watchDom = true; window.Bengal.debug = false; window.Bengal.enhanceUrls = { 'toc': '/kida/assets/js/enhancements/toc.632a9783.js', 'docs-nav': '/kida/assets/js/enhancements/docs-nav.57e4b129.js', 'tabs': '/kida/assets/js/enhancements/tabs.aac9e817.js', 'lightbox': '/kida/assets/js/enhancements/lightbox.1ca22aa1.js', 'interactive': '/kida/assets/js/enhancements/interactive.fc077855.js', 'mobile-nav': '/kida/assets/js/enhancements/mobile-nav.d991657f.js', 'action-bar': '/kida/assets/js/enhancements/action-bar.d62417f4.js', 'copy-link': '/kida/assets/js/enhancements/copy-link.7d9a5c29.js', 'data-table': '/kida/assets/js/enhancements/data-table.1f5bc1eb.js', 'lazy-loaders': '/kida/assets/js/enhancements/lazy-loaders.a5c38245.js', 'holo': '/kida/assets/js/enhancements/holo.ee13c841.js', 'link-previews': '/kida/assets/js/enhancements/link-previews.8d906535.js' }; (function () { try { var defaults = window.BENGAL_THEME_DEFAULTS || { appearance: 'system', palette: '' }; var defaultAppearance = defaults.appearance; if (defaultAppearance === 'system') { defaultAppearance = (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) ? 'dark' : 'light'; } var storedTheme = localStorage.getItem('bengal-theme'); var storedPalette = localStorage.getItem('bengal-palette'); var theme = storedTheme ? (storedTheme === 'system' ? defaultAppearance : storedTheme) : defaultAppearance; var palette = storedPalette ?? defaults.palette; document.documentElement.setAttribute('data-theme', theme); if (palette) { document.documentElement.setAttribute('data-palette', palette); } } catch (e) { document.documentElement.setAttribute('data-theme', 'light'); } })(); { "prerender": [ { "where": { "and": [ { "href_matches": "/docs/*" }, { "not": { "selector_matches": "[data-external], [target=_blank], .external" } } ] }, "eagerness": "conservative" } ], "prefetch": [ { "where": { "and": [ { "href_matches": "/*" }, { "not": { "selector_matches": "[data-external], [target=_blank], .external" } } ] }, "eagerness": "conservative" } ] } Skip to main content Magnifying Glass ESC Recent Clear Magnifying Glass No results for "" Start typing to search... ↑↓ Navigate ↵ Open ESC Close Powered by Lunr )彡 DocumentationInfoAboutArrow ClockwiseGet StartedCodeSyntaxTerminalUsageNoteTutorialsStarburstExtendingBookmarkReferenceTroubleshootingReleasesDevGitHubKida API Reference Magnifying Glass Search ⌘K Palette Appearance Chevron Down Mode Monitor System Sun Light Moon Dark Palette Snow Lynx Brown Bengal Silver Bengal Charcoal Bengal Blue Bengal List )彡 Magnifying Glass Search X Close Documentation Caret Down Info About Arrow Clockwise Get Started Code Syntax Terminal Usage Note Tutorials Starburst Extending Bookmark Reference Troubleshooting Releases Dev Caret Down GitHub Kida API Reference Palette Appearance Chevron Down Mode Monitor System Sun Light Moon Dark Palette Snow Lynx Brown Bengal Silver Bengal Charcoal Bengal Blue Bengal Kida API Reference Caret Right Analysis analyzer cache config dependencies landmarks metadata purity roles Caret Right Compiler Caret Right Statements basic control_flow functions special_blocks template_structure variables _protocols coalescing core expressions utils Caret Right Environment core exceptions filters loaders protocols registry tests Caret Right Parser Caret Right Blocks control_flow core functions special_blocks template_structure variables _protocols core errors expressions statements tokens Caret Right Utils html lru_cache workers _types bytecode_cache kida lexer nodes template tstring Kida API ReferenceParser ᗢ Caret Down Link Copy URL External Open LLM text Copy Copy LLM text Share with AI Ask Claude Ask ChatGPT Ask Gemini Ask Copilot Module parser.statements Statement parsing for Kida parser. Provides mixin for parsing template statements (body, data, output, blocks). Uses inline TYPE_CHECKING declarations for host attributes. See: plan/rfc-mixin-protocol-typing.md 1Class Classes StatementParsingMixin 15 ▼ Mixin for parsing template statements. Host attributes and cross-mixin dependencies are declared v… Mixin for parsing template statements. Host attributes and cross-mixin dependencies are declared via inline TYPE_CHECKING blocks. Attributes Name Type Description _END_KEYWORDS frozenset[str] — _CONTINUATION_KEYWORDS frozenset[str] — Methods Internal Methods 13 ▼ _parse_body 1 list[Node] ▼ Parse template body until an end tag or EOF. Uses universal end detection: sto… def _parse_body(self, stop_on_continuation: bool = False) -> list[Node] Parse template body until an end tag or EOF. Uses universal end detection: stops on ANY end keyword (end, endif, endfor, enddef, etc.) or continuation keyword (else, elif, empty) if stop_on_continuation is True. This enables the unified {% end %} syntax where {% end %} always closes the innermost open block. Parameters Name Type Description stop_on_continuation — If True, also stop on else/elif/empty keywords. Used by if/for blocks that have continuation clauses. Default: False Returns list[Node] List of parsed nodes. _parse_data 0 Data ▼ Parse raw text data. def _parse_data(self) -> Data Returns Data _parse_output 0 Output ▼ Parse {{ expression }}. def _parse_output(self) -> Output Returns Output _parse_block 0 Node | list[Node] | None ▼ Parse {% ... %} block tag. def _parse_block(self) -> Node | list[Node] | None Returns Node | list[Node] | None - Single Node for most blocks - list[Node] for multi-set ({% set a = 1, b = 2 %}) - None for end tags _parse_block_content 0 Node | list[Node] | None ▼ Parse block content after BLOCK_BEGIN is consumed. This is split from _parse_b… def _parse_block_content(self) -> Node | list[Node] | None Parse block content after BLOCK_BEGIN is consumed. This is split from _parse_block so it can be reused in contexts where BLOCK_BEGIN is already consumed (e.g., inside function bodies). Uses dispatch table pattern for O(1) keyword lookup instead of 20+ elif branches. See RFC: rfc-code-smell-remediation.md §1.1 Returns Node | list[Node] | None - Single Node for most blocks - list[Node] for multi-set ({% set a = 1, b = 2 %}) - None for end tags _handle_end_keyword 1 ▼ Handle end keywords (endif, endfor, end, etc.). def _handle_end_keyword(self, keyword: str) -> None Parameters Name Type Description keyword — The end keyword being processed Returns None None for valid end tags (signals parent to close block) _skip_comment 0 ▼ Skip comment block. def _skip_comment(self) -> None _get_eof_error_suggestion 1 str ▼ Generate improved error suggestion for EOF errors in blocks. Checks for unclos… def _get_eof_error_suggestion(self, block_type: str) -> str Generate improved error suggestion for EOF errors in blocks. Checks for unclosed comments and provides helpful suggestions. Parameters Name Type Description block_type — Returns str _check_unclosed_comment 0 tuple[int, int] | None ▼ Check for unclosed comment in the source. Scans the source for {# without matc… def _check_unclosed_comment(self) -> tuple[int, int] | None Check for unclosed comment in the source. Scans the source for {# without matching #}. Returns (line, col) of unclosed comment start if found, None otherwise. Returns tuple[int, int] | None _parse_tuple_or_name 0 Expr ▼ Parse assignment target (variable or tuple for unpacking). Used by set/let/exp… def _parse_tuple_or_name(self) -> Expr Parse assignment target (variable or tuple for unpacking). Used by set/let/export for patterns like: x (single variable) a, b (comma-separated before '=') (a, b) (parenthesized tuple) (a, b), c (nested/mixed) Returns Expr _parse_tuple_or_expression 0 Expr ▼ Parse expression that may be an implicit tuple. Used for value side of set sta… def _parse_tuple_or_expression(self) -> Expr Parse expression that may be an implicit tuple. Used for value side of set statements like: {% set a, b = 1, 2 %} The value 1, 2 is parsed as a tuple without parentheses. Returns Expr _parse_tuple_or_null_coalesce_no_ternary 0 Expr ▼ Parse null coalescing that may be an implicit tuple, without ternary. Used for… def _parse_tuple_or_null_coalesce_no_ternary(self) -> Expr Parse null coalescing that may be an implicit tuple, without ternary. Used for match subject and case patterns to allow: {% match a, b %} {% case 1, 2 %} while preserving the ability to use 'if' as a guard clause: {% case 1 if x %} <- 'if' is a guard, not a ternary conditional Returns Expr _parse_for_target 0 Expr ▼ Parse for loop target (variable or tuple for unpacking). Handles: - item (… def _parse_for_target(self) -> Expr Parse for loop target (variable or tuple for unpacking). Handles: item (single variable) (a, b) (parenthesized tuple) a, b, c (comma-separated names before 'in') Returns Expr ← Previous parser Next → tokens List © 2026 Kida built in ᓚᘏᗢ { "linkPreviews": { "enabled": true, "hoverDelay": 200, "hideDelay": 150, "showSection": true, "showReadingTime": true, "showWordCount": true, "showDate": true, "showTags": true, "maxTags": 3, "includeSelectors": [".prose"], "excludeSelectors": ["nav", ".toc", ".breadcrumb", ".pagination", ".card", "[class*='-card']", ".tab-nav", "[class*='-widget']", ".child-items", ".content-tiles"], "allowedHosts": [], "allowedSchemes": ["https"], "hostFailureThreshold": 3 } } window.BENGAL_LAZY_ASSETS = { tabulator: '/kida/assets/js/tabulator.min.js', dataTable: '/kida/assets/js/data-table.js', mermaidToolbar: '/kida/assets/js/mermaid-toolbar.9de5abba.js', mermaidTheme: '/kida/assets/js/mermaid-theme.344822c5.js', graphMinimap: '/kida/assets/js/graph-minimap.ff04e939.js', graphContextual: '/kida/assets/js/graph-contextual.355458ba.js' }; window.BENGAL_ICONS = { close: '/kida/assets/icons/close.911d4fe1.svg', enlarge: '/kida/assets/icons/enlarge.652035e5.svg', copy: '/kida/assets/icons/copy.3d56e945.svg', 'download-svg': '/kida/assets/icons/download.04f07e1b.svg', 'download-png': '/kida/assets/icons/image.c34dfd40.svg', 'zoom-in': '/kida/assets/icons/zoom-in.237b4a83.svg', 'zoom-out': '/kida/assets/icons/zoom-out.38857c77.svg', reset: '/kida/assets/icons/reset.d26dba29.svg' }; Arrow Up -------------------------------------------------------------------------------- Metadata: - Word Count: 1253 - Reading Time: 6 minutes