📄 symtab.h
字号:
#ifndef _SYMTAB_H_
#define _SYMTAB_H_
#define SUCCESS 0 //valid entry found
#define FAIL -1 //entry unfound
#define UNCONFORM -2 //for funtion definition, parameter uncomform to former declare
#define INVALID -3
struct entryType{
ExpType type;
VarKind varK;
};
struct paramType{
entryType type;
paramType * next;
paramType(){
next = NULL;
}
};
struct Result{
paramType * params;
ExpType etype; //Int, Char , Boolean, Float
VarKind vark; //Norm, Array, Func
int memloc;
int size;
bool local;
Result(){
etype = Void;
params = NULL;
}
};
/* Procedure st_insert inserts line numbers and
* memory locations into the symbol table
* loc = memory location is inserted only the
* first time, otherwise ignored
*/
int st_insert( char * name, int lineno, ExpType type, ExpKind kind, int size = -1);
int st_insert( char * name, int lineno, ExpType type, TreeNode * params);
/* Function st_lookup returns the memory
* location of a variable or -1 if not found
*/
int st_lookup ( char * , Result &);
int st_funclookup(char *, ExpType, TreeNode * params);
int st_funclookup(char *, Result &);
/* Procedure st_setLoc set a variable's memory location
*
*/
int st_setLoc(char * ,int );
/* Function st_newBuck notes that the procedure enters
* a new compoud statement
*/
void st_newBuck();
/* Function st_delBuck notes that the procedure leaves
* a compoud statement
*/
void st_delBuck();
void st_reset();
// Enters a new Function definition part
void st_inFunc(char * name);
//Leaves a Function definition part
void st_outFunc();
/* Procedure printSymTab prints a formatted
* listing of the symbol table contents
* to the listing file
*/
void printSymTab(FILE * listing);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -