?? grammar.h
字號(hào):
//Grammar.h
//本文件定義了文法GRAMMAR類,它通過initializtion.h的信息建立文法的內(nèi)部表示。
#pragma once
#include "TypeDef.h"
using namespace std;
class Grammar
{
public:
Grammar();
~Grammar() {};
//查找wordtype類型的search字符串的內(nèi)部表示
symbol Search(const string& search,symbol_type wordtype);
//輸入內(nèi)部表示,返回相應(yīng)的文本信息
string GetStr(const symbol &sym);
//固定查找
symbol Static_Search(const string& search);
//把產(chǎn)生式輸出
void Show_Productions();
//返回產(chǎn)生式的右部,在語法分析中使用
const vector<symbol>& GetRight(int n) { return productions[n].rhs; }
//返回產(chǎn)生式的左部
symbol GetLeft(int n) { return productions[n].lhs; }
//返回非終極符的個(gè)數(shù)
int Get_Num_Nonterminal() { return nonterminals.size(); }
//返回第i個(gè)非終極符
symbol Get_Nonterminal(int i)
{
if ( i >= nonterminals.size() ) return make_pair(Default,0);
symbols::iterator s_it=nonterminals.begin();
advance (s_it,i);
return s_it->second;
}
//存放產(chǎn)生式數(shù)組
vector<production> productions;
//存放終極符
symbols terminals;
//存放非終極符
symbols nonterminals;
//存放動(dòng)作符號(hào)
symbols actions;
//開始符
nonterminal start_symbol;
//判定是否是非終極符
bool is_nonterminal(const symbol &X);
//判定是否是終極符
bool is_terminal(const symbol &X);
//判定是否是動(dòng)作符號(hào)
bool is_action_symbol(const symbol &X);
//實(shí)現(xiàn)語法分析中的“匹配”功能
bool match(const terminal &X, const terminal &Y);
protected:
vector<string> Intliterals; //常數(shù)表
vector<string> id; //標(biāo)識(shí)符表
vector<string> Chars; //字符常量表
};
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -