macro_rules! grammar {
($($input: tt)+) => { ... };
}Expand description
Convenience macro that allows for shorthand creation of Grammars.
Accepts input in the form "key" => [ "list", "of", "rules" ] or, in the
case of a key having only one rule, "key" => "rule". Equivalent to
manually building a map and then calling Grammar::from_map
§Returns
§Example
// Declare the grammar
let g = grammar! {
"origin" => "#tool# is #description#!",
"tool" => "tracery",
"description" => [ "fun", "awesome" ]
}?;
// Randomly produce the string "tracery is fun!" or "tracery is awesome!"
g.flatten(&mut rand::thread_rng())?;