Commit graph

3 commits

Author SHA1 Message Date
Stephen Dennis
f124a8cd22 Factor shared tokenizer/parser/AST into mux_parse.h
Extract duplicated tokenizer, parser, and AST code from three study
tools into a shared header. Each tool is now a thin main() wrapper.
Added ast_raw_text() utility for source reconstruction. No behavioral
changes — 78 tests still pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 10:06:59 -07:00
Stephen Dennis
fe8321dd1a Implement proper FN_NOEVAL deferred evaluation in AST evaluator
Rework control flow functions (if, switch, case, cand, cor, iter, lit,
@@) to use deferred evaluation: handlers receive unevaluated AST
subtrees and call eval() selectively. This eliminates the need for
replace_tokens() and ##/#@/#$ text substitution.

Key proof: iter(10 20 30,[add(%i0,1)]) correctly produces "11 21 31"
by pushing %i0 onto the iterator stack and evaluating the body subtree
per item. Nested iterators work via %i0/%i1 stack depth.

Add PARSER_REPLACE.md design document for mux_exec replacement
architecture. 78 tests passing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 10:06:59 -07:00
Stephen Dennis
60f668bfd9 Add AST evaluator with 50+ builtin functions
Stage 3 of parser study: tree-walking evaluator that demonstrates
pure-expression MUX softcode CAN be evaluated from an AST. Implements
arithmetic, string, list, comparison, boolean, register, and control
flow functions. Includes 64-test harness.

Key finding: FN_NOEVAL functions (iter, switch, if) need deferred
argument evaluation — the evaluator must pass unevaluated AST subtrees
rather than pre-evaluated strings. Solvable but requires a different
dispatch mechanism than simple string-in/string-out handlers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 10:06:59 -07:00