📄 symtable.h
字号:
/*******************************************************
SymTable.h
武汉大学国际软件学院软件工程05级7班
崔灿
200532580235
2007-12-1
********************************************************/
#ifndef _SYMTABLE_H
#define _SYMTABLE_H
#include "globals.h"
#include <string>
#include <vector>
#include <map>
using namespace std;
class Symbol
{
public:
//符号类型,变量的类型,数组的项的类型,函数的返回类型
int type;
//符号的标识符
string id;
//符号的大小,变量为1,数组为数组的size,函数为0
int size;
//地址。变量的地址。数组的首地址,函数的首地址
string address;
//符号是否为数组,是为1.不是为0
bool isarr;
//符号是否为函数,是为1.不是为0
bool isfun;
Symbol();
Symbol(int type,string id, int size, string address);
Symbol(Symbol* sym);
~Symbol(){}
protected:
private:
};
class SymTable
{
public:
SymTable(/*SymTable* parent=NULL*/);
Symbol* find(string id);
bool contain(string id);
void insert(Symbol* sym);
~SymTable();
map<string,Symbol*> *table;
//该符号表的上一层符号表
SymTable* parent;
//符号表
protected:
private:
};
class Function
{
public:
int type;
string id;
string address;
vector<int>* args;//参数类型列表
Function();
Function(Function* f);
vector<int>* get_args(){return args;}//获取参数类型列表
~Function(){delete args;}
protected:
private:
};
//函数表
class FunTable
{
public:
map<string,Function*>* funs;
Function* get_fun(string id);
void insert(Function* fun);
FunTable();
~FunTable();
protected:
private:
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -