⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 global.h

📁 一个语法分析程序,C++写的,内含原码和exe文件. 开发工具:DEV-C
💻 H
字号:
// Using STL 
// C++ forever ... 
#include <iostream>
#include <stdlib.h>
#include <list>
#include <string>

using namespace std;

class elem
{
public:
string name;
list<string> first; // first set
list<string> follow; // follow set 
};


const int MAXSIZE = 16; // maxium terminal symbol and maxium no-terminal symbol 
const int MAXLINE = 32; // maxium lines of the input grammer
extern int lineno; // record how many lines
extern int colineno;
const string ee = "e"; // the empty string
extern bool isLL1Grammer; // judge whether a given grammer is a LL(1) grammer 
extern elem symbol[MAXSIZE]; // to hold first and follow set for each symbol
extern string LL1_table[MAXSIZE][MAXSIZE]; // only for showing non-empty elements 
extern list<string> production[MAXLINE]; // for getting grammer from standard input stream
extern list<string> coProduction[MAXLINE];
extern list<string> VN; // hold no-terminal symbols
extern list<string> VT; // hold terminal symbols
extern list<string> First;
extern list<string> Follow;

/* ---------------- function declaration --------------------- */
void getGrammer();
void getCoGrammer();
bool isLeftRecursion();
void emitLeftRecursion(); // for emiting later... 
void print(list<string>& ); // to print structure
void removeDup(list<string>& ); // to remove duplicate
void getVN(); // get set of no-terminals
void getVT(); // get set of terminals
bool isIn(string,list<string>&); // judge if a given string is in a list
void listToString(string& ,list<string> ); // copy list to a string
void noRightReserve(); // for printing message
void getName(); // get the name of symbol
void buildFirst(); // build FIRST set
void printFirst(); // print FIRST of each no-terminals
void buildFollow(); // build FOLLOW set
void printFollow(); // print FOLLOW of each non-terminals
void initTable(); // inisialize the LL1 table
void buildTable(); // build LL1 table ( using some algorithm )
void printTable(); // print the LL(1) table 
/* ---------------------------------------------------------- */ 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -