?? mlr1.h
字號:
#if !defined(AFX_MLR1_H__E7626B26_4BA9_4910_849A_151001216F5E__INCLUDED_)
#define AFX_MLR1_H__E7626B26_4BA9_4910_849A_151001216F5E__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif
#include "pchar.h"
#define ADJUST 1
//-128 空輸入
//-127 結束符$
//-126 小數點
//-125..-1 非終結符編號
//0 字符串結束標志
//1-127 終結符的ASCII碼
#ifndef LENGTH
#define ID_LENGTH 20
#define LINE_LENGTH 128
#define MAX_IDENT 125
#define MAP_SIZE 16
#define LR_NULL -128
#define LR_EOF -127
#define LR_DOT -126
#define LR_EOS 0
#endif
class MLR1{
public:
CString GetFirst(int i);
CString GetFollow(int i);
public:
MLR1();
virtual ~MLR1();
void ReSet(FILE*);
const CStringArray& GetIdentList();
int GetExpressNum();
int GetIdentNum();
protected:
bool Lex1();
int Lex2();
int Lex2_1(char*&,bool isUse=false);
bool Lex3();
//詞法、語法分析模塊
void FirstSet1();
void FirstSet2(int,int,int);
bool FirstSet3(const char*,char*);
bool FirstSet4(const char,char*);
CString FirstSet5(const char*,bool has_null=false);
void FirstSet6();
//First集求解模塊
CString FollowSet1(const char*,bool has_eof=false);
bool FollowSet2(const char*);
void FollowSet3();
bool FollowSet4(int,int,int);
//Follow集求解模塊
void LR0_table1();
void LR0_table2(char*);
//構造LR0分析表模塊
private:
CStringArray list_Ident;
CPtrArray list_Express;
//非終結符表和產生式表
CStringArray list_Seed0;
CStringArray list_Clouser0;
int* list_Index0;
//用token[LINE_LENGTH]作為臨時索引表,完成后拷貝到list_Index0
//list_Clouser0中字符串的第一個字符指向種子表,LR0項目從第二個字符開始
struct s_first{
char Fi[MAP_SIZE];
char Fo[MAP_SIZE];
char flag;}
m_first[MAX_IDENT];
//b6:正在計算Fi0x40
//b5-b3:正在計算Fo0x20,Fo以求解0x10,包含LR_EOF0x08
//b2-b0:Fi已求解0x04,推出LR_NULL0x02,b1有效0x01
char token[2048];
int token_len;
//token不止用來緩沖輸入串,還被各個功能模塊用做工作區
//所以各功能模塊不能同時進行
char bit_map[MAP_SIZE];
//如果說token被各模塊用做位圖的話
//bit_map則是一個小的位圖
FILE* p_file;
};
inline const CStringArray& MLR1::GetIdentList(){
return list_Ident;}
inline int MLR1::GetExpressNum(){
return list_Express.GetSize();}
inline int MLR1::GetIdentNum(){
return list_Ident.GetSize();}
#endif
//First集以空推導檢測為前提
//Follow集以First集為前提
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -