@weiqu_/match-pattern-rs
v0.3.0
Published
Rust/WASM compiler package for the match-pattern monorepo.
Downloads
42
Readme
match-pattern-rs
English | 简体中文
The Rust/WASM package in this repository. The current primary path compiles structural rules into CompilePlan instead of executing matchers directly.
The split with the TypeScript package is:
TypeScript authors the DSL and executes matchers.
Rust/WASM provides an optional compile-plan backend.Exported APIs
| Export | Current role |
|---|---|
| compile_match_plan(program) | primary path; compiles CompileProgram into CompilePlan |
| match_pattern(data, patterns) | legacy runtime wasm matcher; not on the default TS engine hot path |
For the current TS integration, compile_match_plan(...) is the important export.
Compile Input and Output
The primary path is:
CompileProgram -> compile_match_plan(...) -> CompilePlanCompileProgram contains only structural branches:
actionIndexpredicate
CompilePlan currently contains:
versionbranchesdiagnosticsdynamicSlotCount
Rust/WASM does not receive .to(...) / .map(...) closures.
Compiler Responsibilities
- Canonicalize analyzable predicates.
- Lower
PredicateAstintoCompiledPredicate. - Produce
CompilePlan. - Emit
unreachable_branchanddynamic_slot.
Non-goals
- TypeScript type narrowing.
- Zero-arg
run()exhaustiveness rules. - Executing
CompilePlan. - Calling JS predicates behind
slot.
Code Map
| Path | Role |
|---|---|
| rs/src/lib.rs | wasm exports |
| rs/src/compiler.rs | CompileProgram -> CompilePlan |
| rs/src/matcher.rs | legacy wasm runtime matcher |
| rs/src/parser.rs | pattern parser for the legacy path |
| rs/src/types.rs | legacy-path pattern types |
Documentation
- Integration overview: ARCHITECTURE.md
- TS default engine: ../ts/ARCHITECTURE.md
- Public usage overview: ../README.md
Commands
yarn test:rs
yarn test:rs:wasm
yarn rebuild:rs-pkg
yarn verify:rs-pkg