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

📄 jsp_parser.cpp

📁 嵌入式系统开发 TOPPERS and JSP Kernel Release 1.3 TOPPERS = Toyohashi Open Platform for Embedded Real-Tim
💻 CPP
📖 第 1 页 / 共 2 页
字号:
#include <stdarg.h>#include "jsp_classes.h"#include "mpstrstream.h"#include <set>using namespace std;void CoreParser::parseOption(Directory & container){	ParserComponent::parseOption(container);	if(findOption(container,"h","help"))	{        cout << Message(			"  -obj, --dump-object=filename : Dump the object tree into the file specified\n"            "  -ao, --assign-order=order : Specify the order of automatic ID assignment\n"			"    You can use three terms below as ordering rule.\n"            "     alphabetic (in alphabetic order)\n"			"     fcfs       (in arrival order [as default])\n"			"     reverse    (reverse the order)\n",			"  -obj, --dump-object=ファイル叹 : 回年したファイルにオブジェクト攫鼠を叫蜗します\n"            "  -ao, --assign-order=界进 : 极瓢ID充碰の充碰界进を回年します\n"			"    充碰界进は肌の3つの寥圭せで回年します.\n"            "     alphabetic (ABC界), fcfs (离咐界 [デフォルト]), reverse (嫡界)\n");        return;	}}static int displayHandler(Directory & container, const char * category, const char * format){	Directory * node;	Directory * scope;	node = container.findChild(OBJECTTREE,category,NULL);	if(node == 0 || node->size() == 0)		return 0;	VerboseMessage("Handler assignment list [%s]\n","ハンドラ充烧山 [%s]\n").format(category);	scope = node->getFirstChild();	while(scope != 0)	{		VerboseMessage::print(scope->format(format));		scope = scope->getNext();	}	return node->size();}int CoreParser::assignID(Directory & container, const char * category){	Directory * node;	Directory * scope;	Directory * work;	set<int> idpool;	map<int, Directory *> sorter;	map<int, Directory *>::iterator p_sorter;	enum tagAssignmentOrder { UNKNOWN, ALPHABETIC, FCFS, REVERSE=0x80, REVERSE_ALPHABETIC, REVERSE_FCFS } order;	int i;		//充碰パラメ〖タ豺老	i = FCFS;	node = getOption(container,"ao","assign-order");	if(node != 0)	{		scope = node->getFirstChild();		while(scope != 0)		{			string param = scope->toString();			if(param.compare("alphabetic") == 0 || param.compare("ALPHABETIC") == 0)				i = (i & 0xf0) | ALPHABETIC;			else if(param.compare("fcfs") == 0 || param.compare("FCFS") == 0)				i = (i & 0xf0) | FCFS;			else if(param.compare("reverse") == 0 || param.compare("REVERSE") == 0)				i |= REVERSE;			scope = scope->getNext();		}	}	order = static_cast<enum tagAssignmentOrder>(i);		//布洁洒	node = container.findChild(OBJECTTREE,category,NULL);	if(node == 0)		return 0;	for(i=1;i< (signed int) node->size() + 32; i++)		idpool.insert(i);		//充烧界の疯年と·充碰貉みIDの猴近	i = 0;	scope = node->getFirstChild();	while(scope != 0)	{		if( *scope == Directory::INTEGER )			idpool.erase(*scope);		else		{			switch(order)			{			case ALPHABETIC:				sorter[i++] = scope;				break;			case REVERSE_ALPHABETIC:				sorter[i--] = scope;				break;			case FCFS:			default:				sorter[scope->openChild("#order")->toInteger()] = scope;				break;			case REVERSE_FCFS:				sorter[-scope->openChild("#order")->toInteger()] = scope;				break;			}		}		scope = scope->getNext();	}		//ID充碰	p_sorter = sorter.begin();	while(p_sorter != sorter.end())	{		scope = (*p_sorter).second;		if( !(*scope == Directory::INTEGER) )		{			work = container.openChild("/","identifier",scope->getKey().c_str(),NULL);			if(*work == Directory::INTEGER)			{				i = work->toInteger();				idpool.erase(i);				VerboseMessage("Assigning the same ID (%d) since the name (%s[%s]) is duplicated\n","ID戎规(%d)を佰硷票叹のオブジェクト(%s[%s])に充り碰てますˉ\n").format(i,scope->getKey().c_str(),category);			}else			{				i = *(idpool.begin());				*work = i;				idpool.erase(idpool.begin());			}			*scope = i;		}		p_sorter ++;	}		//充碰山侯喇	if(node->size() != 0 && VerboseMessage::getVerbose())	{		VerboseMessage("Object ID assignment list [%s]\n","オブジェクトID充烧山 [%s]\n").format(category);		sorter.clear();		scope = node->getFirstChild();		while(scope != 0)		{			sorter[scope->toInteger()] = scope;			scope = scope->getNext();		}		p_sorter = sorter.begin();		while(p_sorter != sorter.end())		{			VerboseMessage("  %3d : %s\n","  %3d : %s\n").format((*p_sorter).first, (*p_sorter).second->getKey().c_str());			p_sorter ++;		}	}		//屡碰拉の冉年	if((signed)node->size()+1 != *(idpool.begin()))		Exception("Discontinuous %s ID assignment occured","稍息鲁なオブジェクトID(%s)").format(category);	return node->size();}bool CoreParser::parse(Parser & p, Directory & container){	Token token;	try{		do {			p.getToken(token);			this->parseStaticAPI(p, container, token);		}while(token != Token::EOS);		if(assignID(container, TASK) == 0)			Exception("Kernel requires one or more task objects.","タスクオブジェクトがありません");		assignID(container, SEMAPHORE);		assignID(container, EVENTFLAG);		assignID(container, DATAQUEUE);		assignID(container, MAILBOX);		assignID(container, FIXEDSIZEMEMORYPOOL);		assignID(container, CYCLICHANDLER);		displayHandler(container, INTERRUPTHANDLER, "  $@ : $(inthdr)\n");		displayHandler(container, EXCEPTIONHANDLER, "  $@ : $(exchdr)\n");		displayHandler(container, INITIALIZER, "  $@ : $(inirtn)($(exinf))\n");		displayHandler(container, FINALIZER, "  $@ : $(finrtn)($(exinf))\n");		return true;	}	catch(Exception * e)	{	throw e;	}}DECLARE_DIRECTIVE(assigner,"assign_id"){	Token name;	Token value;	p.getToken(name, Token::IDENTIFIER);	p.getToken(value, Token::INTEGER);	if(value.value <= 0)		Exception("Cannot assign an ID number less or equal to 0.","0笆布のID戎规を肋年することはできません");	*container.openChild("/","identifier",name.c_str(),NULL) = value.value;}DECLARE_DIRECTIVE(parameter,"parameter"){	Token token;	string key;	string::size_type i,j;	do {		p.getToken(token);		if(!(token == Token::STRINGLITERAL))			Exception("parameter pragma requires additional parameter put in '\"...\"'","parameterプラグマには\"...\"で崇られた纳裁パラメ〖タが涩妥です");		token.chopLiteral();		if(token[0] == '-')		{			i = token.find_first_of('=');			j = token.find_first_not_of('-');			if(i == j || j == string::npos)                Exception(Exception::FATAL,"Wrong option [%s]","稍赖なオプション [%s]").format(token.c_str());			if(i != string::npos)			{				key = DEFAULT_PARAMETER;				*container.openChild(string("/Parameter/") + token.substr(1, i-1)) = token.substr(i+1);			}			else			{				key = token.substr(1);				*container.openChild(string("/Parameter/") + key) = string("");			}		}else			*container.openChild(string("/Parameter/") + key) = token;		p.getToken(token);	} while(token.compare(",") == 0);	p.putBack(token);}//=====================================================================================================void ConfigurationFileGenerator::parseOption(Directory & parameter){	string work;	mpstrstream * stream;	if(findOption(parameter,"h","help"))	{

⌨️ 快捷键说明

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