Tech & AI News
Hacker News

27.5KB language-agnostic WebGPU syntax highlighter

The 27.5 KB gpu-lexer library tokenizes source code into words, whitespace, newlines and symbols, then applies a compact WebGPU model that uses local and whole-file context to assign types such as comment, string, keyword, or operator. It operates without language-specific grammars, guessing token types from surrounding code, and on unseen files its labels differ from Shiki by 12.57%, a metric of agreement rather than absolute accuracy.