dfa.h
来自「一个模拟flex的应用程序 主要实现词法分析 语义分析」· C头文件 代码 · 共 47 行
H
47 行
#ifndef DFA_HEADER#define DFA_HEADER#include"TransitionTable.h"#include"AdjacentTable.h"#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <stack>using namespace std;class DFA
{
public:
DFA();
~DFA(); void prepare(char* re,char*file);
void FindMatchingPatternInFile(char*file);
private:
char *exp; //stores the regular expression
char *post; //stores the postfix expression
char *edge; //stores the terminal of the expression
int edgeNumber; // the number of the terminal
int **DStates;
int **Dtran;
int *AcceptStates;
int DStatesNumber;
int DtranNumber;
int NFAStatesNumber;
int DFAStatesNumber;
AdjacentTable *NFATable;
TransitionTable *DFATable; void GetRegExp(); //get the regular expression from the console
void InsertCatNode(); // Insert dot to represent catenation
void RegExpToPost(); //Change the regular expression into the postfix form according to the operatpor priority
void GetAllTerminals(); //Scan the post order string to get the number of the terminals
void ThompsonConstruction(); //Construct NFA using Thompson's rule
void SubsetConstruction();
int getPriority(char symbol);//Define the priority of the operator
int CompArray(int *t1, int *t2);
int MinimizeDFAStates(int **Dtran, int *AcceptStates, int DtranNumber, int edgeNumber);
void RemoveFirstSymbol(char *buf, int &len);
};#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?