The Battle for Wesnoth  1.19.5+dev
Classes | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
context_free_grammar_generator Class Reference

#include <context_free_grammar_generator.hpp>

Inheritance diagram for context_free_grammar_generator:

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 ()
 
- Public Member Functions inherited from name_generator
std::string generate (const std::map< std::string, std::string > &variables) const
 
 name_generator ()
 
virtual ~name_generator ()
 

Private Member Functions

void init_seed (uint32_t seed[]) const
 
std::string print_nonterminal (const std::string &name, uint32_t seed[], short int seed_pos) const
 

Private Attributes

std::map< std::string, nonterminalnonterminals_
 

Static Private Attributes

static const short unsigned int seed_size = 20
 

Detailed Description

Definition at line 23 of file context_free_grammar_generator.hpp.

Constructor & Destructor Documentation

◆ context_free_grammar_generator() [1/2]

context_free_grammar_generator::context_free_grammar_generator ( const std::string &  source)

Initialisation.

Parameters
sourcethe definition of the context-free grammar to use

Definition at line 38 of file context_free_grammar_generator.cpp.

References nonterminals_.

◆ context_free_grammar_generator() [2/2]

context_free_grammar_generator::context_free_grammar_generator ( const std::map< std::string, std::vector< std::string >> &  source)

Initialisation.

Parameters
sourceA map of nonterminals to lists of possibilities

Definition at line 97 of file context_free_grammar_generator.cpp.

References c, nonterminals_, and utils::trim().

◆ ~context_free_grammar_generator()

context_free_grammar_generator::~context_free_grammar_generator ( )

Definition at line 34 of file context_free_grammar_generator.cpp.

Member Function Documentation

◆ generate()

std::string context_free_grammar_generator::generate ( ) const
overridevirtual

Generates a possible word in the grammar set before.

Returns
the word

Reimplemented from name_generator.

Definition at line 170 of file context_free_grammar_generator.cpp.

References init_seed(), print_nonterminal(), and seed_size.

◆ init_seed()

void context_free_grammar_generator::init_seed ( uint32_t  seed[]) const
private

◆ print_nonterminal()

std::string context_free_grammar_generator::print_nonterminal ( const std::string &  name,
uint32_t  seed[],
short int  seed_pos 
) const
private

Member Data Documentation

◆ nonterminals_

std::map<std::string, nonterminal> context_free_grammar_generator::nonterminals_
private

◆ seed_size

const short unsigned int context_free_grammar_generator::seed_size = 20
staticprivate

Definition at line 36 of file context_free_grammar_generator.hpp.

Referenced by generate(), init_seed(), and print_nonterminal().


The documentation for this class was generated from the following files: