Expand description
Parser combinator interpreter (#221).
Lives in lex-bytecode rather than lex-runtime because it needs
to invoke Value::Closure values from Map / AndThen nodes,
which requires VM-level access. The structural primitives are
constructed by lex-runtime::builtins; only the recursive
interpretation step (parser.run) is here.
Calling convention:
- The Vm intercepts
("parser", "run")effect dispatch before invoking the handler and routes the args torun_parser, passing itself as theClosureCaller. Map(p, f)andAndThen(p, f)AST nodes carry a closure valuef; the interpreter calls back viacaller.call_closureto invoke it on the parsed result.
Traits§
- Closure
Caller - Trait the parser interpreter uses to invoke captured closures
during the recursive walk. The Vm implements it via
Vm::invoke_closure_value, but the interpreter is generic over the implementation solex-bytecodedoesn’t need to depend on any higher-level runtime concepts.
Functions§
- run_
parser - Walk a parser AST. Returns
(value, end_pos)on success or(failure_pos, message)on failure. The interpreter is the same shape as the original (inlex-runtime::builtins) plus theMapandAndThencases that need closure invocation.