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

📄 global.cpp

📁 (1) 给定一段符合Pascal子集语法的语言
💻 CPP
字号:
#include "StdAfx.h"
#include ".\global.h"

global::global(void)
{
	this->global_type = init;
	this->offset = -1;
	this->sentence_num = -1;
	this->v_table.clear();
	this->temp_num = -1;
}

global::~global(void)
{
}

virable_item *global::getVirable(string name)
{
	for( int i = 0 ; i < v_table.size() ; i++)
	{
		if( v_table[i].name.compare(name) == 0 )
			return &v_table[i];
	}
	return NULL;
}
void global::printVTable()
{
	output_code<<endl<<endl;
	output_code<<"打印符号表:"<<endl;
	output_code<<"name"<<"\t"<<"type"<<"\t"<<"address"<<"\t"<<endl;//"value"<<endl;
	for( int i = 0 ; i < v_table.size() ; i ++)
	{
		output_code<<v_table[i].name<<"\t";
		if( v_table[i].type == integer )
			output_code<<"integer"<<"\t";
		else if( v_table[i].type == real )
			output_code<<"real"<<"\t";
		else if( v_table[i].type == boolean )
			output_code<<"boolean"<<"\t";
		else if( v_table[i].type == vector_type )
		{
			if( v_table[i].vectorType == integer )
				output_code<<"int vector"<<"\t";
			else if( v_table[i].vectorType == real )
				output_code<<"real vector"<<"\t";
			else if( v_table[i].vectorType == boolean )
				output_code<<"bool vector"<<"\t";
		}
		output_code<<v_table[i].address<<"\t";
		output_code<<endl;
	}
}
void global::push(string a_n, string c, int a_v, int s_n)
{
	attribute *newAttr = new attribute(a_n, c, a_v, s_n);
	this->att.push(*newAttr);	
}

void global::pushWaiting(string a_n, string c, int a_v, int s_n)
{
	attribute *newAttr = new attribute(a_n, c, a_v, s_n);
	this->wait.push(*newAttr);	
}

void global::getTop(attribute &dst)
{
	if( att.empty() )
		cout<<"ERROE:THE STACK IS EMPTY!!!!!!"<<endl;
	dst = att.top();
}

void global::popTop(attribute &dst)
{
	if( att.empty() )
		cout<<"ERROE:THE STACK IS EMPTY!!!!!!"<<endl;
	dst = att.top();
	att.pop();
}
void global::popWaitingTop(attribute &dst)
{
	if( wait.empty() )
		cout<<"ERROE:THE WAITING STACK IS EMPTY!!!!!!"<<endl;
	dst = wait.top();
	wait.pop();
}
void global::clearAtt()
{
	while( !att.empty())
		att.pop();
}

void global::clearWait()
{
	while( !wait.empty())
		wait.pop();
}

⌨️ 快捷键说明

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