-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompiler.h
More file actions
59 lines (54 loc) · 1.63 KB
/
Copy pathCompiler.h
File metadata and controls
59 lines (54 loc) · 1.63 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef COMPILER_H_INCLUDED
#define COMPILER_H_INCLUDED
#include <vector>
#include <cstring>
#include <fstream>
#include "Grammer.h"
enum WaitType
{
PARSING,
LL1_CALCULATING,
};
class Compiler
{
private:
std::vector< std::string >m_grammers_container;
bool validate(std::string s , int nr_grammers);
void addToGrammer(std::string s);
void createGrammers();
std::vector< Grammer > m_grammers;
std::vector< Grammer > m_grammers2;
void makeUniqueLeftSides();
bool areLeftSidesUnique();
void recheckGrammers( std::string method_name );
std::vector< char > m_null_variables;
bool findNullVariables();
void makeWithoutEpsilon();
void makeWithLeftFactoring();
void makeWithoutLeftRecursion();
void omitRepeatedVariables();
bool canLeftFactoring();
void insertSingleTerminals();
void insertSingleNonTerminals();
bool canRemoveLeftRecursion();
std::vector< char > m_left_recursion_variables;
char findNewLeftSideChar();
void omitRemovedLeftSides();
void insertAllTermsInS();
void removeLastGrammer();
public:
std::ofstream out;
Compiler();
~Compiler();
void help();
void getInput();
bool isGrammerLL1();
void makeGrammerLL1();
void outputLL1();
void outputFirsts();
void outputFollows();
void outputParsingTable();
void waiting( int type );
void outputWhyNotLL1();
};
#endif // COMPILER_H_INCLUDED