Commit Graph

1 Commits

Author SHA1 Message Date
c5d2fa8c96 Step 18 (part 4): _hyperscript compiler — AST → SX expressions
lib/hyperscript/compiler.sx — transforms parsed hyperscript AST into
SX expressions targeting web/lib/dom.sx primitives. Two entry points:
  hs-to-sx    — AST node → SX expression
  hs-to-sx-from-source — source string → SX (tokenize+parse+emit)

Compiler handles:
  Expressions: me/it/event, refs, queries, attrs, styles, locals,
    arithmetic, comparison, boolean, array literals, property access,
    DOM traversal (closest/next/previous/first/last), type conversion,
    membership test, exists/empty/matches/contains predicates
  Commands: add/remove/toggle class, set (var/attr/style/prop dispatch),
    put, if/else, do, wait, wait-for, log, send, trigger, hide, show,
    transition, repeat, fetch, call, return, throw, settle, go, append,
    tell (rebinds me), for, take, make, install, measure, inc/dec
  Features: on (with from/filter/every), init, def, behavior

Maps to SX primitives: dom-add-class, dom-set-attr, dom-set-style,
dom-set-prop, dom-query, dom-closest, dom-dispatch, dom-append, etc.

33 compiler tests across 10 suites. 3076/3076 full build, zero regressions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 08:31:32 +00:00