📄 symbol.c
字号:
/************************** symbol.c **********************/
#include "global.h"
char lexemes[STRMAX];
int lastchar=-1; /* lexemes中最后引用的位置 */
//struct entry symtable[SYMMAX];
int lastentry=0; /* symtable中最后引用的位置 */
int lookup(char s[])
{
int p;
for(p=lastentry;p>0;p=p-1)
if(strcmp(symtable[p].lexptr,s)==0)
return p;
return 0;
}
int insert(char s[],int tok) /* 返回s的表项的位置 */
{
int len;
len=strlen(s); /* strlen计算s的长度 */
if((lastentry+1)>=SYMMAX)
error("symbol table full");
if((lastchar+len+1)>=STRMAX)
error("lexemes array full");
lastentry+=1;
symtable[lastentry].token=tok;
symtable[lastentry].lexptr=&lexemes[lastchar+1];
lastchar=lastchar+len+1;
strcpy(symtable[lastentry].lexptr,s);
return lastentry;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -