analyzer.h

来自「C-MINUS编译器」· C头文件 代码 · 共 65 行

H
65
字号
#ifndef	MY_ANAYLZER_H_
#define	MY_ANAYLZER_H_

/****************************************************/
/* File: parse.h                                    */
/* The parser interface for the C minus compiler    */
/* By: lonelyforest.	Data: 2006.04.08            */
/****************************************************/

#include "symbolTab.h"
#include "FunCheck.h"

const int memInd = 2;   // memory indent,

class Analyzer {
public:
	Analyzer(const string& file);
	~Analyzer();

	void buildSymtab(TreeNode *pNode);
	void typeCheck(TreeNode *pNode);

	//void getListFile()	{ parse->getListFile(); }
	//void getTreeFile()	{ parse->getTreeFile(); }
	void getSymbolFile();  // main interface
	//-------------------------------------------------------------------
	void noTreeFile() { traceParse = false; }
	void noListFile()	{ parse->noListFile(); }
	void noSymbolFile()	{ traceAnalyze = false; }
	//--------------------------------------------------------------------
	bool is_good()const;
	int	errCount() const {return parse->errCount() + err;}
	int warnCount() const { return parse->warnCount() + warn;}
	//-------------------------------------------------------------------
protected:
    //------------------------------------------------------------------------
	void traverse(TreeNode * t,
	void (* preProc) (TreeNode *),
	void (* postProc) (TreeNode *) );
    //------------------------------------------------------------------------
	static void nullProc(TreeNode *t);
	static void insertNode(TreeNode *t);
	static void checkNode(TreeNode *);
	static void addMemLoc() { location += memInd; }
    //------------------------------------------------------------------------
public:
	TreeNode *program; 	
protected:
	Parser	*parse;
	//--------------------------------------------------------------------
	static symTable symbolTab;
	static FunArgsCheck FunArgs;
	string symFile;
	//--------------------------------------------------------------------
	static int location;       // memory location
	static int err;
	static int warn;
	//--------------------------------------------------------------------
	bool	is_good_;
	bool	traceAnalyze;
	bool   traceParse;
};

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?