-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
34 lines (32 loc) · 745 Bytes
/
main.cpp
File metadata and controls
34 lines (32 loc) · 745 Bytes
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
#include "LR.h"
int main() {
//根据文法获取NFA
FA fa;
fa.GrammarToNFA(GRAMMAR_PATH);
//控制台输出该NFA
cout<<"NFA:"<<endl;
fa.printNFA();
FA dfa;
dfa.TransToDFA(fa);
//将该NFA转为DFA,然后最小化,输出最小化的DFA
cout<<"DFA:"<<endl;
dfa.printDFA();
//进行词法分析
int i = LexicalAnalyze(dfa,SOURCE_PATH);
if (!i){
cout<<"程序错误,现已终止!"<<endl;
cout << endl << "按Enter键退出...";
getchar();
return -1;
}
LR lr;
//语法分析
lr.readGrammar(GRAMMAR_2NF_PATH);
// lr.printProduction();
lr.construct_LR1_itemSets();
lr.printItemSet();
lr.parse(TOKEN_PATH);
cout << endl << "按Enter键退出...";
getchar();
return 0;
}