• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ parse_error函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中parse_error函数的典型用法代码示例。如果您正苦于以下问题:C++ parse_error函数的具体用法?C++ parse_error怎么用?C++ parse_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: err_msg

std::vector<std::string> wtss::cxx::client::list_coverages() const
{

  rapidjson::Document doc;
  doc.Parse<0>(wtss::cxx::request(
    wtss::cxx::client::server_uri + "/list_coverages").c_str());

  if (doc.HasParseError())
  {
    boost::format err_msg("Error parsing requested document '%1%/list_coverages: %2%.");

    throw parse_error() << error_description(
      (err_msg % server_uri %doc.GetParseError()).str());
  }

  if (!doc.IsObject())
    throw parse_error() << error_description(
        "Invalid JSON document: expecting a object!");

  if (!doc.HasMember("coverages"))
    throw parse_error() << error_description(
        "Invalid JSON document: expecting a member named \"coverages\"!");

  const rapidjson::Value& j_coverages = doc["coverages"];

  if (!j_coverages.IsArray())
    throw parse_error() << error_description(
        "Invalid JSON document: member named \"coverages\" must be an array!");

  std::vector<std::string> result;

  for (rapidjson::Value::ConstValueIterator itr = j_coverages.Begin();
       itr != j_coverages.End(); ++itr)
    result.push_back(itr->GetString());

  return result;
}
开发者ID:e-sensing,项目名称:wtss.cxx,代码行数:37,代码来源:wtss.cpp


示例2: process_set

/*
 * Parses a set element.
 */
static apr_status_t process_set (parser_rec *p, const char *element,
		int states, apr_table_t *attrs) {
        template_node_t *n;
	const char *names;
        char *name, *last;
        const char *sep = ", \t";
        int status;

        if ((states & TEMPLATE_SOPEN) != 0) {
		n = (template_node_t *) apr_array_push(p->t);
		n->type = TEMPLATE_TSET;
                n->set_names = apr_array_make(p->pool, 2, sizeof(const char *));
                names = apr_table_get(attrs, "names");
                if (names == NULL) {
                        return parse_error(p, "missing attribute 'names'");
                }
                name = apr_strtok(apr_pstrdup(p->pool, names), sep, &last);
                while (name != NULL) {
                        *((char **) apr_array_push(n->set_names)) = name;
                        name = apr_strtok(NULL, sep, &last);
                }
                if (apr_is_empty_array(n->set_names)) {
                        return parse_error(p, "empty 'names'");
                }
                n->set_expressions = apr_table_get(attrs, "expressions");
                if (n->set_expressions == NULL) {
                        return parse_error(p, "missing attribute "
					"'expressions'");
                }
                if ((status = compile_exp(p, n->set_expressions, &n->set_index))
				!= APR_SUCCESS) {
                        return status;
                }
	}

	return APR_SUCCESS;
}
开发者ID:diroussel,项目名称:lua-web-tools,代码行数:40,代码来源:template.c


示例3: parse_error

bool
ConstVarDecl::parse(std::ostream & os, std::shared_ptr<Context> context) {
	auto toker = context->getTokenizer();

	m_position = toker->position();
	bool flag = true;

	m_ident = toker->word();

    // add a constant declaration
    if(context->createConstant_llvm(m_ident, nullptr) == false) {
        parse_error(os, context, "Redefinition of constant: " + m_ident);
        flag = false;
    }//if

	toker->next(); // eat the current identifier

	if(toker->token() != Token::tk_equal) {
		parse_error(os, context, "expect an '=' here for const identifier initialization");
		flag = false;
	} else {
		toker->next(); // eat the current '='
	}//if-else

	if(flag == true && toker->token() == Token::tk_number) {
		// make_unique was overlooked by c++11, a simple implementation
		auto int_num = auc::make_unique<IntegerLiteral>();
		if(!int_num->parse(os, context))
			flag = false;
		m_node = std::move(int_num);
	} else {
		parse_error(os, context, "A const declearation must be initialized with a integer number.");
		flag = false;
	}//if-else

	return flag;
}//parse(os, context)
开发者ID:adamcavendish,项目名称:PL0Compiler,代码行数:37,代码来源:ConstVarDecl.cpp


示例4: parse_error

void help_text_area::handle_jump_cfg(const config &cfg)
{
	const std::string amount_str = cfg["amount"];
	const std::string to_str = cfg["to"];
	if (amount_str == "" && to_str == "") {
		throw parse_error("Jump markup must have either a to or an amount attribute.");
	}
	unsigned jump_to = curr_loc_.first;
	if (amount_str != "") {
		unsigned amount;
		try {
			amount = lexical_cast<unsigned, std::string>(amount_str);
		}
		catch (bad_lexical_cast) {
			throw parse_error("Invalid amount the amount attribute in jump markup.");
		}
		jump_to += amount;
	}
	if (to_str != "") {
		unsigned to;
		try {
			to = lexical_cast<unsigned, std::string>(to_str);
		}
		catch (bad_lexical_cast) {
			throw parse_error("Invalid amount in the to attribute in jump markup.");
		}
		if (to < jump_to) {
			down_one_line();
		}
		jump_to = to;
	}
	if (jump_to != 0 && static_cast<int>(jump_to) <
            get_max_x(curr_loc_.first, curr_row_height_)) {

		curr_loc_.first = jump_to;
	}
}
开发者ID:PositiveMD,项目名称:wesnoth,代码行数:37,代码来源:help_text_area.cpp


示例5: vardecl

static AST vardecl() { /* TODO: allow vars */
    Token *t = &tok;
    AST a=0;
    AST a1=0,a2=0,a3=0,a4=0;
    AST ft;
    int idx;

    a2 = typedecl();
    a1 = var();		

    if (t->sym == '(') { /* oops, it was func */
	gettoken();
	set_nodetype(a1, nNAME); /* change to NAME */
	insert_SYM(get_text(a1), ft=func_type(gen(fLOCAL),a2), fLOCAL,0 /* dummy */ );

	a3 = argdecls();
	set_argtypeofnode(ft,a3);

	if (t->sym == ')') gettoken();
	else parse_error("expected )");

	a4 = block();
	a  = make_AST_funcdecl(a1, a2, a3, a4);
    } else if (t->sym == ';') { /* vardecl */
	a = make_AST_vardecl(a1, a2, 0, 0);
	idx = insert_SYM(get_text(a1), a2, vLOCAL, a1); 
	set_ival(a1,idx);
	/*
	   } else if (t->sym == ',') {  // multiple vars 
	 *     contents must be made
	 *
	 */
    } else {
	parse_error("expected ; or (");
    }
    return a;
}
开发者ID:tungvx,项目名称:FSE,代码行数:37,代码来源:parser2.c


示例6: g_spawn_sync

void TinySpawn::run()
{
  // Working directory.
  const gchar *workingdirectory = NULL;
  if (!myworkingdirectory.empty())
    workingdirectory = myworkingdirectory.c_str();
  // Store arguments in argv.
  char *argv [arguments.size() + 2];
  argv[0] = (char *)myprogram;
  for (unsigned int i = 0; i < arguments.size(); i++) {
    argv[i + 1] = (char *)arguments[i].c_str();
  }
  // Terminate argv.
  argv[arguments.size() + 1] = NULL;
  // Spawn flags.
  int flags = G_SPAWN_SEARCH_PATH;
  // Possible pipes.
  gchar *standard_output = NULL;
  gchar *standard_error = NULL;
  gchar **standard_output_pointer = NULL;
  gchar **standard_error_pointer = NULL;
  if (myread) {
    standard_output_pointer = &standard_output;
    standard_error_pointer = &standard_error;
  }
  // Spawn process.
  result = g_spawn_sync(workingdirectory, argv, NULL, (GSpawnFlags) flags, NULL, NULL, standard_output_pointer, standard_error_pointer, &exitstatus, NULL);
  // Handle case we didn't spawn the process.
  if (!result) {
    exitstatus = -1;
    string message = myprogram;
    message.append(_(" didn't spawn"));
    g_critical("%s", message.c_str());
    return;
  }
  // Handle reading the output.
  if (myread) {
    // In sync mode we have gchar * output.
    ParseLine parse_output (standard_output);
    standardout = parse_output.lines;
    ParseLine parse_error (standard_error);
    standarderr = parse_error.lines;
    // Free data.
    if (standard_output)
      g_free(standard_output);
    if (standard_error)
      g_free(standard_error);
  }
}
开发者ID:postiffm,项目名称:bibledit-gtk,代码行数:49,代码来源:bibledit-git.cpp


示例7: Initializer

static void Initializer(sym_pt templt){
	sym_pt initializer, instance;
	
	add_sym(instance);
	
	instance->type    = templt->type;
	instance->storage = templt->storage;
	instance->qual    = templt->qual;
	//instance->parent  = templt->parent;
	//instance->mtype   = templt->mtype;
	
	Instantiate_auto_members(instance, templt);
	
	if (Scanner::token() == T_ASS){ // Initialized value
		Scanner::next_token();
		
		if(instance->type == &Syms::none)
			parse_error("Cannot initialize an undefined type");
		
		
		initializer=Expression();
		if (!initializer->set)
			parse_error("Using an uninitialized value");
		if (initializer->storage == sc_constant){
			instance->value = initializer->value;
			instance->init  = true;
		
			//Syms::remove(initializer->full_name());
		}
		else Context_Stack::emit_op(I_ASS, instance, initializer, NULL);
		
		instance->set   = true;
	}
	else if (instance->qual == q_ro)
		parse_error("No initialization for a read only object");
}
开发者ID:Vkd1WV,项目名称:Ocode_compiler,代码行数:36,代码来源:parse_declarations.cpp


示例8: if

help_text_area::ALIGNMENT help_text_area::str_to_align(const std::string &cmp_str)
{
	if (cmp_str == "left") {
		return LEFT;
	} else if (cmp_str == "middle") {
		return MIDDLE;
	} else if (cmp_str == "right") {
		return RIGHT;
	} else if (cmp_str == "here" || cmp_str == "") { // Make the empty string be "here" alignment.
		return HERE;
	}
	std::stringstream msg;
	msg << "Invalid alignment string: '" << cmp_str << "'";
	throw parse_error(msg.str());
}
开发者ID:PositiveMD,项目名称:wesnoth,代码行数:15,代码来源:help_text_area.cpp


示例9: print_dependents

int print_dependents(char* module_name)
{
	int i, n;
	int j, m;
	int ct;
	Var* v;
	char* dep_name;

	ct = 0; /* keep a count of dependents */

	if (VERBOSE) {
		parse_error("Dependents of %s:", module_name);
	}

	n = Narray_count(loaded_modules);

	for (i = 0; i < n; i++) {
		Narray_get(loaded_modules, i, &dep_name, (void**)&v);
		m = V_MODULE(v).init_stuff.ndep;

		for (j = 0; j < m; j++) {
			if (strcmp(V_MODULE(v).init_stuff.dep[j].name, module_name) == 0) {
				if (VERBOSE) {
					parse_error("%s%s", ((ct == 0) ? "" : ", "), dep_name);
				}
				ct++;
			}
		}
	}

	if (VERBOSE) {
		parse_error("Total %d dependents.", ct);
	}

	return ct;
}
开发者ID:robwink,项目名称:davinci,代码行数:36,代码来源:ff_modules.c


示例10: hub_client2

void	hub_client2(char **tabcmd, t_client clt)
{
	if (ft_strcmp(tabcmd[0], "lls") == 0)
		lls(tabcmd);
	else if (ft_strcmp(tabcmd[0], "lpwd") == 0)
		ft_putendl(getcwd(NULL, 0));
	else if (ft_strcmp(tabcmd[0], "lcd") == 0)
		lcd(tabcmd, clt);
	else if (ft_strcmp(tabcmd[0], "put") == 0)
		put_hub(tabcmd, clt);
	else if (ft_strcmp(tabcmd[0], "get") == 0)
		get_hub(tabcmd, clt);
	else
		parse_error(tabcmd[0]);
}
开发者ID:AcideSpud,项目名称:ft_p,代码行数:15,代码来源:hub_client.c


示例11: while

clan::Colorf SvgAttributeReader::get_color()
{
	if (!is_color()) parse_error("expected color");

	size_t end_pos = pos + 1;
	while (end_pos < attr.length())
	{
		bool is_hex_char = (attr[end_pos] >= 'a' && attr[end_pos] <= 'f') || (attr[end_pos] >= 'A' && attr[end_pos] <= 'F') || (attr[end_pos] >= '0' && attr[end_pos] <= '9');
		if (!is_hex_char) break;
		end_pos++;
	}

	if (end_pos != pos + 4 && end_pos != pos + 7) parse_error("invalid color");

	clan::Colorf color;
	std::string hexstr = attr.substr(pos + 1, end_pos - pos - 1);
	unsigned int value = strtoul(hexstr.c_str(), 0, 16);
	if (end_pos == pos + 4)
	{
		int red = ((((value >> 8) & 0xf) + 1) << 4) - 1;
		int green = ((((value >> 4) & 0xf) + 1) << 4) - 1;
		int blue = (((value & 0xf) + 1) << 4) - 1;
		color = clan::Colorf(red / 255.0f, green / 255.0f, blue / 255.0f);
	}
开发者ID:ArtHome12,项目名称:ClanLib,代码行数:24,代码来源:svg_attribute_reader.cpp


示例12: parse_return

/*
 *	RETURN statement
 *	Handles RETURN [ <expression> ] ;
 */
void
parse_return(TOKEN *first_token)
{
    TOKEN	token;
    int	token_class;

    out_white_space(first_token);
    out_str("return");

    token_class = parse_expression(&token);
    if (token_class != END_OF_LINE)
        parse_error("';' expected");
    else
        out_token(&token);
}
开发者ID:dbremner,项目名称:retrocomputing,代码行数:19,代码来源:parse.c


示例13: parse_range_list

static int parse_range_list(char_stream_t cs, int_list_t il) {
  if (!parse_range(cs, il)) return 0;
  set_ok_pos(cs);
  while (cur_char(cs) == ',') {
    next_char(cs);
    if (!parse_range(cs, il)) return 0;
    set_ok_pos(cs);
  }
  if (cur_char(cs) != '\0') { 
    next_char(cs);
    parse_error(cs, "junk at the end of CPU list"); 
    return 0;
  }
  return 1;			/* OK */
}
开发者ID:massivethreads,项目名称:massivethreads,代码行数:15,代码来源:myth_bind_worker.c


示例14: parse

  RR parse(T& t, RR rr, int_<N>)
  {
    if (!rr.first)
      return throw_<_except_>( t, unexpected_end_fragment(), rr);

    rr = this->parse(t, rr, int_<0>() );

    if ( !try_<_except_>(t) )
      return rr;

    if ( (*rr.first & 192)==128 )
      return this->parse(t, rr, int_<N-1>() );

    return throw_<_except_>( t, parse_error( distance(rr.first) ), rr);
  }
开发者ID:migashko,项目名称:faslib-sandbox,代码行数:15,代码来源:ad_utf8_letter.hpp


示例15: var

static AST var() {
    Token *t = &tok;
    AST a=0;
    int idx;

    if (t->sym == ID) {
	char *s = strdup(t->text);
	gettoken();
	/* ival may be changed later */
	a = make_AST_var(s,0);
    } else {
	parse_error("expected ID");
    }
    return a;
}
开发者ID:tungvx,项目名称:FSE,代码行数:15,代码来源:parser2.c


示例16: invalid_argument

void			invalid_argument(t_parser *p, char expected, char got)
{
	char	*error_msg;

	if (expected & got)
		return ;
	error_msg = "Invalid arg, expected ";
	if (!(error_msg = ft_strjoin(error_msg, get_expected_chars(expected))))
		ERROR("Failed to malloc invalid arg expected msg");
	if (!(error_msg = ft_strjoin_free1(error_msg, ", got ")))
		ERROR("Failed to malloc invalid arg msg");
	if (!(error_msg = ft_strjoin_free1(error_msg, get_expected_chars(got))))
		ERROR("Failed to malloc invalid arg got msg");
	parse_error(p, error_msg);
}
开发者ID:acazuc,项目名称:42_corewar,代码行数:15,代码来源:invalid_argument.c


示例17: exit

// TODO add lookahead for sensor and control expressions
Expr* APDEvaluator::expression(const char* string) {
  Expr* expr;

  if(string[G_STRING_ITERATOR] == '(' || isdigit(string[G_STRING_ITERATOR])|| string[G_STRING_ITERATOR]=='c'|| string[G_STRING_ITERATOR]=='s') {
    if(NULL == (expr = (Expr*)malloc(sizeof(Expr)))) {
      exit(1);			// TODO this is not the way to handle this
    }

    expr = term(string, expr);
    expr = term_right(string, expr);
    return expr;
  } else {
    parse_error(string);
  }
}
开发者ID:rskang,项目名称:APDuinOS_library,代码行数:16,代码来源:APDEvaluator.cpp


示例18: mac_arg

// Implements \newcolumntype{C}[opt]{body}
// as \newcommand\cmd[opt]{body}
// Here \cmd is some internal name, stored in nct_tok[C]
void Parser::T_newcolumn_type()
{
  TokenList L = mac_arg();
  uint c = 0; 
  if(L.empty()) parse_error("Empty argument to \\newcolumntype");
  else if(L.size() != 1)
    parse_error("More than one token in argument to \\newcolumntype");
  else {
    if(L.front().is_a_char())
      c = L.front().char_val().get_value();
    if(!(c>0 && c<nb_newcolumn)) {
      parse_error("Argument to \\newcolumntype is not a 7bit character");
      c= 0;
    }
  }
  Buffer& B = hash_table.my_buffer();
  B.reset();
  B.push_back("[email protected]");
  B.push_back(uchar(c)); // special hack if c=0 !
  cur_tok = hash_table.locate(B);
  new_array_object.add_a_type(c,cur_tok);
  back_input();
  get_new_command(rd_always,false); // definition is local
}
开发者ID:chenhaot,项目名称:oerpub.rhaptoslabs.tralics,代码行数:27,代码来源:txarray.C


示例19: process_ef

static int
process_ef(struct state *cur, struct block *info,
		const char *name, scconf_block *blk)
{
	struct state	state;

	init_state(cur, &state);
	if (name == NULL) {
		parse_error(cur, "No name given for EF object.");
		return 1;
	}
	if (!(state.file = new_file(cur, name, SC_FILE_TYPE_WORKING_EF)))
		return 1;
	return process_block(&state, info, name, blk);
}
开发者ID:Emergya,项目名称:opendnie-debian-packaging,代码行数:15,代码来源:profile.c


示例20: selfn_monitor_cores

void selfn_monitor_cores(const char *arg)
{
        char *cp = NULL, *str = NULL;
        char *saveptr = NULL;

        if (arg == NULL)
                parse_error(arg, "NULL pointer!");

        if (strlen(arg) <= 0)
                parse_error(arg, "Empty string!");

        selfn_strdup(&cp, arg);

        for (str = cp; ; str = NULL) {
                char *token = NULL;

                token = strtok_r(str, ";", &saveptr);
                if (token == NULL)
                        break;
                parse_monitor_event(token);
        }

        free(cp);
}
开发者ID:yyzreal,项目名称:intel-cmt-cat,代码行数:24,代码来源:monitor.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ parse_expr函数代码示例发布时间:2022-05-30
下一篇:
C++ parse_env_file函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap