#include <context_free_grammar_generator.hpp>
Classes | |
struct | nonterminal |
Public Member Functions | |
context_free_grammar_generator (const std::string &source) | |
Initialisation. More... | |
context_free_grammar_generator (const std::map< std::string, std::vector< std::string >> &source) | |
Initialisation. More... | |
std::string | generate () const override |
Generates a possible word in the grammar set before. More... | |
~context_free_grammar_generator () | |
bool | is_valid () const override |
Checks if the object is initialized. More... | |
Public Member Functions inherited from name_generator | |
virtual | ~name_generator () |
Private Member Functions | |
std::string | print_nonterminal (const std::string &name, uint32_t *seed, short int seed_pos) const |
Private Attributes | |
std::map< std::string, nonterminal > | nonterminals_ |
bool | initialized_ |
Static Private Attributes | |
static const short unsigned int | seed_size = 20 |
Definition at line 26 of file context_free_grammar_generator.hpp.
context_free_grammar_generator::context_free_grammar_generator | ( | const std::string & | source | ) |
Initialisation.
source | the definition of the context-free grammar to use |
Definition at line 33 of file context_free_grammar_generator.cpp.
References initialized_, nonterminals_, context_free_grammar_generator::nonterminal::possibilities_, utils::strip(), and lg::wml_error().
context_free_grammar_generator::context_free_grammar_generator | ( | const std::map< std::string, std::vector< std::string >> & | source | ) |
Initialisation.
source | A map of nonterminals to lists of possibilities |
Definition at line 94 of file context_free_grammar_generator.cpp.
References initialized_, nonterminals_, utils::strip(), and lg::wml_error().
context_free_grammar_generator::~context_free_grammar_generator | ( | ) |
Definition at line 29 of file context_free_grammar_generator.cpp.
|
overridevirtual |
Generates a possible word in the grammar set before.
Implements name_generator.
Definition at line 154 of file context_free_grammar_generator.cpp.
References random_new::generator, i, random_new::rng::next_random(), print_nonterminal(), and seed_size.
|
inlineoverridevirtual |
Checks if the object is initialized.
Reimplemented from name_generator.
Definition at line 62 of file context_free_grammar_generator.hpp.
References initialized_.
|
private |
Definition at line 131 of file context_free_grammar_generator.cpp.
References i, context_free_grammar_generator::nonterminal::last_, nonterminals_, context_free_grammar_generator::nonterminal::possibilities_, seed_size, and lg::wml_error().
Referenced by generate().
|
private |
Definition at line 37 of file context_free_grammar_generator.hpp.
Referenced by context_free_grammar_generator(), and is_valid().
|
private |
Definition at line 36 of file context_free_grammar_generator.hpp.
Referenced by context_free_grammar_generator(), and print_nonterminal().
|
staticprivate |
Definition at line 39 of file context_free_grammar_generator.hpp.
Referenced by generate(), and print_nonterminal().