/* ** Perform a reduce action and the shift that must immediately ** follow the reduce. */ static void yy_reduce( yyParser *yypParser, /* The parser */ int yyruleno /* Number of the rule by which to reduce */ ){ int yygoto; /* The next state */ int yyact; /* The next action */ YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ yyStackEntry *yymsp; /* The top of the parser's stack */ int yysize; /* Amount to pop the stack */ ParseARG_FETCH; yymsp = &yypParser->yystack[yypParser->yyidx]; #ifndef NDEBUG if( yyTraceFILE && yyruleno>=0 && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, yyRuleName[yyruleno]); } #endif /* NDEBUG */ /* Silence complaints from purify about yygotominor being uninitialized ** in some cases when it is copied into the stack after the following ** switch. yygotominor is uninitialized when a rule reduces that does ** not set the value of its left-hand side nonterminal. Leaving the ** value of the nonterminal uninitialized is utterly harmless as long ** as the value is never used. So really the only thing this code ** accomplishes is to quieten purify. ** ** 2007-01-16: The wireshark project (www.wireshark.org) reports that ** without this code, their parser segfaults. I'm not sure what there ** parser is doing to make this happen. This is the second bug report ** from wireshark this week. Clearly they are stressing Lemon in ways ** that it has not been previously stressed... (SQLite ticket #2172) */ /*memset(&yygotominor, 0, sizeof(yygotominor));*/ yygotominor = yyzerominor; switch( yyruleno ){ /* Beginning here are the reduction cases. A typical example ** follows: ** case 0: ** #line <lineno> <grammarfile> ** { ... } // User supplied code ** #line <lineno> <thisfile> ** break; */ case 4: /* decl ::= REPORT TO STR */ #line 22 "cfg.y" {set_report(ps,yymsp[0].minor.yy0);} #line 739 "cfg.c" break; case 5: /* decl ::= LISTEN ON STR */ #line 23 "cfg.y" {set_listen(ps,yymsp[0].minor.yy0);} #line 744 "cfg.c" break; case 6: /* job ::= JOB LCURLY sbody RCURLY */ #line 24 "cfg.y" {push_job(ps);} #line 749 "cfg.c" break; case 9: /* kv ::= NAME STR */ #line 27 "cfg.y" {set_name(ps,yymsp[0].minor.yy0);} #line 754 "cfg.c" break; case 11: /* kv ::= DIR path */ #line 29 "cfg.y" {set_dir(ps,yymsp[0].minor.yy0);} #line 759 "cfg.c" break; case 12: /* kv ::= OUT path */ #line 30 "cfg.y" {set_out(ps,yymsp[0].minor.yy0);} #line 764 "cfg.c" break; case 13: /* kv ::= IN path */ #line 31 "cfg.y" {set_in(ps,yymsp[0].minor.yy0);} #line 769 "cfg.c" break; case 14: /* kv ::= ERR path */ #line 32 "cfg.y" {set_err(ps,yymsp[0].minor.yy0);} #line 774 "cfg.c" break; case 15: /* kv ::= USER STR */ #line 33 "cfg.y" {set_user(ps,yymsp[0].minor.yy0);} #line 779 "cfg.c" break; case 16: /* kv ::= ORDER STR */ #line 34 "cfg.y" {set_ord(ps,yymsp[0].minor.yy0);} #line 784 "cfg.c" break; case 17: /* kv ::= ENV STR */ #line 35 "cfg.y" {set_env(ps,yymsp[0].minor.yy0);} #line 789 "cfg.c" break; case 18: /* kv ::= ULIMIT STR STR */ case 34: /* pairs ::= pairs STR STR */ yytestcase(yyruleno==34); #line 36 "cfg.y" {set_ulimit(ps,yymsp[-1].minor.yy0,yymsp[0].minor.yy0);} #line 795 "cfg.c" break; case 20: /* kv ::= DISABLED */ #line 38 "cfg.y" {set_dis(ps); } #line 800 "cfg.c" break; case 21: /* kv ::= WAIT */ #line 39 "cfg.y" {set_wait(ps); } #line 805 "cfg.c" break; case 22: /* kv ::= ONCE */ #line 40 "cfg.y" {set_once(ps); } #line 810 "cfg.c" break; case 23: /* kv ::= BOUNCE EVERY STR */ #line 41 "cfg.y" {set_bounce(ps,yymsp[0].minor.yy0);} #line 815 "cfg.c" break; case 25: /* cmd ::= path */ #line 43 "cfg.y" {set_cmd(ps,yymsp[0].minor.yy0);} #line 820 "cfg.c" break; case 26: /* cmd ::= path args */ #line 44 "cfg.y" {set_cmd(ps,yymsp[-1].minor.yy0);} #line 825 "cfg.c" break; case 27: /* path ::= STR */ case 30: /* arg ::= STR */ yytestcase(yyruleno==30); #line 45 "cfg.y" {yygotominor.yy0=yymsp[0].minor.yy0;} #line 831 "cfg.c" break; case 28: /* args ::= args arg */ case 29: /* args ::= arg */ yytestcase(yyruleno==29); #line 46 "cfg.y" {utarray_push_back(&ps->job->cmdv,&yymsp[0].minor.yy0);} #line 837 "cfg.c" break; case 31: /* arg ::= QUOTEDSTR */ #line 49 "cfg.y" {yygotominor.yy0=unquote(yymsp[0].minor.yy0);} #line 842 "cfg.c" break; case 32: /* paths ::= paths path */ case 33: /* paths ::= path */ yytestcase(yyruleno==33); #line 50 "cfg.y" {utarray_push_back(&ps->job->depv,&yymsp[0].minor.yy0);} #line 848 "cfg.c" break; default: /* (0) file ::= decls */ yytestcase(yyruleno==0); /* (1) decls ::= decls job */ yytestcase(yyruleno==1); /* (2) decls ::= decls decl */ yytestcase(yyruleno==2); /* (3) decls ::= */ yytestcase(yyruleno==3); /* (7) sbody ::= sbody kv */ yytestcase(yyruleno==7); /* (8) sbody ::= kv */ yytestcase(yyruleno==8); /* (10) kv ::= CMD cmd */ yytestcase(yyruleno==10); /* (19) kv ::= ULIMIT LCURLY pairs RCURLY */ yytestcase(yyruleno==19); /* (24) kv ::= DEPENDS LCURLY paths RCURLY */ yytestcase(yyruleno==24); /* (35) pairs ::= */ yytestcase(yyruleno==35); break; }; yygoto = yyRuleInfo[yyruleno].lhs; yysize = yyRuleInfo[yyruleno].nrhs; yypParser->yyidx -= yysize; yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto); if( yyact < YYNSTATE ){ #ifdef NDEBUG /* If we are not debugging and the reduce action popped at least ** one element off the stack, then we can push the new element back ** onto the stack here, and skip the stack overflow test in yy_shift(). ** That gives a significant speed improvement. */ if( yysize ){ yypParser->yyidx++; yymsp -= yysize-1; yymsp->stateno = (YYACTIONTYPE)yyact; yymsp->major = (YYCODETYPE)yygoto; yymsp->minor = yygotominor; }else #endif { yy_shift(yypParser,yyact,yygoto,&yygotominor); } }else{ assert( yyact == YYNSTATE + YYNRULE + 1 ); yy_accept(yypParser); } }
int main() { boost::asio::io_service io_service; boost::scoped_ptr<boost::thread_group> threads( new boost::thread_group ); boost::asio::io_service::work work(io_service); for (int i = 0; i < boost::thread::hardware_concurrency() ; ++i) { threads->create_thread(boost::bind(&boost::asio::io_service::run, &io_service)); } std::vector<boost::shared_future<int> > pending_data; // vector of futures push_job(1000, io_service, pending_data); push_job(1001, io_service, pending_data); push_job(1002, io_service, pending_data); push_job(1003, io_service, pending_data); push_job(1004, io_service, pending_data); push_job(1005, io_service, pending_data); push_job(1006, io_service, pending_data); push_job(1007, io_service, pending_data); push_job(1008, io_service, pending_data); push_job(1009, io_service, pending_data); push_job(1010, io_service, pending_data); boost::wait_for_all(pending_data.begin(), pending_data.end()); // Stop all thread activity before deleting the thread group io_service.stop(); // Allow threads to clean up while shared task pointers are still in scope. threads.reset(); system("PAUSE"); return 0; }