/[bison]/bison/data/lalr1.cc
ViewVC logotype

Diff of /bison/data/lalr1.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.36 by eggert, Mon Jul 7 03:46:28 2003 UTC revision 1.37 by akim, Mon Aug 25 08:06:17 2003 UTC
# Line 328  m4_if(b4_defines_flag, 0, [], [#include Line 328  m4_if(b4_defines_flag, 0, [], [#include
328    
329  #define YYACCEPT        goto yyacceptlab  #define YYACCEPT        goto yyacceptlab
330  #define YYABORT         goto yyabortlab  #define YYABORT         goto yyabortlab
331  #define YYERROR         goto yyerrlab1  #define YYERROR         goto yyerrorlab
332    
333    
334  int  int
# Line 395  yy::]b4_parser_class_name[::parse () Line 395  yy::]b4_parser_class_name[::parse ()
395  #endif  #endif
396      }      }
397    
398      /* If the proper action on seeing token YYTOKEN is to reduce or to
399         detect an error, take that action.  */
400    n_ += ilooka_;    n_ += ilooka_;
401    if (n_ < 0 || last_ < n_ || check_[n_] != ilooka_)    if (n_ < 0 || last_ < n_ || check_[n_] != ilooka_)
402      goto yydefault;      goto yydefault;
# Line 439  yy::]b4_parser_class_name[::parse () Line 441  yy::]b4_parser_class_name[::parse ()
441    state_ = n_;    state_ = n_;
442    goto yynewstate;    goto yynewstate;
443    
444    /* Default action.  */  /*-----------------------------------------------------------.
445    | yydefault -- do the default action for the current state.  |
446    `-----------------------------------------------------------*/
447   yydefault:   yydefault:
448    n_ = defact_[state_];    n_ = defact_[state_];
449    if (n_ == 0)    if (n_ == 0)
450      goto yyerrlab;      goto yyerrlab;
451    goto yyreduce;    goto yyreduce;
452    
453    /* Reduce.  */  /*-----------------------------.
454    | yyreduce -- Do a reduction.  |
455    `-----------------------------*/
456   yyreduce:   yyreduce:
457    len_ = r2_[n_];    len_ = r2_[n_];
458      /* If LEN_ is nonzero, implement the default value of the action:
459         `$$ = $1'.  Otherwise, use the top of the stack.
460    
461         Otherwise, the following line sets YYVAL to garbage.
462         This behavior is undocumented and Bison
463         users should not rely upon it.  */
464    if (len_)    if (len_)
465      {      {
466        yyval = semantic_stack_[len_ - 1];        yyval = semantic_stack_[len_ - 1];
# Line 517  b4_syncline([@oline@], [@ofile@])[ Line 529  b4_syncline([@oline@], [@ofile@])[
529      state_ = defgoto_[n_ - ntokens_];      state_ = defgoto_[n_ - ntokens_];
530    goto yynewstate;    goto yynewstate;
531    
532    /* Report and recover from errors.  This is very incomplete.  */  /*------------------------------------.
533    | yyerrlab -- here on detecting error |
534    `------------------------------------*/
535   yyerrlab:   yyerrlab:
536    /* If not already recovering from an error, report this error.  */    /* If not already recovering from an error, report this error.  */
537    if (!errstatus)    if (!errstatus)
# Line 558  b4_syncline([@oline@], [@ofile@])[ Line 572  b4_syncline([@oline@], [@ofile@])[
572          message = "syntax error";          message = "syntax error";
573        error_ ();        error_ ();
574      }      }
   goto yyerrlab1;  
   
575    
   /*----------------------------------------------------.  
   | yyerrlab1 -- error raised explicitly by an action.  |  
   `----------------------------------------------------*/  
  yyerrlab1:  
576    if (errstatus == 3)    if (errstatus == 3)
577      {      {
578        /* If just tried and failed to reuse lookahead token after an        /* If just tried and failed to reuse lookahead token after an
579           error, discard it.  */           error, discard it.  */
580    
581        /* Return failure if at end of input.  */        /* Return failure if at end of input.  */
582        if (looka_ == eof_)        if (looka_ <= eof_)
583          goto yyabortlab;          {
584              /* If at end of input, pop the error token,
585                 then the rest of the stack, then return failure.  */
586              if (looka_ == eof_)
587                 for (;;)
588                   {
589                     state_stack_.pop ();
590                     semantic_stack_.pop ();
591                     location_stack_.pop ();
592                     if (state_stack_.height () == 1)
593                       YYABORT;
594    //               YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
595    // FIXME: yydestruct (yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[);
596                   }
597            }
598          else
599            {
600  #if YYDEBUG  #if YYDEBUG
601        YYCDEBUG << "Discarding token " << looka_             YYCDEBUG << "Discarding token " << looka_
602                 << " (" << name_[ilooka_] << ")." << std::endl;                      << " (" << name_[ilooka_] << ")." << std::endl;
603    //        yydestruct (yytoken, &yylval]b4_location_if([, &yylloc])[);
604  #endif  #endif
605        looka_ = empty_;             looka_ = empty_;
606            }
607      }      }
608    
609    /* Else will try to reuse lookahead token after shifting the error    /* Else will try to reuse lookahead token after shifting the error
610       token.  */       token.  */
611      goto yyerrlab1;
612    
613    
614    /*---------------------------------------------------.
615    | yyerrorlab -- error raised explicitly by YYERROR.  |
616    `---------------------------------------------------*/
617    yyerrorlab:
618    
619      state_stack_.pop (len_);
620      semantic_stack_.pop (len_);
621      location_stack_.pop (len_);
622      state_ = state_stack_[0];
623      goto yyerrlab1;
624    
625    errstatus = 3;  /*-------------------------------------------------------------.
626    | yyerrlab1 -- common code for both syntax error and YYERROR.  |
627    `-------------------------------------------------------------*/
628    yyerrlab1:
629      errstatus = 3;        /* Each real token shifted decrements this.  */
630    
631    for (;;)    for (;;)
632      {      {
# Line 601  b4_syncline([@oline@], [@ofile@])[ Line 644  b4_syncline([@oline@], [@ofile@])[
644    
645        /* Pop the current state because it cannot handle the error token.  */        /* Pop the current state because it cannot handle the error token.  */
646        if (state_stack_.height () == 1)        if (state_stack_.height () == 1)
647          goto yyabortlab;          YYABORT;
648    
649  #if YYDEBUG  #if YYDEBUG
650        if (debug_)        if (debug_)
# Line 625  b4_syncline([@oline@], [@ofile@])[ Line 668  b4_syncline([@oline@], [@ofile@])[
668          }          }
669  #endif  #endif
670    
671        state_ = (state_stack_.pop (), state_stack_[0]);        state_stack_.pop ();
672        semantic_stack_.pop ();        semantic_stack_.pop ();
673        location_stack_.pop ();;        location_stack_.pop ();
674          state_ = state_stack_[0];
675    
676  #if YYDEBUG  #if YYDEBUG
677        if (debug_)        if (debug_)

Legend:
Removed from v.1.36  
changed lines
  Added in v.1.37

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26