title: error handling in YACC
body: <p>hi there i'm trying to make a simple parser and using lex and yacc. the thing is i wanna print my own error messages rather than <code>error</code> symbol used by yacc which prints <code>syntax error</code>. for example this is my yacc code;</p>
  
  <pre><code>%{
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include "y.tab.h"
  extern FILE *yyin;
  extern int linenum;
  %}
  
  %token INTRSW IDENTIFIER INTEGER ASSIGNOP SEMICOLON DOUBLEVAL DOUBLERSW COMMA 
  %token IF ELSE WHILE FOR
  %token CLOSE_BRA OPEN_BRA CLOSE_PARA OPEN_PARA EQ LE GE
  %token SUM MINUS MULTIP DIV
  
  %left OPEN_BRA OPEN_PARA
  %left MULTIP DIV
  %left SUM MINUS
  
  %union 
  {
          int number;
          char* string;
  }
  
  %token &lt;number&gt; INTEGER
  %token &lt;string&gt; IDENTIFIER
  
  %%
  program: 
      statement_list
      ;
  
  statement_list:
          statement_list statement
          |
          statement
          ;
  
  statement:
      if_statement OPEN_BRA statement_list CLOSE_BRA
      |
      if_statement 
      |
      assignment_block
      |
      single_assignment 
      ;
  
  if_statement:
      IF OPEN_PARA condition_statement CLOSE_PARA
      ;
  
  condition_statement:
      logical_expression
      ;
  
  logical_expression:
      expression EQ expression
      |
      expression LE expression
      |
      expression GE expression
      ;
  
  expression:
      double
      |
      IDENTIFIER
      |
      OPEN_PARA expression CLOSE_PARA
      |
      expression MULTIP expression
      |
      expression DIV expression
      |
      expression SUM expression
      |
      expression MINUS expression
      ;
  
  assignment_block:
      integer_assignment_block
      | 
      double_assignment_block
      ;
  
  integer_assignment_block:
      INTRSW integer_assignment_list SEMICOLON
      ;
  
  double_assignment_block:
      DOUBLERSW double_assignment_list SEMICOLON
      ;
  
  integer_assignment_list:
      integer_assignment
      |
      integer_assignment_list COMMA integer_assignment
      ;
  
  double_assignment_list:
      double_assignment
      |
      double_assignment_list COMMA double_assignment
      ;
  
  single_assignment:
      IDENTIFIER ASSIGNOP double SEMICOLON
      |
      IDENTIFIER ASSIGNOP IDENTIFIER SEMICOLON
      |
      error ';' { printf("You made en error"); }  
      ;
  
  integer_assignment:
      IDENTIFIER ASSIGNOP INTEGER
      |
      IDENTIFIER
      ;
  
  double_assignment:
      IDENTIFIER ASSIGNOP double
      |
      IDENTIFIER
      ;
  
  double:
      DOUBLEVAL
      |
      INTEGER 
      ;
  
  %%
  void yyerror(char *s){
      fprintf(stderr,"%s Error at line: %d\n",s, linenum);
  }
  int yywrap(){
      return 1;
  }
  int main(int argc, char *argv[])
  {
      /* Call the lexer, then quit. */
      yyin=fopen(argv[1],"r");
      yyparse();
      fclose(yyin);
      return 0;
  }
  </code></pre>
  
  <p>so this the block i add error statement.</p>
  
  <pre><code>single_assignment:
      IDENTIFIER ASSIGNOP double SEMICOLON
      |
      IDENTIFIER ASSIGNOP IDENTIFIER SEMICOLON
      |
      error ';' { printf("You made en error"); }  
      ;
  </code></pre>
  
  <p>so i write a=7 (without ';') in a line it just says <code>syntax error Error at line:7</code>. so where is my error message_? i will be very very glad if you can help me about this issue. and thanks anyway</p>