本文整理汇总了C++中parse_error函数的典型用法代码示例。如果您正苦于以下问题:C++ parse_error函数的具体用法?C++ parse_error怎么用?C++ parse_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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)
示例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;
}
}
示例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;
}
示例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);
}
}
示例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");
}
示例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());
}
示例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;
}
示例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]);
}
示例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);
}
示例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);
}
示例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 */
}
示例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);
}
示例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;
}