当前位置: 首页>>代码示例>>C++>>正文


C++ Lex::StartDynamic方法代码示例

本文整理汇总了C++中Lex::StartDynamic方法的典型用法代码示例。如果您正苦于以下问题:C++ Lex::StartDynamic方法的具体用法?C++ Lex::StartDynamic怎么用?C++ Lex::StartDynamic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lex的用法示例。


在下文中一共展示了Lex::StartDynamic方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: convert_async

void convert_async(Lex& lex, const char *class_name, FILE *h, FILE *cpp)
{
	int		t, l;
	const char	*s, *e;
	Param		*params, *last, *next;
	bool		keep_params, timed_async, dynamic_event;

	keep_params = false;
	timed_async = false;
	dynamic_event = false;

	// we can have multiple dynamic as long as each have a different
	// function name; also, we need to mark them as being timed if
	// the timed flag is also specified
	lex.StartDynamic();

// first we parse the function
	// skip spaces
	do {
		t = lex.GetToken();
	} while(isspace(t) || t == '\n');
	if(t == '\0') {
eof:
		fprintf(stderr, "%s:%ld: error: EOF reached within an async declaration\n", lex.Filename(), lex.Line());
		g_errcnt++;
		return;
	}

	if(t != Lex::IDENTIFIER) {
		fprintf(stderr, "%s:%ld: error: async not followed by an identifier\n", lex.Filename(), lex.Line());
		g_errcnt++;
		return;
	}

	// we expect the name of the function
	s = lex.GetStart();
	e = lex.GetEnd();
	l = static_cast<int>(e - s);
	char* name = new char[l + 1];
	str_keeper sk(name);
	memcpy(name, s, l);
	name[l] = '\0';

	do {
		t = lex.GetToken();
	} while(isspace(t) || t == '\n');
	if(t == '\0') {
		goto eof;
	}

	if(t != '(') {
		fprintf(stderr, "%s:%ld: error: async function name not followed by (\n", lex.Filename(), lex.Line());
		g_errcnt++;
		return;
	}

	// now we read the parameters
	last = params = 0;
	do {
		t = get_param(lex, next);
		if(next != 0) {
			if(last != 0) {
				last->f_next = next;
			}
			if(params == 0) {
				params = next;
			}
			last = next;
		}
	} while(t != ')' && t != '\0');
	if(t == '\0') {
		goto eof;
	}

	// right after the ')' we can have a dynamic attribute!
	// the syntax is:
	//	__attribute__ ((dynamic[([<identifier>])]))
	do {
		 t = lex.GetToken();
	} while(isspace(t) || t == '\n');
	if(t != Lex::IDENTIFIER) {
		goto no_attribute;
	}
	s = lex.GetStart();
	e = lex.GetEnd();
	l = static_cast<int>(e - s);
	if(l != 13 || memcmp(s, "__attribute__", l) != 0) {
		fprintf(stderr, "%s:%ld: error: the keyword __attribute__ or = 0 was expected\n", lex.Filename(), lex.Line());
		g_errcnt++;
		goto skip_attr;
	}
	do {
		 t = lex.GetToken();
	} while(isspace(t) || t == '\n');
	if(t != '(') {
		fprintf(stderr, "%s:%ld: error: the keyword __attribute__ is expected to be followed by two '('\n", lex.Filename(), lex.Line());
		g_errcnt++;
		goto skip_attr;
	}
	do {
//.........这里部分代码省略.........
开发者ID:m2osw,项目名称:turnwatcher,代码行数:101,代码来源:async_functions.cpp


注:本文中的Lex::StartDynamic方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。