/*
 file: /yacco2/diagrams+etc/threadmanualcall.txt
 Example of a subrule calling a thread manually.
 Taken from grammar pass3.lex before explicit procedure call of threads
 construct invented.
 The start_manually_parallel_parsing function uses the
 thread's id generated from O2linker as its key to find the thread to launch.
*/
  -> "@" 
  /@
  \Yacco2's pre-processor include directive.\fbreak
 \fbreak
 This demonstrates a nested environment 
 where the grammar uses recursion by 
 calling a function which contains the |pass3| grammar sequence.
 In this example, grammar |pass3| 
 manually calls a thread via
 |start_manually_parallel_parsing| 
 to get its file name to process.
 With the returned ``file-inclusion'' terminal, 
 |PROCESS_INCLUDE_FILE| is called to parse
 the include file: a bom-de-bom-bom bump-and-grind sequence.
 The |use_cnt_| is a global variable that protects
 against the file include recursion of calling self
 until a stack overflow occurs.
 @/
  { 
    op
      using namespace NS_prefile_include;
      using namespace NS_yacco2_T_enum;

      Parser::parse_result result = 
        rule_info__.parser__->
        start_manually_parallel_parsing(ITH_prefile_include.thd_id__);
      if(result == Parser::erred){
          // in this case, it will not happen: here for education
          rule_info__.parser__->set_abort_parse(true);
          return;
      }
      // process returned token
      Caccept_parse& accept_parm = 
           *rule_info__.parser__->arbitrated_token__;
      CAbs_lr1_sym* rtn_tok = accept_parm.accept_token__;
      int id = rtn_tok->enumerated_id__;
      accept_parm.accept_token__ = 0;
      if(id == T_Enum::T_T_file_inclusion_) {			
          T_file_inclusion* finc = (T_file_inclusion*)(rtn_tok);
          CAbs_lr1_sym* err = finc->error_sym();
          if(err != 0) {
            rule_info__.parser__->set_abort_parse(true);
            ADD_TOKEN_TO_ERROR_QUEUE(*finc); 
            ADD_TOKEN_TO_ERROR_QUEUE(*finc->error_sym()); 
            finc->error_sym(0);
            return;
          }
          rule_info__.parser__->
            override_current_token(*accept_parm.la_token__
	                          ,accept_parm.la_token_pos__);
           bool result = 
            PROCESS_INCLUDE_FILE
                (*rule_info__.parser__
		,*finc,*rule_info__.parser__->token_producer__);
          if(result == false){ // exceeded nested file limit
            rule_info__.parser__->set_abort_parse(true);
            return;
          }
          ADD_TOKEN_TO_RECYCLE_BIN(*finc);//file name inside
          return;
      }
      // catch all  errors
      rule_info__.parser__->set_abort_parse(true);
    ***
    }