📄 symbol.c
字号:
#include "global.h"
#define STRMAX 999 /* size of lexeme array */
#define SYMMAX 100 /* size of symtable */
char lexemes [STRMAX];
/* las used position in lexemes */
int lastchar = -1;
struct entry symtable[SYMMAX];
/* last used position in symtable */
int lastentry = 0;
/* returns the position of entry for s */
int lookup(char s[]) {
int p;
for( p=lastentry; p>0; p-=1 )
if(strcmp(symtable[p].lexptr, s) == 0)
return p;
return 0;
}
/* returns position of entry for s */
int insert(char s[], int tok) {
int len;
/* strlen computes length of s */
len = strlen(s);
if(lastentry + 1 > SYMMAX)
error(" Symbol Table Full ");
if(lastchar + len + 1 >= STRMAX )
error(" Lexemes Array Full ");
lastentry = 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 + -