Add optional regex constraints

This commit is contained in:
2026-06-16 11:27:27 +09:00
parent 84680e2652
commit f1a5836247
9 changed files with 160 additions and 6 deletions
+34
View File
@@ -0,0 +1,34 @@
# Features
Decodal keeps the embedded core small by making heavy functionality opt-in.
## Core defaults
`decodal-core` defaults to `std` only.
```toml
[features]
default = ["std"]
std = []
regex = ["std", "dep:regex"]
```
Building `decodal-core` with `--no-default-features` keeps the core in `no_std + alloc` mode and avoids optional dependencies.
## Regex
Regex constraints are implemented behind the `regex` feature.
When the feature is disabled, regex constraints parse and compose, but validating a concrete value against them returns an unsupported feature diagnostic.
```sh
cargo run -q -p decodal --features regex -- examples/regex/main.dcdl
```
Regex constraints are accumulated during `&` composition.
The implementation does not try to prove whether the intersection of two regex constraints is empty.
Concrete strings must match every regex constraint attached to the abstract value.
## CLI features
`decodal-cli` exposes a matching `regex` feature that enables `decodal-core/regex`.
The feature is not enabled by default so the default CLI binary remains small.
+1
View File
@@ -16,3 +16,4 @@ bytecode VM や JIT ではなく、AST を demand-driven に評価すること
4. [Composition and Materialization](./composition-and-materialization.md)
5. [Diagnostics and Fallback](./diagnostics-and-fallback.md)
6. [Embedding API](./embedding-api.md)
7. [Features](./features.md)