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.

src/Cart.tsrx
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>
}
a TSRX component, highlighted with the TSRX grammar tsx · module

The decoded program, as JSON. TSRX nodes keep their own names: JSXCodeBlock, TSRXExpression, JSXStyleElement.

the parser starts when this page loads

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.

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.