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

📄 product.h

📁 compiler principle how to ananilyze
💻 H
字号:
// Product.h: interface for the Product class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_PRODUCT_H__F0EE7A41_FD1B_427D_8F29_1F44711F9314__INCLUDED_)
#define AFX_PRODUCT_H__F0EE7A41_FD1B_427D_8F29_1F44711F9314__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "SymbolEntry.h"

#include <vector>
using namespace std;

class Product  
{
public:
	enum {UNKNOWN=0, LEFT_RIGHT_LINE=2, LEFT_LINE=4, RIGHT_LINE=5, 
		  RG3=7, CFG2=9, CSG1=11, PSG0=13 };
protected:
	vector<int> line;
	int countLeft;
	int grammarType;

	SymbolEntry& se(int index) const;
	const SymbolEntry& cse(int index) const;

	int sizeOfLeft(int token_type) const;
	int sizeOfRight(int token_type) const;
	int sizeOfRight() const;
	bool isRightInclude(int SymbolTableIndex) const;

	int sizeOfLeft_without_epsilon() const;
	int sizeOfRight_without_epsilon() const;
	
	//ture: PSG
	bool ggt_PSG_A_epsilon(const vector<Product>& products, int& sum_grammar_type, int startSymbolIndex);

public:
	Product();
	int size() const;	//without '|', ';', '->'
	int sizeOfLeft() const;
	
	void append_Left(int symbolTableIndex);
	bool append_Right_VN_VT(int symbolTableIndex, int row);		//false: epsilon is removed
	bool append_Right_Epsilon(int symbolTableIndex);			//false: the new index isn't inserted
	void copyLeft(Product& product, int newRow) const;
	
	static string grammarTypeString(int aGrammarType);

	int getGrammarType(const vector<Product>& products, int& sum_grammar_type, int startSymbolIndex);
	virtual string display() const;

};

#endif // !defined(AFX_PRODUCT_H__F0EE7A41_FD1B_427D_8F29_1F44711F9314__INCLUDED_)

⌨️ 快捷键说明

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