/*193:*/
//#line 553 "/usr/local/yacco2/library/thread.w"

/*565:*/
//#line 24 "/usr/local/yacco2/library/macros.w"



/*:565*/
//#line 554 "/usr/local/yacco2/library/thread.w"

/*23:*/
//#line 392 "/usr/local/yacco2/library/intro.w"

using namespace yacco2;

/*:23*/
//#line 555 "/usr/local/yacco2/library/thread.w"

/*200:*/
//#line 650 "/usr/local/yacco2/library/thread.w"

char ma[SMALL_BUFFER_4K];
const char*pp_start= "YACCO2_MSG__::%i::%s start parsing\n";
const char*pp_stop= "YACCO2_MSG__::%i::%s stop parsing\n";
/*23:*/
//#line 392 "/usr/local/yacco2/library/intro.w"

using namespace yacco2;

/*:23*/
//#line 654 "/usr/local/yacco2/library/thread.w"


/*:200*/
//#line 556 "/usr/local/yacco2/library/thread.w"

/*202:*/
//#line 663 "/usr/local/yacco2/library/thread.w"

Parser pp_parser(ssPARSE_TABLE,pp_thread_entry,Caller_pp);

/*:202*/
//#line 557 "/usr/local/yacco2/library/thread.w"

/*201:*/
//#line 657 "/usr/local/yacco2/library/thread.w"

pp_parser.pp_requesting_parallelism__= Caller_pp;
pp_parser.from_thread__= Caller_pp;
pp_parser.no_competing_pp_ths__= Caller_pp->no_requested_ths_to_run__;

/*:201*/
//#line 558 "/usr/local/yacco2/library/thread.w"

do{
/*199:*/
//#line 618 "/usr/local/yacco2/library/thread.w"

pp_parser.override_current_token(*pp_parser.pp_requesting_parallelism__->current_token()
,pp_parser.pp_requesting_parallelism__->current_token_pos__);
pp_parser.set_start_token(*pp_parser.pp_requesting_parallelism__->current_token());
pp_parser.set_start_token_pos(pp_parser.pp_requesting_parallelism__->current_token_pos__);
pp_parser.top_stack_record()->set_symbol(pp_parser.current_token());
pp_parser.token_supplier__= pp_parser.pp_requesting_parallelism__->token_supplier__;
pp_parser.token_producer__= pp_parser.pp_requesting_parallelism__->token_producer__;
pp_parser.error_queue__= pp_parser.pp_requesting_parallelism__->error_queue__;
pp_parser.recycle_bin__= pp_parser.pp_requesting_parallelism__->recycle_bin__;
pp_parser.sym_lookup_functor__= pp_parser.pp_requesting_parallelism__->sym_lookup_functor__;
pp_parser.supplier_r_w_cnt__= pp_parser.pp_requesting_parallelism__->supplier_r_w_cnt__;

if(pp_parser.th_blk__.grammar_s_parser__!=&pp_parser){
char a[BUFFER_SIZE];

yacco2::KCHARP msg= "parser's thd blk's pp addr != itself thd: %i::%s";
sprintf(a,msg,pp_parser.thread_no__,pp_parser.thread_name());
Yacco2_faulty_precondition(a,__FILE__,__LINE__);
exit(1);
}
if(pp_parser.th_blk__.grammar_s_parser__->pp_requesting_parallelism__
!=pp_parser.pp_requesting_parallelism__){
char a[BUFFER_SIZE];

yacco2::KCHARP msg= 
"caller's pp addr not = in called parser's thd blk ptr, and its parser thd: %i::%s";
sprintf(a,msg,pp_parser.thread_no__,pp_parser.thread_name());
Yacco2_faulty_precondition(a,__FILE__,__LINE__);
exit(1);
}
/*:199*/
//#line 560 "/usr/local/yacco2/library/thread.w"

/*637:*/
//#line 1330 "/usr/local/yacco2/library/macros.w"

if(yacco2::YACCO2_MSG__){
/*389:*/
//#line 3053 "/usr/local/yacco2/library/parser.w"

LOCK_MUTEX(yacco2::TRACE_MU);
if(yacco2::YACCO2_MU_TRACING__){
yacco2::lrclog<<"YACCO2_MU_TRACING__::Acquired trace mu"<<FILE_LINE<<std::endl;
}

/*:389*/
//#line 1332 "/usr/local/yacco2/library/macros.w"

sprintf(ma,pp_start,pp_parser.thread_no__,pp_thread_entry.thread_fnct_name__);
yacco2::lrclog<<ma;
Parser*pp_= pp_parser.pp_requesting_parallelism__;
yacco2::lrclog<<"YACCO2_MSG__::"
<<pp_parser.thread_no__
<<"::"
<<pp_parser.thread_name()
<<" requesting parser*: "<<pp_
<<FILE_LINE<<std::endl;
yacco2::lrclog<<"\tYACCO2_MSG__::"<<pp_parser.thread_no__<<"::"
<<pp_parser.thread_name()
<<" Caller's # threads to run:: "<<pp_->no_requested_ths_to_run__
<<" Caller's # active threads: "<<pp_->th_active_cnt__
<<" Self # competing threads: "<<pp_parser.no_competing_pp_ths__
<<FILE_LINE<<std::endl;
yacco2::lrclog<<"\tYACCO2_MSG__::"
<<pp_parser.thread_no__<<"::"
<<pp_parser.thread_name()
<<" passed token*: "<<pp_->current_token()
<<'"'<<pp_parser.current_token()->id__<<'"'
<<" pos: "<<pp_parser.current_token_pos__
<<FILE_LINE<<std::endl;
yacco2::lrclog
<<"\t\t::GPS FILE: ";
EXTERNAL_GPSing(pp_parser.current_token__)
yacco2::lrclog
<<" GPS LINE: "
<<pp_parser.current_token__->tok_co_ords__.line_no__
<<" GPS CHR POS: "
<<pp_parser.current_token__->tok_co_ords__.pos_in_line__
<<FILE_LINE<<std::endl;

/*390:*/
//#line 3060 "/usr/local/yacco2/library/parser.w"

if(yacco2::YACCO2_MU_TRACING__){
yacco2::lrclog<<"YACCO2_MU_TRACING__::Releasing trace mu"<<FILE_LINE<<std::endl;
}
UNLOCK_MUTEX(yacco2::TRACE_MU);

/*:390*/
//#line 1365 "/usr/local/yacco2/library/macros.w"

}
if(yacco2::YACCO2_T__){
/*389:*/
//#line 3053 "/usr/local/yacco2/library/parser.w"

LOCK_MUTEX(yacco2::TRACE_MU);
if(yacco2::YACCO2_MU_TRACING__){
yacco2::lrclog<<"YACCO2_MU_TRACING__::Acquired trace mu"<<FILE_LINE<<std::endl;
}

/*:389*/
//#line 1368 "/usr/local/yacco2/library/macros.w"

yacco2::lrclog<<"YACCO2_T__::"
<<pp_parser.thread_no__
<<"::"
<<pp_parser.thread_name()
<<" token*: "<<pp_parser.current_token__
<<" enum: "<<pp_parser.current_token__->enumerated_id__
<<" pos: "<<pp_parser.current_token_pos__
<<' '<<'"'<<pp_parser.current_token__->id__<<'"'
<<FILE_LINE<<std::endl;
yacco2::lrclog
<<"\t\t::GPS FILE: ";
EXTERNAL_GPSing(pp_parser.current_token__)
yacco2::lrclog
<<" GPS LINE: "
<<pp_parser.current_token__->tok_co_ords__.line_no__
<<" GPS CHR POS: "
<<pp_parser.current_token__->tok_co_ords__.pos_in_line__
<<FILE_LINE<<std::endl;
yacco2::lrclog
<<"\tGPS LINE: "
<<pp_parser.current_token()->tok_co_ords__.line_no__
<<" GPS CHR POS: "
<<pp_parser.current_token()->tok_co_ords__.pos_in_line__
<<FILE_LINE<<std::endl;

/*390:*/
//#line 3060 "/usr/local/yacco2/library/parser.w"

if(yacco2::YACCO2_MU_TRACING__){
yacco2::lrclog<<"YACCO2_MU_TRACING__::Releasing trace mu"<<FILE_LINE<<std::endl;
}
UNLOCK_MUTEX(yacco2::TRACE_MU);

/*:390*/
//#line 1394 "/usr/local/yacco2/library/macros.w"

}

/*:637*/
//#line 561 "/usr/local/yacco2/library/thread.w"

/*198:*/
//#line 610 "/usr/local/yacco2/library/thread.w"

pp_parser.parallel_parse();

/*:198*/
//#line 562 "/usr/local/yacco2/library/thread.w"

/*639:*/
//#line 1461 "/usr/local/yacco2/library/macros.w"

if(yacco2::YACCO2_MSG__){
/*389:*/
//#line 3053 "/usr/local/yacco2/library/parser.w"

LOCK_MUTEX(yacco2::TRACE_MU);
if(yacco2::YACCO2_MU_TRACING__){
yacco2::lrclog<<"YACCO2_MU_TRACING__::Acquired trace mu"<<FILE_LINE<<std::endl;
}

/*:389*/
//#line 1463 "/usr/local/yacco2/library/macros.w"

sprintf(ma,pp_stop,pp_parser.thread_no__,pp_thread_entry.thread_fnct_name__);
yacco2::lrclog<<ma;
/*390:*/
//#line 3060 "/usr/local/yacco2/library/parser.w"

if(yacco2::YACCO2_MU_TRACING__){
yacco2::lrclog<<"YACCO2_MU_TRACING__::Releasing trace mu"<<FILE_LINE<<std::endl;
}
UNLOCK_MUTEX(yacco2::TRACE_MU);

/*:390*/
//#line 1466 "/usr/local/yacco2/library/macros.w"

}

/*:639*/
//#line 563 "/usr/local/yacco2/library/thread.w"

/*197:*/
//#line 597 "/usr/local/yacco2/library/thread.w"

pp_parser.remove_from_stack(pp_parser.parse_stack__.top_sub__-1);
CAbs_lr1_sym*sym= pp_parser.top_stack_record()->symbol__;
if(sym!=0){
if(sym->auto_delete__==ON){
/*640:*/
//#line 1470 "/usr/local/yacco2/library/macros.w"

if(yacco2::YACCO2_TH__){
THREAD_NO tid= pp_parser.thread_no__;
/*389:*/
//#line 3053 "/usr/local/yacco2/library/parser.w"

LOCK_MUTEX(yacco2::TRACE_MU);
if(yacco2::YACCO2_MU_TRACING__){
yacco2::lrclog<<"YACCO2_MU_TRACING__::Acquired trace mu"<<FILE_LINE<<std::endl;
}

/*:389*/
//#line 1473 "/usr/local/yacco2/library/macros.w"

yacco2::lrclog<<"YACCO2_TH__:: "<<"sym to be deleted: "
<<tid<<"::"
<<pp_parser.fsm_tbl__->id__<<"::"
<<sym->id__
<<FILE_LINE<<std::endl;
/*390:*/
//#line 3060 "/usr/local/yacco2/library/parser.w"

if(yacco2::YACCO2_MU_TRACING__){
yacco2::lrclog<<"YACCO2_MU_TRACING__::Releasing trace mu"<<FILE_LINE<<std::endl;
}
UNLOCK_MUTEX(yacco2::TRACE_MU);

/*:390*/
//#line 1479 "/usr/local/yacco2/library/macros.w"

}
/*:640*/
//#line 602 "/usr/local/yacco2/library/thread.w"

delete sym;
}
pp_parser.top_stack_record()->set_symbol(0);
}
pp_parser.parse_stack__.lr_stk_init(*pp_parser.fsm_tbl__->start_state__);

/*:197*/
//#line 564 "/usr/local/yacco2/library/thread.w"

/*196:*/
//#line 586 "/usr/local/yacco2/library/thread.w"

pp_parser.use_all_shift__= ON;
pp_parser.abort_parse__= OFF;
pp_parser.stop_parse__= OFF;
pp_parser.has_questionable_shift_occured__= OFF;

/*:196*/
//#line 565 "/usr/local/yacco2/library/thread.w"

/*642:*/
//#line 1495 "/usr/local/yacco2/library/macros.w"

if(yacco2::YACCO2_MSG__){
/*389:*/
//#line 3053 "/usr/local/yacco2/library/parser.w"

LOCK_MUTEX(yacco2::TRACE_MU);
if(yacco2::YACCO2_MU_TRACING__){
yacco2::lrclog<<"YACCO2_MU_TRACING__::Acquired trace mu"<<FILE_LINE<<std::endl;
}

/*:389*/
//#line 1497 "/usr/local/yacco2/library/macros.w"

yacco2::lrclog<<"YACCO2_MSG__::"<<pp_parser.thread_no__
<<"::"<<pp_thread_entry.thread_fnct_name__
<<" ==>PP waiting for work: "
<<FILE_LINE<<std::endl;
/*390:*/
//#line 3060 "/usr/local/yacco2/library/parser.w"

if(yacco2::YACCO2_MU_TRACING__){
yacco2::lrclog<<"YACCO2_MU_TRACING__::Releasing trace mu"<<FILE_LINE<<std::endl;
}
UNLOCK_MUTEX(yacco2::TRACE_MU);

/*:390*/
//#line 1502 "/usr/local/yacco2/library/macros.w"

}

/*:642*/
//#line 566 "/usr/local/yacco2/library/thread.w"

/*195:*/
//#line 581 "/usr/local/yacco2/library/thread.w"

pp_parser.wait_for_event();

/*:195*/
//#line 567 "/usr/local/yacco2/library/thread.w"

/*643:*/
//#line 1506 "/usr/local/yacco2/library/macros.w"

if(yacco2::YACCO2_MSG__){
/*389:*/
//#line 3053 "/usr/local/yacco2/library/parser.w"

LOCK_MUTEX(yacco2::TRACE_MU);
if(yacco2::YACCO2_MU_TRACING__){
yacco2::lrclog<<"YACCO2_MU_TRACING__::Acquired trace mu"<<FILE_LINE<<std::endl;
}

/*:389*/
//#line 1508 "/usr/local/yacco2/library/macros.w"

yacco2::lrclog<<"YACCO2_MSG__::"<<pp_parser.thread_no__
<<"::"<<pp_thread_entry.thread_fnct_name__
<<" ==>PP go process work: "
<<FILE_LINE<<std::endl;
/*390:*/
//#line 3060 "/usr/local/yacco2/library/parser.w"

if(yacco2::YACCO2_MU_TRACING__){
yacco2::lrclog<<"YACCO2_MU_TRACING__::Releasing trace mu"<<FILE_LINE<<std::endl;
}
UNLOCK_MUTEX(yacco2::TRACE_MU);

/*:390*/
//#line 1513 "/usr/local/yacco2/library/macros.w"

}

/*:643*/
//#line 568 "/usr/local/yacco2/library/thread.w"

}while(pp_parser.th_blk__.status__!=THREAD_TO_EXIT);
finished_working:
/*194:*/
//#line 577 "/usr/local/yacco2/library/thread.w"

