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


C++ tokenizer::next_token方法代码示例

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


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

示例1: stmt_def_field

	inline stmt_def_field(const statement&parent,const token&tk,tokenizer&t):
		statement{parent,tk},
		ident_{t.next_token()}
	{
		if(ident_.is_name(""))
			throw compiler_error(ident_,"expected field name");

		if(!t.is_next_char('{'))
			throw compiler_error(ident_,"expected '{' initial value   then '}' ",ident_.name());

		while(true){
			if(t.is_next_char('}'))break;
			tokens_.push_back(t.next_token());
		}
	}
开发者ID:calint,项目名称:compiler-2,代码行数:15,代码来源:stmt_def_field.hpp

示例2: stmt_def_func_param

	inline stmt_def_func_param(const statement&parent,tokenizer&t):
		statement{parent,t.next_token()}
	{
		assert(!tok().is_name(""));

		if(!t.is_next_char(':'))
			return;

		while(true){
			if(t.is_eos())throw compiler_error(*this,"unexpected end of stream",tok().name_copy());
			keywords_.push_back(t.next_token());
			if(t.is_next_char(':'))
					continue;
			break;
		}
	}
开发者ID:calint,项目名称:compiler-2,代码行数:16,代码来源:stmt_def_func_param.hpp

示例3:

inline unique_ptr<statement>create_statement_from_tokenizer(const statement&parent,tokenizer&t){
	auto tk=t.next_token();
	if(tk.is_name("#"))return make_unique<stmt_comment>(parent,move(tk),t);// ie    print("hello") // comment
	if(t.is_peek_char('('))return create_call_statement_from_tokenizer(parent,move(tk),t); // ie  f(...)
	return make_unique<statement>(parent,move(tk));// ie  0x80
}
开发者ID:calint,项目名称:compiler-2,代码行数:6,代码来源:main.cpp


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