示例#1
0
 void config_handler::handle_request(const request& req, reply& rep)
 {
     timer t;
     mem_counter mc;
     
     boost::scoped_ptr<argos::common::ExecutionContext> pctx(the_index_->create_context());
     argos::common::ExecutionContext &ctx=*(pctx.get());
     try {
         rep.content=the_index_->get_field_config()->serialize();
         rep.status = reply::ok;
         rep.headers.resize(2);
         rep.headers[0].name = "Content-Length";
         rep.headers[0].value = boost::lexical_cast<std::string>(rep.content.size());
         rep.headers[1].name = "Content-Type";
         rep.headers[1].value = "application/xml";
     }
     catch(...) {
         rep=reply::stock_reply(reply::internal_server_error);
         LOG4CPLUS_ERROR(err, "CLIENT:" << req.peer << ", CODE:" << rep.status << " - " << req.uri);
     }
     LOG4CPLUS_INFO(acc, "CLIENT:" << req.peer << ", CODE:" << rep.status << ", TIME:" << t*1000 << "ms, MEM:" << mc << ", CL:" << rep.content.size() << ", QID:[], URL:" << req.uri);
     if (ctx.temp_pool->get_used_size()>3*1024*1024) {
         ctx.temp_pool->reset();
     }
 }
示例#2
0
void z::Compiler::compileString(Ast::Module& module, Lexer& lexer, const z::string& data, const bool& isEof) {
    z::Ast::Factory factory(module);
    ParserContext pctx(factory, z::ref(this));

    const z::estring edata = z::s2e(data);
    lexer.push(pctx, edata.c_str(), edata.size(), isEof);
}
示例#3
0
bool z::Compiler::compileFile(z::Ast::Module& module, const z::string& filename, const z::string& msg) {
    if(_project.verbosity() >= z::Ast::Project::Verbosity::Normal) {
        z::string indent = "   ";
        for(z::Ast::Module::Level_t i = 0; i < module.level(); ++i) {
            indent += "  ";
        }
        std::cout << indent << msg << " " << filename << std::endl;
    }

    std::ifstream is;
    is.open(z::s2e(filename).c_str(), std::ifstream::in);
    if(is.is_open() == false) {
        throw z::Exception("Compiler", zfmt(z::Ast::Token(filename, 0, 0, ""), z::string("Error opening file %{s}").arg("s", filename)));
    }

    Parser parser;
    Lexer lexer(parser);
    z::Ast::Factory factory(module);
    ParserContext pctx(factory, z::ref(this));
    while(!is.eof()) {
        char buf[1025];
        memset(buf, 0, 1024);
        is.read(buf, 1024);
        std::streamsize got = is.gcount();
        lexer.push(pctx, buf, got, is.eof());
    }
    return true;
}
示例#4
0
TEST (ParserTest, DataDeclTest) {
    int result;
    apus::ParserContext pctx(std::make_shared<apus::VirtualMachine>());

    yy_scan_string(data_decl_test);
    result = yyparse(&pctx);

    EXPECT_EQ (result, 0);
}