Fix quasiquote flattening bug, decouple relations from evaluator
- Fix qq-expand in eval.sx: use concat+list instead of append to prevent
nested lists from being flattened during quasiquote expansion
- Update append primitive to match spec ("if x is list, concatenate")
- Rebuild sx_ref.py with quasiquote fix
- Make relations.py self-contained: parse defrelation AST directly
without depending on the evaluator (25/25 tests pass)
- Replace hand-written JSEmitter with js.sx self-hosting bootstrapper
- Guard server-only tests in test-eval.sx with runtime check
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -384,57 +384,47 @@ def _self_hosting_data(ref_dir: str) -> dict:
|
||||
|
||||
|
||||
def _js_self_hosting_data(ref_dir: str) -> dict:
|
||||
"""Run js.sx live: load into evaluator, translate spec files, diff against G0."""
|
||||
"""Run js.sx live: load into evaluator, translate all spec defines."""
|
||||
import os
|
||||
from shared.sx.parser import parse_all
|
||||
from shared.sx.types import Symbol
|
||||
from shared.sx.evaluator import evaluate, make_env
|
||||
from shared.sx.ref.bootstrap_js import extract_defines, JSEmitter
|
||||
from shared.sx.evaluator import evaluate
|
||||
from shared.sx.ref.run_js_sx import load_js_sx
|
||||
from shared.sx.ref.platform_js import extract_defines
|
||||
|
||||
try:
|
||||
js_sx_path = os.path.join(ref_dir, "js.sx")
|
||||
with open(js_sx_path, encoding="utf-8") as f:
|
||||
js_sx_source = f.read()
|
||||
|
||||
exprs = parse_all(js_sx_source)
|
||||
env = make_env()
|
||||
for expr in exprs:
|
||||
evaluate(expr, env)
|
||||
|
||||
emitter = JSEmitter()
|
||||
env = load_js_sx()
|
||||
|
||||
# All spec files
|
||||
all_files = sorted(
|
||||
f for f in os.listdir(ref_dir) if f.endswith(".sx")
|
||||
)
|
||||
total = 0
|
||||
matched = 0
|
||||
for filename in all_files:
|
||||
filepath = os.path.join(ref_dir, filename)
|
||||
with open(filepath, encoding="utf-8") as f:
|
||||
src = f.read()
|
||||
defines = extract_defines(src)
|
||||
for name, expr in defines:
|
||||
g0_stmt = emitter.emit_statement(expr)
|
||||
env["_def_expr"] = expr
|
||||
g1_stmt = evaluate(
|
||||
evaluate(
|
||||
[Symbol("js-statement"), Symbol("_def_expr")], env
|
||||
)
|
||||
total += 1
|
||||
if g0_stmt.strip() == g1_stmt.strip():
|
||||
matched += 1
|
||||
|
||||
status = "identical" if matched == total else "mismatch"
|
||||
status = "ok"
|
||||
|
||||
except Exception as e:
|
||||
js_sx_source = f";; error loading js.sx: {e}"
|
||||
matched, total = 0, 0
|
||||
total = 0
|
||||
status = "error"
|
||||
|
||||
return {
|
||||
"bootstrapper-not-found": None,
|
||||
"js-sx-source": js_sx_source,
|
||||
"defines-matched": str(matched),
|
||||
"defines-total": str(total),
|
||||
"js-sx-lines": str(len(js_sx_source.splitlines())),
|
||||
"verification-status": status,
|
||||
|
||||
Reference in New Issue
Block a user