www.pudn.com > pl0.zip > Table.h


#ifndef __TABLE_H 
#define __TABLE_H 
 
//#include "Simpsc.h" 
#include "Grammar.h" 
 
#define TABLE_MAX	100 
 
enum obj{constant,variable,procedure}; 
 
typedef struct table_type 
{ 
	char name[30];	//名字 
	obj kind;		//种类 
	union 
	{ 
		int val;	//值(constant) 
		struct 
		{ 
			int level;		//层次 
			int adr;		//相对偏移量 
			int size;		//占用空间(variable) 
		}; 
	}; 
}TableType; 
 
class Table   
{ 
	friend class Grammar; 
private: 
	int tx[MAX_LEV+1];             //table表的下标指针,是以值参数形式使用的 
	int lev; 
	Simpsc *pl; 
public: 
	TableType table[TABLE_MAX]; 
public: 
	Table(Simpsc *p); 
	void Enter(obj k,Word *Token); 
	void GetVal(int num); 
	int Position(char *id); 
	int ReturnIndex(); 
}; 
 
#endif //table.h