The Battle for Wesnoth  1.19.0-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:


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 24 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)


sourcethe definition of the context-free grammar to use

Definition at line 39 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)


sourceA map of nonterminals to lists of possibilities

Definition at line 98 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 35 of file context_free_grammar_generator.cpp.

Member Function Documentation

◆ generate()

std::string context_free_grammar_generator::generate ( ) const

Generates a possible word in the grammar set before.

the word

Reimplemented from name_generator.

Definition at line 171 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

◆ print_nonterminal()

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

Member Data Documentation

◆ nonterminals_

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

◆ seed_size

const short unsigned int context_free_grammar_generator::seed_size = 20

Definition at line 37 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: