lexer_svelte.ts

Hand-written Svelte lexer — the shared markup scanner (lexer_markup.ts) in svelte mode plus the {…} expression lexer.

Emits markup's tag/attr/comment/entity structure (no special_attr — svelte handles style=/on*= as ordinary attributes; js-style line and block comments between attributes emit comment leaves), script+lang_ts and style+lang_css regions (svelte scripts are always TypeScript), and svelte_expression containers whose forms nest a same-span block ({#if}/{:else if}/{/each}/…), each ({#each list as item}), at_directive ({@render}/{@const}/…), or declaration_tag ({const …}/{let …}) container with special_keyword/at_keyword/ keyword leaves and lang_ts interiors.

Notable behavior: expression braces balance to any depth and skip strings/templates/comments ({'}'} works); expression-valued attributes emit full structure (attr_name + attr_value with attr_equals, not the = swallowed into the name); quoted values interleave text and expressions (class="a {b} c"); the {#each} expression before as is lexed as ts; the closing } is always expression punctuation; as/then are keywords only in the each/await forms that define them, not anywhere they appear; directive modifiers (transition:fade|global) get punctuation pipes.

Resilience: an unterminated expression extends to the end of the window.

view source

Declarations
#

lexer_svelte
#

lexer_svelte.ts view source

SyntaxLang import {lexer_svelte} from '@fuzdev/fuz_code/lexer_svelte.js';

The Svelte language registration for the lexer engine.

Depends on
#

Imported by
#