compiler-temp/LL1/LL1.h

33 lines
848 B
C++

// LL1 语法分析器
#ifndef LL1_H
#define LL1_H
#include "grammar.h"
using namespace std;
class LL1:public Grammar{
public:
LL1();
~LL1();
bool IsLL1(); // 判断该文法是否为 LL1 文法
void build_LL1_predict(); // 构建 LL1 的预测分析表
void print_LL1_predict(); // 打印 LL1 的预测分析表
void build_LL1_grammar(); // 构建规约序列
void print_LL1_grammar_log();
void fileout_LL1_grammar_log(string file_name);
private:
unordered_map<string, vector<string>> select; // 计算符号的 SELECT 集合
unordered_map<string, unordered_map<string, int>> LL1_predict; // LL1 的预测分析表
vector<string> LL1_grammar_log; // 规约序列
int insert_rule(pair<string, vector<string>>& new_rule); // 增加新的规则
};
#endif // !LL1_H