Bootstrap parser.sx to Python, add reactive runtime plan
Replace hand-written serialize/sx_serialize/sx_parse in Python with spec-derived versions from parser.sx. Add parser as a Python adapter alongside html/sx/async — all 48 parser spec tests pass. Add reactive runtime plan to sx-docs: 7 feature layers (ref, foreign FFI, state machines, commands with undo/redo, render loops, keyed lists, client-first app shell) — zero new platform primitives. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -85,7 +85,12 @@ class PyEmitter:
|
||||
if name == "define-async":
|
||||
return self._emit_define_async(expr, indent)
|
||||
if name == "set!":
|
||||
return f"{pad}{self._mangle(expr[1].name)} = {self.emit(expr[2])}"
|
||||
varname = expr[1].name if isinstance(expr[1], Symbol) else str(expr[1])
|
||||
py_var = self._mangle(varname)
|
||||
cell_vars = getattr(self, '_current_cell_vars', set())
|
||||
if py_var in cell_vars:
|
||||
return f"{pad}_cells[{self._py_string(py_var)}] = {self.emit(expr[2])}"
|
||||
return f"{pad}{py_var} = {self.emit(expr[2])}"
|
||||
if name == "when":
|
||||
return self._emit_when_stmt(expr, indent)
|
||||
if name == "do" or name == "begin":
|
||||
@@ -747,12 +752,12 @@ class PyEmitter:
|
||||
nested_set_vars = self._find_nested_set_vars(body)
|
||||
def_kw = "async def" if is_async else "def"
|
||||
lines = [f"{pad}{def_kw} {py_name}({params_str}):"]
|
||||
if nested_set_vars:
|
||||
lines.append(f"{pad} _cells = {{}}")
|
||||
# Emit body with cell var tracking (and async context if needed)
|
||||
old_cells = getattr(self, '_current_cell_vars', set())
|
||||
if nested_set_vars and not old_cells:
|
||||
lines.append(f"{pad} _cells = {{}}")
|
||||
old_async = self._in_async
|
||||
self._current_cell_vars = nested_set_vars
|
||||
self._current_cell_vars = old_cells | nested_set_vars
|
||||
if is_async:
|
||||
self._in_async = True
|
||||
self._emit_body_stmts(body, lines, indent + 1)
|
||||
|
||||
Reference in New Issue
Block a user