Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·part ofmodule highlight.module·originates fromworld 07158574-5…

wgsl

WGSL syntax highlighter. Pure `(text) -> { Segment }`. Mirrors the algorithm of the deleted Rust `highlight_wgsl` (renderer.rs): `//` line comments, `/* ... */` block comments, `"..."` strings with `\` escapes, `@attribute` tokens, numeric literals (digits + dots + alphanumerics…

byzero-proxy @ DESKTOP-DB3UJOJ·posted 2mo ago
What it does

wgsl

WGSL syntax highlighter. Pure (text) -> { Segment }. Mirrors the algorithm of the deleted Rust highlight_wgsl (renderer.rs): // line comments, /* ... */ block comments, "..." strings with \ escapes, @attribute tokens, numeric literals (digits + dots + alphanumerics for suffixes like 1u, 0xFF, 1.0_f32), and identifiers dispatched against the WGSL keyword and built-in type tables. Colors flow from ui.getToken("code.<role>") via the active theme; hardcoded fallbacks match the deleted Rust values when no theme is active.

Exports

  • highlight(text: string) -> { Segment } — tokenize a WGSL string into colored segments for the zui code renderer. The module returns this function directly.

Types:

  • Segment = { text: string, color: string, monospace: boolean }

Usage

local highlight = require("@builtin::modules.zui.highlight.wgsl")
local segments  = highlight("@vertex fn main() -> vec4<f32> {}")

Notes

  • Pure function — no side effects, no state. Safe to call any time.
  • Keyword and type tables match the deleted Rust constants verbatim (renderer.rs:6245-6263).
  • Strings are escape-aware ("a\"b" is one segment); WGSL has no single-quoted strings.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

ZuiHighlightWgsl Module WGSL syntax highlighter. Pure `(text) -> { Segment }`. Mirrors the algorithm of the deleted Rust `highlight_wgsl` (renderer.rs): `//` line comments, `/* ... */` block comments, `"..."` strings with `\` escapes, `@attribute` tokens, numeric literals (digits + dots + alphanumerics for suffixes like `1u`, `0xFF`), and identifiers dispatched against keyword and built-in type tables. Colors flow from `ui.getToken("code.<role>")` via the active theme. Hardcoded fallbacks below match the deleted Rust values when no theme is active. The module returns the highlighter function directly: local highlight = require("modules.highlight.wgsl") local segments = highlight("@vertex fn main() -> vec4<f32> { ... }")

token(role: string, fallback: string) → string

Internal: resolve `code.<role>` from the active theme; fall back to the deleted Rust constant when no `ui` global or no theme exists.

argtypedescription
rolestring
fallbackstring

isDigit(b: number) → boolean

argtypedescription
bnumber

isAlpha(b: number) → boolean

argtypedescription
bnumber

isAlnum(b: number) → boolean

argtypedescription
bnumber

push(segments: ?, text: ?, color: ?) → void

argtypedescription
segments?
text?
color?

highlightWgsl(text: string) →

Tokenize a WGSL source string into colored text segments for the zui code renderer. Handles `//` and `/* */` comments, `"..."` strings with backslash escapes, `@attribute` tokens, numeric literals with suffixes (`1u`, `0xFF`, `1.0_f32`), and identifiers dispatched against the WGSL keyword and built-in type tables. defaults to `""` when nil. for the zui code renderer.

argtypedescription
textstringThe WGSL source to highlight. Coerced via `tostring` and

examples

local segments = highlight("@vertex fn main() -> vec4<f32> {}")
⌬ Types
Segment = { text: string, color: string, monospace: boolean }

Sub-parts

Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.

3items
·
other · born here
▤file
▲ 0↑ born
backing path · modules/highlight.module/wgsl.module

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.