-
Notifications
You must be signed in to change notification settings - Fork 0
/
cfg.h
executable file
·38 lines (37 loc) · 1.09 KB
/
cfg.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include<bits/stdc++.h>
using namespace std;
#ifndef CFG_H
#define CFG_H
/**
* Class representing the Context Free Grammar being used to generate the image.
*/
class CFG
{
private:
map<char,char[1000000]> productions;
char current[1000000];
public:
/**
* Constructor which initializes the string with the axiom
* @param axiom The string representing the first generation of the series
*/
CFG(char axiom[])
{
strcpy(current,axiom);
}
/**
* Function to add a production to the grammar
* @param symbol Represents the LHS symbol of the production
* @param rhs Represents the RHS of the production
*/
void addProduction(char symbol,char rhs[]);
/**
* Generates the offspring of the current string by simultaneously replacing all the symbols by the RHS's of their respective rules.
*/
void createNewGeneration();
/**
* Returns the current generation string
*/
void getCurrent(char buffer[]);
};
#endif //CFG_H