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>
This commit is contained in:
@@ -1311,6 +1311,7 @@ let run_spec_tests env test_files =
|
||||
let hs_dir = Filename.concat lib_dir "hyperscript" in
|
||||
load_module "tokenizer.sx" hs_dir;
|
||||
load_module "parser.sx" hs_dir;
|
||||
load_module "compiler.sx" hs_dir;
|
||||
load_module "types.sx" lib_dir;
|
||||
load_module "sx-swap.sx" lib_dir;
|
||||
(* Shared templates: TW styling engine *)
|
||||
|
||||
Reference in New Issue
Block a user