📄 grammar.h
字号:
#include <iostream>
#include <vector>
#include <string>
#include "firstfollow.h"
using namespace std;
struct Production
{
char left;
string right;
};
struct Terminal
{
string t;
int id;
};
struct Variable
{
char v;
firstfollow first;
firstfollow follow;
};
struct Relation
{
char l;
char r;
};
class grammar
{
public:
vector <Production> production;
vector <Variable> VSet;
vector <Terminal> TSet;
vector <Relation> relation;
vector <Production> list;
public:
void ReadVSet();
void ShowVSet();
void ReadTSet();
void ShowTSet();
void ReadProduction();
void ShowProduction();
void AddRelation(char x1,char x2);
void DelRelation(char x1,char x2);
string GetFirstTerminal(string s);
firstfollow FirstSet(string s);
firstfollow FirstSet(char ch);
void FirstSet();
void FollowSet();
bool IsVar(char var);
bool IsTer(string t);
int FindVSetPos(char v);
int FindTSetPos(string t);
void InitList();
void CreatList();
void ShowList();
void AddProductionToList(Production pro,int vNum,int tNum);
void GrammarAnalyzer(string sentence);
void error();
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -