title: bison doesn't call yyerror when detecting a parsing error
body: <p>I am writing a parser with bison. I ran into a problem that bison detected the parsing error but didn't call <code>yyerror</code>.</p>
  
  <p>Here are my scripts fragments to deal with class definition:</p>
  
  <pre><code>    %{ ...
         void yyerror(char *s); 
         Program ast_root;         /* the result of the parse  */
         Classes parse_results;    
      }%
      ...
      %%
      /* 
      Save the root of the abstract syntax tree in a global variable.
      */
      program     : class_list    { @$ = @1; ast_root = program($1); }
      ;
  
      class_list
      : class                     /* single class */
      { $$ = single_Classes($1);
      parse_results = $$; }
      | class_list class  /* several classes */
      { $$ = append_Classes($1,single_Classes($2));
      parse_results = $$; }
      | class_list error
      {
        $$ = $1;
      } 
      ; 
  
     /* If no parent is specified, the class inherits from the Object class. */
     class       : CLASS TYPEID '{' dummy_feature_list '}' ';' 
     { @$ = @2;
      SET_NODELOC(@2);
      $$ = class_($2,idtable.add_string("Object"),$4,
      stringtable.add_string(curr_filename)); }
      | CLASS TYPEID INHERITS TYPEID '{' dummy_feature_list '}' ';'
      {
        @$ = @2;
        SET_NODELOC(@2);         
        $$ = class_($2,$4,$6,stringtable.add_string(curr_filename)); 
     }
     ; 
  </code></pre>
  
  <p>The test file is like:</p>
  
  <pre><code>(* no error *)
  class A {
  };
  
  (* error 1:  b is not a type identifier *)
  Class b inherits A {
  };
  
  (* error 2:  a is not a type identifier *)
  Class C inherits a {
   }; 
  
  (* error 3:  keyword inherits is misspelled *)
  Class D inherts A {
  };
  
  (* error 4:  closing brace is missing *)
  Class E inherits A {
  ;
  </code></pre>
  
  <p>The running result is shown below:</p>
  
  <p><em>"bad.cl", line 15: syntax error at or near OBJECTID = b</em></p>
  
  <p><em>"bad.cl", line 19: syntax error at or near OBJECTID = a</em></p>
  
  <p><em>"bad.cl", line 28: syntax error at or near ';'</em></p>
  
  <p><em>Compilation halted due to lex and parse errors</em></p>
  
  <p>The third error which has wrong spelling of <strong>inherits</strong> is not displayed.</p>
  
  <p>I check the debug information. Error2 is like:</p>
  
  <pre><code>Stack now 0
  Entering state 3
  Reading a token: Next token is token CLASS (: )
  Shifting token CLASS (: )
  Entering state 1
  Reading a token: Next token is token TYPEID (: )
  Shifting token TYPEID (: )
  Entering state 5
  Reading a token: Next token is token INHERITS (: )
  Shifting token INHERITS (: )
  Entering state 9
  Reading a token: Next token is token OBJECTID (: )
  "bad.cl", line 19: syntax error at or near OBJECTID = a
  Error: popping token INHERITS (: )
  Stack now 0 3 1 5
  Error: popping token TYPEID (: )
  Stack now 0 3 1
  Error: popping token CLASS (: )
  Stack now 0 3
  Shifting token error (: )
  Entering state 7
  Reducing stack by rule 4 (line 165):
     $1 = nterm class_list (: )
     $2 = token error (: )
  -&gt; $$ = nterm class_list (: )
  Stack now 0
  Entering state 3
  Next token is token OBJECTID (: )
  Error: discarding token OBJECTID (: )
  Shifting token error (: )
  </code></pre>
  
  <p>I see that after <code>Reading a token: Next token is token OBJECTID (: )</code> , bison detects the parsing error so it calls <code>yyerror</code> and print <code>"bad.cl", line 19: syntax error at or near OBJECTID = a</code></p>
  
  <p>But the information of error 3 is like:</p>
  
  <pre><code>Stack now 0
  Entering state 3
  Reading a token: Next token is token CLASS (: )
  Shifting token CLASS (: )
  Entering state 1
  Reading a token: Next token is token TYPEID (: )
  Shifting token TYPEID (: )
  Entering state 5
  Reading a token: Next token is token OBJECTID (: )
  Error: popping token TYPEID (: )
  Stack now 0 3 1
  Error: popping token CLASS (: )
  Stack now 0 3
  Shifting token error (: )
  Entering state 7
  </code></pre>
  
  <p>Obviously when it encounters <code>Reading a token: Next token is token OBJECTID (: )</code> , bison detects an error but there is no error message printed so the <code>yyerror</code> has not been called. </p>
  
  <p>I just feel so confused why this could happen since the above three errors are almost the same. Any help would be appreciated.</p>