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

📄 endflag.cpp

📁 输入一个表达式子 然后输出 这个式子 的LL1文法形式
💻 CPP
字号:
// endflag.cpp: implementation of the Cendflag class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "LL1.h"
#include "endflag.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
/////////////head
Cendflag * Cendflag::head=NULL;
//////////////////
//////////////construct
Cendflag::Cendflag(TCHAR c)
{
	if(head==NULL){
		head=this;
		this->next=NULL;
	}else{
		this->next=head;
		head=this;
	}
	flag=c;
	isNull=FALSE;
	first=NULL;
	follow=NULL;
}
/////////////destroy
Cendflag::~Cendflag()
{

}

void Cendflag::destroy()
{
	Cendflag * endflag;
	while(endflag!=NULL){
		endflag=head;
		head=head->next;
		delete endflag;
	}
}

bool Cendflag::isaflag(TCHAR c)
{
	Cendflag *endflag=head;
	while(endflag!=NULL){
		if(endflag->flag==c){
			return TRUE;
		}
		endflag=endflag->next;
	}
	return FALSE;
}

Cendflag * Cendflag::getflag(TCHAR c)
{
	Cendflag *endflag=head;
	while(endflag!=NULL){
		if(endflag->flag==c){
			return endflag;
		}
		endflag=endflag->next;
	}
	return NULL;
}

bool Cendflag::addfirst(TCHAR c)
{
	Cuendflag * uendflag=first;
	while(uendflag!=NULL){
		if(uendflag->flag==c){
			return FALSE;
		}
		uendflag=uendflag->next;
	}
	uendflag=new Cuendflag(c);
	if(first==NULL){
		first=uendflag;
		uendflag->next=NULL;
	}else{
		uendflag->next=first;
		first=uendflag;
	}
	return TRUE;

}

bool Cendflag::addfollow(TCHAR c)
{
	if(c=='\0'){
		return FALSE;
	}
	Cuendflag * uendflag=follow;
	while(uendflag!=NULL){
		if(uendflag->flag==c){
			return FALSE;
		}
		uendflag=uendflag->next;
	}
	uendflag=new Cuendflag(c);
	if(follow==NULL){
		follow=uendflag;
		uendflag->next=NULL;
	}else{
		uendflag->next=follow;
		follow=uendflag;
	}
	return TRUE;
}

⌨️ 快捷键说明

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