📄 funcheck.h
字号:
#ifndef MY_FUNCHECK_H_
#define MY_FUNCHECK_H_
#include "parser.h"
/*----------------------------------------------*/
/* FunArgsCheck */
/*----------------------------------------------*/
/* 这个思想主要来自于符号表,这里建立了一个类似*/
/* 符号表的函数声明表,记录参数,函数名,等等的 */
/* 信息,用来在类型检查的时候,检测函数调用的正 */
/* 确性。 */
/*----------------------------------------------*/
struct ParamListRec {
ParamListRec():isArr(false), next(NULL) {}
ParamListRec(tokenType t, bool arr) : type(t), isArr(arr), next(NULL) {}
~ParamListRec() { if (next) delete next; }
// ...
tokenType type;
bool isArr;
ParamListRec *next;
};
struct FunDecListRec {
FunDecListRec():count(0), lineno(0), next(NULL) {}
FunDecListRec(const string &s, const tokenType t) :name(s), type(t),
count(0), lineno(0), params(NULL), next(NULL)
{}
~FunDecListRec() { if (next) delete next; if (params) delete params; }
int count; // record the params count
int lineno; // record the function defined line;
string name;
tokenType type;
ParamListRec *params;
FunDecListRec *next;
};
// ...
/**: class FunArgsCheck;
&
* author: lonelyforest
* data: 2006.04.08
*/
class FunArgsCheck {
public:
FunArgsCheck(): first(NULL), last(NULL)
{}
~FunArgsCheck() { if (first) delete first; } // don't delete last
void initial();
void insert(TreeNode *pNode);
int check(TreeNode *pNode, string &args, int &line); // check for function call
private:
FunDecListRec *first, *last;
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -