Macro tracery::grammar [−][src]
macro_rules! grammar { ($($input: tt)+) => { ... }; }
Convenience macro that allows for shorthand creation of Grammar
s.
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())?;