protected void parse_lookahead(boolean debug) throws java.lang.Exception {
  int act;
  Symbol lhs_sym=null;
  short handle_size, lhs_sym_num;
  lookahead_pos=0;
  if (debug) {
    debug_message("# Reparsing saved input with actions");
    debug_message("# Current Symbol is #" + cur_err_token().sym);
    debug_message("# Current state is #" + ((Symbol)stack.peek()).parse_state);
  }
  while (!_done_parsing) {
    act=get_action(((Symbol)stack.peek()).parse_state,cur_err_token().sym);
    if (act > 0) {
      cur_err_token().parse_state=act - 1;
      cur_err_token().used_by_parser=true;
      if (debug)       debug_shift(cur_err_token());
      stack.push(cur_err_token());
      tos++;
      if (!advance_lookahead()) {
        if (debug)         debug_message("# Completed reparse");
        return;
      }
      if (debug)       debug_message("# Current Symbol is #" + cur_err_token().sym);
    }
 else     if (act < 0) {
      lhs_sym=do_action((-act) - 1,this,stack,tos);
      lhs_sym_num=production_tab[(-act) - 1][0];
      handle_size=production_tab[(-act) - 1][1];
      if (debug)       debug_reduce((-act) - 1,lhs_sym_num,handle_size);
      for (int i=0; i < handle_size; i++) {
        stack.pop();
        tos--;
      }
      act=get_reduce(((Symbol)stack.peek()).parse_state,lhs_sym_num);
      lhs_sym.parse_state=act;
      lhs_sym.used_by_parser=true;
      stack.push(lhs_sym);
      tos++;
      if (debug)       debug_message("# Goto state #" + act);
    }
 else     if (act == 0) {
      report_fatal_error("Syntax error",lhs_sym);
      return;
    }
  }
}

protected void parse_lookahead ( boolean debug ) throws java . lang . Exception { int act ; Symbol lhs_sym = null ; short handle_size , lhs_sym_num ; lookahead_pos = 0 ; if ( debug ) { debug_message ( "# Reparsing saved input with actions" ) ; debug_message ( "# Current Symbol is #" + cur_err_token ( ) . sym ) ; debug_message ( "# Current state is #" + ( ( Symbol ) stack . peek ( ) ) . parse_state ) ; } while ( ! _done_parsing ) { act = get_action ( ( ( Symbol ) stack . peek ( ) ) . parse_state , cur_err_token ( ) . sym ) ; if ( act > 0 ) { cur_err_token ( ) . parse_state = act - 1 ; cur_err_token ( ) . used_by_parser = true ; if ( debug ) debug_shift ( cur_err_token ( ) ) ; stack . push ( cur_err_token ( ) ) ; tos ++ ; if ( ! advance_lookahead ( ) ) { if ( debug ) debug_message ( "# Completed reparse" ) ; return ; } if ( debug ) debug_message ( "# Current Symbol is #" + cur_err_token ( ) . sym ) ; } else if ( act < 0 ) { lhs_sym = do_action ( ( - act ) - 1 , this , stack , tos ) ; lhs_sym_num = production_tab [ ( - act ) - 1 ] [ 0 ] ; handle_size = production_tab [ ( - act ) - 1 ] [ 1 ] ; if ( debug ) debug_reduce ( ( - act ) - 1 , lhs_sym_num , handle_size ) ; for ( int i = 0 ; i < handle_size ; i ++ ) { stack . pop ( ) ; tos -- ; } act = get_reduce ( ( ( Symbol ) stack . peek ( ) ) . parse_state , lhs_sym_num ) ; lhs_sym . parse_state = act ; lhs_sym . used_by_parser = true ; stack . push ( lhs_sym ) ; tos ++ ; if ( debug ) debug_message ( "# Goto state #" + act ) ; } else if ( act == 0 ) { report_fatal_error ( "Syntax error" , lhs_sym ) ; return ; } } }
parse forward using stored lookahead symbols . in this case we have already verified that parsing will make it through the stored lookahead symbols and we are now getting back to the point at which we can hand control back to the normal parser . consequently , this version of the parser performs all actions and modifies the real parse configuration . this returns once we have consumed all the stored input or we accept .