pp_parser.clear_parse_stack();

/*:194*/
//#line 571 "/usr/local/yacco2/library/thread.w"

/*644:*/
//#line 1517 "/usr/local/yacco2/library/macros.w"

if(yacco2::YACCO2_MSG__){
/*389:*/
//#line 3053 "/usr/local/yacco2/library/parser.w"

LOCK_MUTEX(yacco2::TRACE_MU);
if(yacco2::YACCO2_MU_TRACING__){
yacco2::lrclog<<"YACCO2_MU_TRACING__::Acquired trace mu"<<FILE_LINE<<std::endl;
}

/*:389*/
//#line 1519 "/usr/local/yacco2/library/macros.w"

yacco2::lrclog<<"YACCO2_MSG__::"<<pp_parser.thread_no__
<<"::"<<pp_thread_entry.thread_fnct_name__
<<" ==>PP finished working"
<<FILE_LINE<<std::endl;
/*390:*/
//#line 3060 "/usr/local/yacco2/library/parser.w"

if(yacco2::YACCO2_MU_TRACING__){
yacco2::lrclog<<"YACCO2_MU_TRACING__::Releasing trace mu"<<FILE_LINE<<std::endl;
}
UNLOCK_MUTEX(yacco2::TRACE_MU);

/*:390*/
//#line 1524 "/usr/local/yacco2/library/macros.w"

}
/*:644*/
//#line 572 "/usr/local/yacco2/library/thread.w"

UNLOCK_MUTEX_OF_CALLED_PARSER(pp_parser.mu__,pp_parser," of called thread");
return(THR)1;

/*:193*/
