| Crates.io | grammatica |
| lib.rs | grammatica |
| version | 0.1.2 |
| created_at | 2025-12-09 13:02:09.75599+00 |
| updated_at | 2025-12-09 13:02:09.75599+00 |
| description | Rust library for representing and transforming formal grammars (Chomsky hierarchy today; extensible toward attribute, probabilistic, and specialized grammars). |
| homepage | https://github.com/platinvm/grammatica |
| repository | https://github.com/platinvm/grammatica |
| max_upload_size | |
| id | 1975448 |
| size | 63,973 |
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.
Core goals:
use std::collections::HashSet;
use grammatica::grammar::chomsky::{RegularGrammar, RegularProduction, RegularRhs};
let g = RegularGrammar::new(
HashSet::from(["S".to_string()]),
HashSet::from(['a', 'b']),
"S".to_string(),
vec![
RegularProduction { lhs: "S".to_string(), rhs: RegularRhs::Terminal('b') },
RegularProduction { lhs: "S".to_string(), rhs: RegularRhs::TerminalNonTerminal('a', "S".to_string()) },
]
).unwrap();
println!("start: {} productions: {}", g.start_symbol(), g.productions().len());
API docs will appear on docs.rs after the first successful publish.
Licensed under the MIT License. See LICENSE for details.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work shall be licensed under MIT without additional terms or conditions.