?? symboltable.h
字號:
/*
SymbolTable class,it is a list,include struct SymbolElement as it's element.
Used to store infomations about lexemes.
*/
using namespace std;
struct symbolElement
{
string token;
char* entry;//point to lexemeArr
double attribute;//will be implemented later in parser
symbolElement* next;
symbolElement()
//constructor
{
token="";
entry=0;
attribute=NULL;
}
};
//a struct in symbol table
class SymbolTable
{
public:
void initiate(string filename);
/*
Read the file in the path "filename",counted the characters in it
allocate enough space to lexemeArr.
Initiate the SymbolTable with keywords.
*/
symbolElement* insert(string lex,string tok);
/*
first find(string lexeme),if founded ,return current
else insert the lex into lexemeArr and construct a new
SymbolElement then insert it into the list.
*/
symbolElement* find(string lexeme);
/*
search the list to find lexeme,if founded return the current pointer
else return 0.
*/
~SymbolTable();
//destructor
private:
char* SymbolTable::insertArr(string lex);
/*
Insert lex into the lexemeArr,return the pointer that points to the
first character of the string.
*/
string readArr(char* entry);
/*
Every lexeme in the array that "entry" points to is ended by '\n'.
Returns the string it read from the array when it reachs a '\n'.
The first character of the string is pointed by "entry".
*/
symbolElement* head;
symbolElement* current;//Used to search the list
int count;//count the number of SymbolElements
int c;//first empty position of lexemeArr;
int i;//number of characters in the source file;
char* lexemeArr;//Used to store lexemes
};
//symbol table
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -