📄 symbol.cpp
字号:
/*****symbol.c******************************************************************/
#include"global.h"
#include<stdio.h> /*输入/输出*/
#include<string.h> /*字符串处理函数*/
#define STRMAX 999 /*lexemes数组的大小*/
#define SYMMAX 100 /*symtable的大小*/
char lexemes[STRMAX];
int lastchar=-1; /*lexemes中最后引用的位置*/
struct entry symtable[SYMMAX];
int lastentry=0; /*symtable中最后引用的位置*/
int lookup(char *s){ /*返回s的表项的位置*/
int p;
for(p=lastentry;p>0;p=p-1)
if(strcmp(symtable[p].lexptr,s)==0)
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=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 + -