yuku-tsrx
A Zig parser, analyzer, and code generator for .tsrx
Built as a compile-time dialect on Yuku, with a JavaScript API on top of a native addon.
export function Cart({ items }): unknown @{
const total = items.length;
<section className="cart">
@if (total > 0) {
@for (const item of items; index i; key item.id) {
<span>{i}:{item.id}</span>
} @empty {
<span>empty</span>
}
} @else {
<span>no cart</span>
}
<style>.cart { display: grid; }</style>
</section>
}
The decoded program, as JSON. TSRX nodes keep their own names: JSXCodeBlock, TSRXExpression, JSXStyleElement.
Everything the parser reported for the current source, including the semantic early errors.
What the code generator prints for the current program.
Scopes, symbols, references and the module record from the analyzer.
Measured, not claimed
These four numbers are computed from benchmarks/m6-baseline.json when this page is built, so they cannot drift from the committed report.
Shorter is faster. Median microseconds per parse of the same 214,751-byte input, 25 iterations, alternating order.
One measurement on one machine (Apple M5 Pro, a 224-file corpus). Your hardware will differ. MB means 1,000,000 bytes.
-
A dialect on Yuku
TSRX rules are compiled into Yuku through its extension points. Yuku does the JavaScript and TypeScript work.
-
A real parser you can call
parseandparseModulereturn a TSRX AST from an ESM JavaScript API over a native addon. -
An analyzer with a semantic view
analyzeadds aSemanticViewover references, scopes, and symbols alongside the parse result. -
A code generator
generateturns a program back into source, with options for stripping, minifying, quotes, and comments. -
TSRX node names, not a lowering
The AST carries
JSXCodeBlock,TSRXExpression,JSXStyleElementand the rest by name. -
No fork
A Yuku built without a dialect compiles to exactly what it did before. Nothing upstream is copied or patched.
Built on the Yuku seam in PR #164
yuku-tsrx is a dialect adapter that plugs into the extension points Yuku exposes. It is an independent project and nothing here is a fork of Yuku.