ruleset.h

来自「这是一个用c++写的预测分析法程序,是编译原理课程设计的内容,可以预测分析语言」· C头文件 代码 · 共 50 行

H
50
字号

#include "Table.h"

struct  FOLLOW_SET     
{
	SIGN      Sign;       // 符号
	SIGN_SET  FollowSet;  // FOLLOW 符号集合
	FOLLOW_SET(); 
	~FOLLOW_SET();
	void      Compact();  // 压缩:去掉右边重复的,以及和左边符号相同的符号
	int       GetNonTerminalSignNum();	
};

class RULE_SET
{
public:
	RULE_SET();	
	~RULE_SET();

	int   GetRuleNum();
	RULE  GetRule(int);
	void  AddRule(RULE);	
	void  Reset();

	bool  IsLeftRecursive();
	bool  SetStartSign(SIGN);	
	SIGN  GetStartSign();
	TABLE CreateSELECTTable();
//private:
	bool		CanPushOutNULLString(SIGN);
	bool		CanPushOutNULLString(const SIGN_SET&);
	SIGN_SET	GetFIRSTSignSet(SIGN);
	void	    GetFIRSTSignSet(const SIGN_SET&,SIGN_SET&);

	int         CalcFOLLOWSet();
	SIGN_SET    GetFollowSet(SIGN);
	void        CalcSELECTSet();

	bool        CheckLeftRecursive(); // 检查是否有左递归存在
private:
	bool  FollowSetCalced;   // 是否已经计算过 FOLLOW 集
	bool  LeftRecursive;     // 是否是左递归的
	SIGN  StartSign;
	int   RuleNum;	         // 规则数
	RULE* pRules;            // 各规则
	int   NonTerSignNum;     // 非终极符个数
	FOLLOW_SET* FollowSet;   // FOLLOW 集合
	TABLE SelectTable;
};

⌨️ 快捷键说明

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