Grammatica
Grammatica is a Rust library for representing and transforming formal grammars. It currently implements the full Chomsky hierarchy (regular, context-free, context-sensitive, unrestricted) and is designed to be extensible toward additional paradigms such as attribute grammars, probabilistic/stochastic grammars, L-systems, and domain‑specific rewriting systems.
Currently Implemented
- Regular grammars (Type‑3)
- Context-free grammars (Type‑2)
- Context-sensitive grammars (Type‑1)
- Unrestricted grammars (Type‑0)
Planned Extensions
- Attribute grammars (semantic annotations)
- Probabilistic / weighted production systems
- Rewriting systems (Thue, string rewriting)
- L‑systems and growth models
Goals
Core goals:
- Provide immutable, validated grammar representations
- Enable safe transformations between grammar classes
- Offer introspection utilities (counts, symbol sets, structural checks)
- Serve as a foundation for parsers, analyzers, and educational tooling
Example (sketch)
use HashSet;
use ;
let g = new.unwrap;
println!;
Documentation
API docs will appear on docs.rs after the first successful publish.
License
Licensed under the MIT License. See LICENSE for details.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work shall be licensed under MIT without additional terms or conditions.