INLINE_DECL_SPLIT_REGEX

Static INLINE_DECL_SPLIT_REGEX 

Source
pub(crate) static INLINE_DECL_SPLIT_REGEX: LazyLock<Regex>
Expand description

Normalise ;<space>TYPE to ;\nTYPE so the line-anchored LOCAL_DECL_REGEX sees each declaration on its own line. The Isosceles preset (and a handful of MD2 packs that compress kaleidoscope state) put multiple typed locals on a single source line:

float2 cntr = float2(q13,q14); float sin = q11; float cos = q12; float scale = q15;

Without this pre-pass, only the first decl converted to a var — the rest stayed as raw HLSL and tripped naga with expected assignment or increment/decrement; found 'sin'. Safe for for(f32 i = 0; …) because the first ; inside the parens is followed by an expression (the loop condition), never by a type keyword.

We also split when the type is glued to { (function-body opening brace, conditional/loop body), and recognise vec types ending in >. A naive \b boundary check fails after vec2<f32> because > is already a non-word char; vec-typed declarations grouped behind any prior ; <decl> would otherwise stay un-rewritten and naga would report expected assignment or increment/decrement; found 'uvc'. Requiring an identifier-start [A-Za-z_] after the type+space rules out false positives on constructor calls like vec3<f32>(0).