⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 analyzer.h

📁 C-MINUS编译器
💻 H
字号:
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -