亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? expand.cpp

?? Full support for extended regular expressions (those with intersection and complement); Support for
?? CPP
字號:

// To expand some expression E means
//
// i. to prove that L(E) is a subset of Sigma
//	and
// ii. to compute L(E), i.e. build the set of all terminals generated by E.

// To expand some nonterminal A means to expand the body of its definition.

#include "expand.h"
#include "dolphin.h"
#include "stl.h"
using namespace std;
using namespace Whale;

//#define DEBUG_EXPANDED_NONTERMINALS

UnionOfIntervals<int> expand_proc(NonterminalExpression *expr);
void expand_proc_ii(NonterminalExpression *expr);
UnionOfIntervals<int> expand_proc(NonterminalExpressionS *expr);
UnionOfIntervals<int> expand_proc(NonterminalExpressionC *expr);

UnionOfIntervals<int> expand_proc(NonterminalExpression *expr)
{
	if(typeid(*expr)==typeid(NonterminalExpressionDisjunction))
	{
		NonterminalExpressionDisjunction &expr_d=*dynamic_cast<NonterminalExpressionDisjunction *>(expr);
		return expand_proc(expr_d.expr1) | expand_proc(expr_d.expr2);
	}
	else if(typeid(*expr)==typeid(NonterminalExpressionConjunction))
	{
		NonterminalExpressionConjunction &expr_c=*dynamic_cast<NonterminalExpressionConjunction *>(expr);
		return expand_proc(expr_c.expr1) & expand_proc(expr_c.expr2);
	}
	else if(typeid(*expr)==typeid(NonterminalExpressionConcatenation))
		assert(false);
	else if(typeid(*expr)==typeid(NonterminalExpressionComplement))
		assert(false);
	else if(typeid(*expr)==typeid(NonterminalExpressionOmittable))
		assert(false);
	else if(typeid(*expr)==typeid(NonterminalExpressionInParentheses))
	{
		NonterminalExpressionInParentheses &expr_p=*dynamic_cast<NonterminalExpressionInParentheses *>(expr);
		return expand_proc(expr_p.expr);
	}
	else if(typeid(*expr)==typeid(NonterminalExpressionIteration))
		assert(false);
	else if(typeid(*expr)==typeid(NonterminalExpressionCondition))
	{
		NonterminalExpressionCondition &expr_cond=*dynamic_cast<NonterminalExpressionCondition *>(expr);
		
		return expand_proc(expr_cond.condition);
	}
	else if(typeid(*expr)==typeid(NonterminalExpressionRange))
	{
		NonterminalExpressionRange &expr_r=*dynamic_cast<NonterminalExpressionRange *>(expr);
		
		return UnionOfIntervals<int>(expr_r.first, expr_r.last);
	}
	else if(typeid(*expr)==typeid(NonterminalExpressionContains))
		assert(false);
	else if(typeid(*expr)==typeid(NonterminalExpressionEpsilon))
		assert(false);
	else if(typeid(*expr)==typeid(NonterminalExpressionSharpSign))
	{
		return UnionOfIntervals<int>(numeric_limits<int>::min(), numeric_limits<int>::max());
	}
	else if(typeid(*expr)==typeid(NonterminalExpressionSymbol))
	{
		NonterminalExpressionSymbol &expr_s=*dynamic_cast<NonterminalExpressionSymbol *>(expr);
		return expand_proc(expr_s.expr);
	}
	else
		assert(false);
	
	return UnionOfIntervals<int>(); // to please the compiler
}

void expand_proc_ii(NonterminalExpression *expr)
{
	if(typeid(*expr)==typeid(NonterminalExpressionDisjunction))
	{
		NonterminalExpressionDisjunction &expr_d=*dynamic_cast<NonterminalExpressionDisjunction *>(expr);
		expand_proc_ii(expr_d.expr1);
		expand_proc_ii(expr_d.expr2);
	}
	else if(typeid(*expr)==typeid(NonterminalExpressionConjunction))
	{
		NonterminalExpressionConjunction &expr_c=*dynamic_cast<NonterminalExpressionConjunction *>(expr);
		expand_proc_ii(expr_c.expr1);
		expand_proc_ii(expr_c.expr2);
	}
	else if(typeid(*expr)==typeid(NonterminalExpressionConcatenation))
	{
		NonterminalExpressionConcatenation &expr_cat=*dynamic_cast<NonterminalExpressionConcatenation *>(expr);
		expand_proc_ii(expr_cat.expr1);
		expand_proc_ii(expr_cat.expr2);
	}
	else if(typeid(*expr)==typeid(NonterminalExpressionComplement))
	{
		NonterminalExpressionComplement &expr_com=*dynamic_cast<NonterminalExpressionComplement *>(expr);
		expand_proc_ii(expr_com.expr);
	}
	else if(typeid(*expr)==typeid(NonterminalExpressionOmittable))
	{
		NonterminalExpressionOmittable &expr_om=*dynamic_cast<NonterminalExpressionOmittable *>(expr);
		expand_proc_ii(expr_om.expr);
	}
	else if(typeid(*expr)==typeid(NonterminalExpressionInParentheses))
	{
		NonterminalExpressionInParentheses &expr_p=*dynamic_cast<NonterminalExpressionInParentheses *>(expr);
		expand_proc_ii(expr_p.expr);
	}
	else if(typeid(*expr)==typeid(NonterminalExpressionIteration))
	{
		NonterminalExpressionIteration &expr_it=*dynamic_cast<NonterminalExpressionIteration *>(expr);
		expand_proc_ii(expr_it.expr);
	}
	else if(typeid(*expr)==typeid(NonterminalExpressionCondition))
	{
		NonterminalExpressionCondition &expr_cond=*dynamic_cast<NonterminalExpressionCondition *>(expr);
		expr->expanded=new UnionOfIntervals<int>(expand_proc(expr_cond.condition));
	}
	else if(typeid(*expr)==typeid(NonterminalExpressionRange))
	{
	}
	else if(typeid(*expr)==typeid(NonterminalExpressionContains))
	{
		NonterminalExpressionContains &expr_cont=*dynamic_cast<NonterminalExpressionContains *>(expr);
		expand_proc_ii(expr_cont.expr);
	}
	else if(typeid(*expr)==typeid(NonterminalExpressionEpsilon))
	{
	}
	else if(typeid(*expr)==typeid(NonterminalExpressionSharpSign))
	{
	}
	else if(typeid(*expr)==typeid(NonterminalExpressionSymbol))
	{
	}
	else
		assert(false);
}

UnionOfIntervals<int> expand_proc(NonterminalExpressionS *expr)
{
	if(expr->is_nts)
	{
		NonterminalData &nonterminal=data.nonterminals[expr->nn];
		assert(nonterminal.expanded);
		return *nonterminal.expanded;
	}
	else
	{
		assert(expr->s.size()==1);
		return UnionOfIntervals<int>(expr->s[0]);
	}
}

UnionOfIntervals<int> expand_proc(NonterminalExpressionC *expr)
{
	if(typeid(*expr)==typeid(NonterminalExpressionC_Disjunction))
	{
		NonterminalExpressionC_Disjunction &expr_d=*dynamic_cast<NonterminalExpressionC_Disjunction *>(expr);
		return expand_proc(expr_d.expr1) | expand_proc(expr_d.expr2);
	}
	else if(typeid(*expr)==typeid(NonterminalExpressionC_Conjunction))
	{
		NonterminalExpressionC_Conjunction &expr_c=*dynamic_cast<NonterminalExpressionC_Conjunction *>(expr);
		return expand_proc(expr_c.expr1) & expand_proc(expr_c.expr2);
	}
	else if(typeid(*expr)==typeid(NonterminalExpressionC_Complement))
	{
		NonterminalExpressionC_Complement &expr_com=*dynamic_cast<NonterminalExpressionC_Complement *>(expr);
		return ~expand_proc(expr_com.expr);
	}
	else if(typeid(*expr)==typeid(NonterminalExpressionC_InParentheses))
	{
		NonterminalExpressionC_InParentheses &expr_p=*dynamic_cast<NonterminalExpressionC_InParentheses *>(expr);
		return expand_proc(expr_p.expr);
	}
	else if(typeid(*expr)==typeid(NonterminalExpressionC_Comparison))
	{
		NonterminalExpressionC_Comparison &expr_cmp=*dynamic_cast<NonterminalExpressionC_Comparison *>(expr);
		
		if(expr_cmp.actual_operation==NonterminalExpressionC_Comparison::EQ)
			return UnionOfIntervals<int>(expr_cmp.symbol);
		else if(expr_cmp.actual_operation==NonterminalExpressionC_Comparison::NE)
			return ~UnionOfIntervals<int>(expr_cmp.symbol);
		else if(expr_cmp.actual_operation==NonterminalExpressionC_Comparison::LT)
			return UnionOfIntervals<int>(numeric_limits<int>::min(), expr_cmp.symbol-1);
		else if(expr_cmp.actual_operation==NonterminalExpressionC_Comparison::LE)
			return UnionOfIntervals<int>(numeric_limits<int>::min(), expr_cmp.symbol);
		else if(expr_cmp.actual_operation==NonterminalExpressionC_Comparison::GT)
			return UnionOfIntervals<int>(expr_cmp.symbol+1, numeric_limits<int>::max());
		else if(expr_cmp.actual_operation==NonterminalExpressionC_Comparison::GE)
			return UnionOfIntervals<int>(expr_cmp.symbol, numeric_limits<int>::max());
		else
			assert(false);
	}
	else if(typeid(*expr)==typeid(NonterminalExpressionC_In))
	{
		NonterminalExpressionC_In &expr_in=*dynamic_cast<NonterminalExpressionC_In *>(expr);
		NonterminalData &nonterminal=data.nonterminals[expr_in.nn];
		assert(nonterminal.expanded);
		return *nonterminal.expanded;
	}
	else if(typeid(*expr)==typeid(NonterminalExpressionC_Constant))
	{
		NonterminalExpressionC_Constant &expr_const=*dynamic_cast<NonterminalExpressionC_Constant *>(expr);
		
		if(expr_const.value) // true
			return UnionOfIntervals<int>(numeric_limits<int>::min(), numeric_limits<int>::max());
		else // false
			return UnionOfIntervals<int>();
	}
	else
		assert(false);
	
	return UnionOfIntervals<int>(); // to please the compiler
}

bool expand_what_can_be_expanded()
{
	int n=data.nonterminals.size();
	
	// making a set of all nonterminals derivable from 'in' expressions.
	bool *nonterminals_in_question=new bool[n];
	int number_of_nonterminals_in_question=0;
	for(int i=0; i<n; i++)
	{
		bool value=false;
		
		if(data.nonterminals[i].is_used_in_IN_expressions)
			value=true;
		else
			for(int j=0; j<n; j++)
				if(j!=i && data.derivation_paths[j][i].v.size()
					&& data.nonterminals[j].is_used_in_IN_expressions)
				{
					value=true;
					break;
				}
		
		nonterminals_in_question[i]=value;
		if(value) number_of_nonterminals_in_question++;
	}

#ifdef DEBUG_EXPANDED_NONTERMINALS
	if(number_of_nonterminals_in_question)
		cout << "Expanding " << number_of_nonterminals_in_question << " nonterminals\n";
#endif
	
	// expanding (replacing with sets of terminals) all nonterminals
	// one by one.
	while(number_of_nonterminals_in_question)
	{
		// searching for a nonterminal that is ready to be expanded
		// (i.e. all nonterminals referenced by this one have already
		// been expanded)
		
		int nn=-1;
		for(int i=0; i<n; i++)
		{
			if(!nonterminals_in_question[i]) continue;
			
			bool it_is_ready=true;
			for(int j=0; j<n; j++)
				if(nonterminals_in_question[j] &&
					data.derivation_paths[i][j].v.size())
				{
					it_is_ready=false;
					break;
				}
			if(it_is_ready)
			{
				nn=i;
				break;
			}
		}
		
		if(nn==-1)
		{
			cout << "\n\n\texpand_what_can_be_expanded():";
			cout << "Found a previously undetected error in grammar.\n";
			cout << "Something's wrong around nonterminal" << (number_of_nonterminals_in_question==1 ? " " : "s ");
			int p=0;
			for(int i=0; i<n; i++)
				if(nonterminals_in_question[i])
				{
					if(p==number_of_nonterminals_in_question-1)
						cout << " and ";
					else if(p)
						cout << ", ";
					p++;
					cout << data.nonterminals[i].name;
				}
			cout << ".\n\n";
			assert(false);
		}
		
	#ifdef DEBUG_EXPANDED_NONTERMINALS
		cout << "processing nonterminal " << data.nonterminals[nn].name << "\n";
	#endif
		
		assert(data.nonterminals[nn].rules.size()==1);
		data.nonterminals[nn].expanded=new UnionOfIntervals<int>(expand_proc(data.nonterminals[nn].rules[0]->right));
		
	#ifdef DEBUG_EXPANDED_NONTERMINALS
		cout << *(data.nonterminals[nn].expanded) << "\n";
	#endif
		
		assert(nonterminals_in_question[nn]);
		nonterminals_in_question[nn]=false;
		number_of_nonterminals_in_question--;
	}
	
	// All nonterminals used in 'in' expressions have been expanded.
	//
	// Now making a pass through all rules and actions (except rules for
	// those nonterminals that have already been expanded), expanding the
	// following:
	// i. All 'condition' statements;
	// ii. All subexpressions that can be expanded;
	// iii. All nonterminals that can be expanded.
	for(int i=0; i<n; i++)
		if(!data.nonterminals[i].expanded)
			expand_proc_ii(data.nonterminals[i].rules[0]->right);
	for(int i=0; i<data.recognized_expressions.size(); i++)
	{
		RecognizedExpressionData &re=data.recognized_expressions[i];
		if(re.is_special) continue;
		
		expand_proc_ii(re.expr);
		if(re.lookahead)
			expand_proc_ii(re.lookahead);
	}
	
	return true;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品美女一区二区| 4438x成人网最大色成网站| 日精品一区二区| 一区二区三区**美女毛片| 久久久91精品国产一区二区三区| 日韩一区二区三区电影| 欧美色爱综合网| 日韩精品一区二区三区老鸭窝| 色www精品视频在线观看| 成人性色生活片| 国产精品亚洲第一区在线暖暖韩国| 日韩综合一区二区| 图片区小说区区亚洲影院| 亚洲成av人片www| 亚洲一区二区三区四区中文字幕| 有码一区二区三区| 亚洲电影一区二区| 日本va欧美va瓶| 久久精品国产亚洲aⅴ| 加勒比av一区二区| 国产福利一区二区三区视频| 国产成人99久久亚洲综合精品| 国内精品视频666| 国产精品白丝jk白祙喷水网站 | 国产一区二区影院| 国产精品一区二区无线| 成人高清av在线| 欧美亚洲高清一区二区三区不卡| 欧美日韩中文字幕一区| 日韩免费高清av| 亚洲国产精品成人综合| 一区二区三区不卡在线观看| 日本不卡视频在线| 国产91丝袜在线播放| 91热门视频在线观看| 欧美欧美午夜aⅴ在线观看| 精品久久久影院| 18成人在线观看| 日韩成人精品在线观看| 国产精品中文字幕日韩精品| 91欧美一区二区| 9191精品国产综合久久久久久| 久久综合av免费| 亚洲韩国精品一区| 国产成都精品91一区二区三| 欧洲视频一区二区| 精品999久久久| 亚洲一区二区三区自拍| 国产一区欧美一区| 欧美日韩精品欧美日韩精品一 | 另类的小说在线视频另类成人小视频在线| 国产毛片精品视频| 精品视频在线免费观看| 国产欧美一区二区精品仙草咪| 亚洲福利国产精品| va亚洲va日韩不卡在线观看| 欧美一区二区三区视频免费| 亚洲色图在线视频| 国产成人福利片| 911精品国产一区二区在线| 欧美国产欧美综合| 六月丁香婷婷色狠狠久久| 色婷婷久久久综合中文字幕| 亚洲精品一区二区三区精华液 | 欧美日韩国产天堂| 国产精品久久久一区麻豆最新章节| 欧美96一区二区免费视频| 色悠久久久久综合欧美99| 国产日产精品1区| 91日韩精品一区| 国产亚洲综合av| 毛片av一区二区| 欧美日韩mp4| 亚洲国产欧美在线| 色噜噜狠狠成人网p站| 精品国产免费一区二区三区香蕉| 亚洲高清免费一级二级三级| 91丨九色porny丨蝌蚪| 欧美激情一区二区三区四区| 国内精品视频666| 久久精品视频在线免费观看| 麻豆精品一区二区三区| 精品久久一区二区| 精品一区二区三区香蕉蜜桃| 精品三级av在线| 看片的网站亚洲| 久久伊人中文字幕| 免费不卡在线视频| 精品国产露脸精彩对白| 久久国产精品一区二区| 26uuu国产在线精品一区二区| 免费欧美日韩国产三级电影| 精品国产百合女同互慰| 国产一本一道久久香蕉| 国产亚洲综合色| 成人丝袜18视频在线观看| 国产精品国产三级国产aⅴ中文| 成人av资源在线| 亚洲自拍偷拍麻豆| 5月丁香婷婷综合| 狠狠色2019综合网| 国产蜜臀97一区二区三区| 97久久精品人人爽人人爽蜜臀| 夜夜嗨av一区二区三区网页| 欧美日韩免费视频| 免费视频最近日韩| 国产人伦精品一区二区| 色一区在线观看| 免费三级欧美电影| 国产精品另类一区| 欧美视频在线不卡| 激情av综合网| 亚洲另类一区二区| 日韩欧美一二三四区| av电影一区二区| 秋霞午夜鲁丝一区二区老狼| 国产欧美一区二区精品仙草咪 | 色婷婷一区二区| 久久99久久99精品免视看婷婷| 国产精品三级电影| 欧美酷刑日本凌虐凌虐| 国内精品国产成人国产三级粉色 | 亚洲在线观看免费| 国产日本亚洲高清| 69久久夜色精品国产69蝌蚪网| 精品一区二区精品| 亚洲成人av中文| 欧美激情综合在线| 日韩一本二本av| 色综合久久久久网| 国产乱人伦精品一区二区在线观看 | 亚洲人成伊人成综合网小说| 日韩视频中午一区| 色猫猫国产区一区二在线视频| 久久福利资源站| 一区二区三区加勒比av| 国产精品女人毛片| 久久综合久久99| 欧美一区二区成人| 91国产丝袜在线播放| 高清国产午夜精品久久久久久| 日韩精品成人一区二区在线| 亚洲精品中文在线观看| 国产欧美精品一区二区色综合朱莉 | 国产美女精品人人做人人爽| 日韩av一二三| 亚洲国产cao| 亚洲黄色免费网站| 一区精品在线播放| 亚洲国产精华液网站w | 经典三级视频一区| 裸体一区二区三区| 男人的天堂亚洲一区| 日韩国产一二三区| 婷婷综合另类小说色区| 亚洲电影在线免费观看| 一区二区欧美在线观看| 亚洲免费伊人电影| 亚洲人成小说网站色在线 | 在线视频你懂得一区| 一本大道av伊人久久综合| 97精品久久久午夜一区二区三区| 丁香六月久久综合狠狠色| 成人一区二区三区在线观看| 国产成人自拍高清视频在线免费播放| 麻豆国产精品一区二区三区 | 久久久久久久久久美女| 国产亚洲一区字幕| 国产欧美日韩久久| 中文字幕在线观看一区二区| 国产精品国产三级国产a| 亚洲精品视频自拍| 亚洲高清免费观看高清完整版在线观看| 夜夜嗨av一区二区三区四季av| 午夜一区二区三区视频| 麻豆精品一区二区三区| 粉嫩aⅴ一区二区三区四区 | 色综合天天综合网天天狠天天 | 欧美精选在线播放| 欧美成人一区二区| 国产视频在线观看一区二区三区| 国产精品初高中害羞小美女文| 一区二区三区自拍| 麻豆国产精品官网| 不卡av在线免费观看| 欧美日韩精品欧美日韩精品一综合| 欧美一卡二卡三卡| 中文无字幕一区二区三区| 亚洲欧美日韩中文字幕一区二区三区 | 精品欧美乱码久久久久久| 日韩美女视频在线| 精品久久久久99| 久久精品人人爽人人爽| 国产精品动漫网站| 亚洲伊人色欲综合网| 天天综合天天做天天综合| 亚洲国产欧美一区二区三区丁香婷| 亚洲国产精品久久一线不卡| 久久国产视频网| av在线一区二区三区|