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

📄 dfa.h

📁 输入一个正则表达式
💻 H
字号:
#ifndef _DFA_H_
#define _DFA_H_

#include "NFA.h"

class DFA
{
private:
	typedef int							*StateItem;
	typedef vector <StateItem>			StateTranTable;
	typedef StateTranTable::iterator	StateTranIt;

	// Destroy STT
	void	destroySTT();

	// Create a new item, return the index of the new item
	int		newItem();

	// add stateSet ss into STT[i][j], using setVec and nfa start set:nfaF.
	void	addItem(StateSet &ss, int i, int j, vector <StateSet> &setVec, StateSet &nfaF);

	// if State[i] and State[j] is the same state
	int		isSameState(int i, int j);
	
	// merge State[b] into state[a], and delete [b]
	void	mergeState(int a, int b);

protected:
	int				alphaSize;
	int				*rawMap;

	StateSet		F;
	int				Q;
	StateTranTable	STT;
	int				STTSize;

public:
	DFA(NFA *n, int *_rawMap);
	~DFA();

	// build a DFA from an NFA
	void	buildDFA(NFA *n);
	
	// minimize the DFA
	void	minimize();

	// identify if the string is the language of this DFA
	int		identify(const char *str);

	friend ostream& operator<<(ostream &os, DFA *d);
};

#endif

⌨️ 快捷键说明

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