Function mo::parallel_generate_examples[][src]

pub fn parallel_generate_examples(
    grammar_string: String,
    quantity: u32,
    start: String,
    config: &GeneratorConfig,
    print_progress: bool,
    print_stdout: bool
) -> Vec<Result<String, String>>

Generate a number of examples with the grammar,start rule and config provided

use mo::config::GeneratorConfig;
use mo::parallel_generate_examples;

// Default configuration for the generator
let mut config: GeneratorConfig = Default::default();

// Grammar string
let mut grammar = r#"
        language = {"Rust" | "Python" | "Go" | "Java" | "PHP" | "Haskell"}
        one = {"1"}
        daysNumber = {one ~ " day" | !one ~ ASCII_NONZERO_DIGIT ~ " days"}
        sentence = {"I have been programming in " ~ language ~ " for " ~ daysNumber ~ "."}
    "#;

// Generate the examples
let results = parallel_generate_examples(
            grammar.to_string(),        // The grammar
            5,                          // Quantity of examples
            "sentence".to_string(),    // Start rule
            &config,                    // Config of the generator
            false,                      // Print progress
            false,                      // Print in stdout, false return a vector with the examples
        );

println!("{:?}", results);