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

📄 biaoge.cpp

📁 c++_pl0词法分析器
💻 CPP
字号:
// Biaoge.cpp: implementation of the Biaoge class.
//
//////////////////////////////////////////////////////////////////////
#include <string.h>
#include "cifa.h"
#include "Biaoge.h"
#include "yufa.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CBiaoge::CBiaoge(CPlCompiler *p)
{
	pl=p;
	lev=0;
	tx[0]=0;
	table[0].name[0]=0;
}
void CBiaoge::Enter(enum object k)
{
	if (pl->yufa->Level()>lev)
		tx[++lev]=tx[lev-1];
	else if (pl->yufa->Level()<lev)
		lev--;

	tx[lev]++;
	if (tx[lev]>=TABLE_SIZE) return;
	strcpy(table[tx[lev]].name,pl->cifa->id);
	table[tx[lev]].kind=k;
	switch (k)
	{
	case constant:
		table[tx[lev]].val=pl->cifa->num;
		break;
	case variable:
		table[tx[lev]].level=pl->yufa->Level();
		table[tx[lev]].adr=pl->yufa->DataAddr();
		break;
	case procedure:
		table[tx[lev]].level=pl->yufa->Level();
		break;
	}
}
int CBiaoge::Position(char *id)
{
	int i=tx[lev];
	while (stricmp(table[i].name,id) && i>0) i--;
	return i;
}

⌨️ 快捷键说明

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