Commit Graph

3 Commits

Author SHA1 Message Date
2d7dd7d582 Step 5 piece 6: migrate 23 .sx files to define-library/import
Wraps all core .sx files in R7RS define-library with explicit export
lists, plus (import ...) at end for backward-compatible global re-export.

Libraries registered:
  (sx bytecode)      — 83 opcode constants
  (sx render)        — 15 tag registries + render helpers
  (sx signals)       — 23 reactive signal primitives
  (sx r7rs)          — 21 R7RS aliases
  (sx compiler)      — 42 compiler functions
  (sx vm)            — 32 VM functions
  (sx freeze)        — 9 freeze/thaw functions
  (sx content)       — 6 content store functions
  (sx callcc)        — 1 call/cc wrapper
  (sx highlight)     — 13 syntax highlighting functions
  (sx stdlib)        — 47 stdlib functions
  (sx swap)          — 13 swap algebra functions
  (sx render-trace)  — 8 render trace functions
  (sx harness)       — 21 test harness functions
  (sx canonical)     — 12 canonical serialization functions
  (web adapter-html) — 13 HTML renderer functions
  (web adapter-sx)   — 13 SX wire format functions
  (web engine)       — 33 hypermedia engine functions
  (web request-handler) — 4 request handling functions
  (web page-helpers) — 12 page helper functions
  (web router)       — 36 routing functions
  (web deps)         — 19 dependency analysis functions
  (web orchestration) — 59 page orchestration functions

Key changes:
- define-library now inherits parent env (env-extend env instead of
  env-extend make-env) so library bodies can access platform primitives
- sx_server.ml: added resolve_library_path + load_library_file for
  import resolution (maps library specs to file paths)
- cek_run_with_io: handles "import" locally instead of sending to
  Python bridge

2608/2608 tests passing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 21:48:54 +00:00
b62dfb25e5 Highlight returns SX tree, rendered to HTML/DOM by pipeline
highlight.sx now returns a list of (span :class "..." "text") elements
instead of a string. The rendering pipeline handles the rest:
- Server render-to-html: produces <span class="...">text</span>
- Client render-to-dom: produces DOM span elements
- Aser: serializes spans as SX for client rendering

Key fixes:
- hl-span uses (make-keyword "class") not :class (keywords evaluate
  to strings in list context)
- render-sx-tokens returns flat list of spans (no wrapper)
- hl-escape is identity (no escaping needed for tree values)
- highlight.sx added to browser bundle + platform loader
- ~docs/code renders src directly as child of pre

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 23:12:36 +00:00
0d5770729f sx-host step 3: HTTP server mode + define shorthand + SX highlighter
HTTP server (--http PORT): OCaml serves sx-docs directly, no Python.
Loads components at startup, routes /sx/ URLs, renders full pages with
shell. Geography page: 124ms TTFB (vs 144ms Quart). Single process.

define shorthand: (define (name args) body) desugars to
(define name (fn (args) body)) in the CEK step function.

SX highlighter (lib/highlight.sx): pure SX syntax highlighting with
Tailwind spans. Tokenizes SX/Lisp code — comments, strings, keywords,
components, specials, numbers, booleans. Replaces Python highlight.py.

Platform constructors: make-lambda, make-component, make-island,
make-macro, make-thunk, make-env + accessor functions bound for
evaluator.sx compatibility in HTTP mode.

Tests: 1116/1117 OCaml, 7/7 Playwright (main tree).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 16:15:58 +00:00