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

📄 parsingstack.h

📁 一个用C++写的编译器
💻 H
字号:
using namespace std;


struct stackEntry
{
	string entry;
	stackEntry* lower;
	stackEntry()
	{
		entry="";
		lower=0;
	}
};

class ParsingStack
{
	public:
		ParsingStack();//Constructor, push $ and P(the start symbol) into the stack.
		void initialize();//reset the stack to the initial state.
		stackEntry* pop();//pop the top entry(the leftmost token of a production).
		stackEntry* push(string entry);//push an entry into the stack.
		stackEntry* replace(string pte);
		//Been given the entry of the parsing table, it will 
		//replace the top of the stack by several other entries, according to
		//the production.
		stackEntry* getTop();
		//return the current pointer.
		bool isEmpty();
		~ParsingStack();
	private:
		string getEntry(string pte);//get an entry from the entry of parsingTable
		stackEntry* head;
	    stackEntry* current;
		stackEntry* popHead;
		stackEntry* popCurrent;
		int currentPosition;//get the terminal or nonterminal from a string
		int count;
};

⌨️ 快捷键说明

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