rec_parse.h

来自「pl0编译器」· C头文件 代码 · 共 34 行

H
34
字号
//Rec_Parse.h

#pragma once
#include "Grammar.h"
#include "Action.h"
using namespace std;


class Rec_Parse
{
public:
	Rec_Parse(Grammar *grammar,vector< set<symbol> > p,
		list<TOKEN> *tokenlist):g(grammar),Predict(p),tlist(tokenlist),pos(tlist->begin()),act(grammar)
	{
		cout<<"Recursive Parsing..."<<endl;
		Parse(g->start_symbol);
		if(pos == tlist->end()) cout<<"Cheer! Accept!"<<endl<<endl;
	}
	~Rec_Parse() {};
//	void print_table() {symbol_table.print_table();}

protected:
	list<TOKEN> *tlist;
	list<TOKEN>::iterator pos;
	Grammar *g;
	vector< set<symbol> > Predict;
	void Parse(symbol X);
	void error(list<TOKEN>::iterator pos,nonterminal X);

	//for semantic analyse
	list<TOKEN>::iterator token_pos;
	_Action act;
};

⌨️ 快捷键说明

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