#![feature(proc_macro_non_items)] use grammar_tech_macro::grammar; use grammar_tech::{ Grammar, Generation, }; #[test] fn test_grammar () { let _grammar: Grammar = grammar! { Start -> Sentence; Sentence -> Name | List " and " Name; Name -> "tom" | "dick" | "harry"; List -> Name | Name ", " List; }; // println! ("- grammar : {:?}", grammar); } #[test] fn test_next_sentence () { let grammar: Grammar = grammar! { Start -> Sentence; Sentence -> Name | List " and " Name; Name -> "tom" | "dick" | "harry"; List -> Name | Name ", " List; }; let mut generation = Generation::new (grammar); for _ in 0..1000 { let sentence = generation .next_sentence (); println! ("{:?}", sentence); } }