parsingstack.h

来自「这是我们老师给我们的例子」· C头文件 代码 · 共 38 行

H
38
字号
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 + =
减小字号Ctrl + -
显示快捷键?