| Crates.io | cadk-bnf |
| lib.rs | cadk-bnf |
| version | 0.1.0 |
| created_at | 2025-07-12 22:16:10.799844+00 |
| updated_at | 2025-07-12 22:16:10.799844+00 |
| description | Parser for .bnf (Extended Backus–Naur form) files |
| homepage | |
| repository | https://github.com/davefol/cadk-bnf |
| max_upload_size | |
| id | 1749739 |
| size | 41,362 |
Parser for .bbf files
Used to translate iso-10303-11-2004.bnf and iso-10303-21-2004.bnf files into .lalrpop format for building a STEP file parser.
let source = "12 a = 'b' | 'c' .";
let lexer = lexer::Lexer::new(&source);
let parser = grammar::GrammarParser::new();
let ast = parser.parse(lexer)?;
let expected = ast::Grammar {
productions: vec![ast::Production {
index: Some(12),
lhs: ast::Ident("a".into()),
rhs: ast::Expr::Choice(vec![
ast::Expr::Atom(ast::Atom::Terminal("b".into())),
ast::Expr::Atom(ast::Atom::Terminal("c".into())),
]),
}],
};
assert_eq!(ast, expected);