title: Yacc %define parse.error verbose generates error
body: <p>When I try to get more out of my "syntax error", I seem to use the way described on so many websites, but all seem to create their own errors, for some reason.</p>
  
  <p>I was getting standard "syntax error" on line 5 of the Input file... so I wanted to add better error handling so I can see what exactly is the issue. But</p>
  
  <pre><code>%define parse.error verbose
  </code></pre>
  
  <p>However, it gives me this; </p>
  
  <pre><code>error: %define variable 'parse.error' is not used
  </code></pre>
  
  <p>Below are my files, as long as you keep it constructive, feel free to comment on more then just the error parts, any help is welcome :)
  (As long as the errors get fixed as well :P )
  Thanks in advance!</p>
  
  <p>lex file;</p>
  
  <pre><code>%option nounput yylineno
  %{
  #include "yaccTest.tab.h"
  void InvalidToken();
  void extern yyerror (char *s);
  %}
  
  whitespace      [ \t\r\v\f]
  linefeed        \n
  
  %%
  
  ";"                     {return SEMICOLON;}
  "="                     {return EQ;}
  "+"                     {return PLUS;}
  "-"                     {return MINUS;}
  "*"                     {return MULTIPLY;}
  "/"                     {return DEVIDE;}
  "("                     {return BO;}
  ")"                     {return BC;}
  "^"                     {return POWER;}
  
  "print"                 {return PRINT;}
  
  [a-zA-Z][a-zA-Z0-9]*    {yylval.charValue = yytext[0]; return IDENTIFIER;}
  [0-9]+                  {yylval.intValue = atoi(yytext); return NUMBER;}
  {whitespace}            {;}
  .                       {InvalidToken();}
  
  %%
  
  void yyerror(char *s) {
  fprintf(stderr, "\nERROR ON LINE %d : \n %s\n", yylineno, s);
  exit(0);
  }
  
  void InvalidToken(){
  printf("ERROR ON LINE %d : \n Invalid Token %s\n", yylineno,yytext);
  exit(0);
  }
  
  int yywrap (void) {return 1;}
  </code></pre>
  
  <p>yacc file;</p>
  
  <pre><code>%{
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int getVariableValue(char varID);
  extern int yylineno;
  int varIDs[52] = {0};
  int varValues[52] = {0};
  %}
  
  %define parse.lac full
  %define parse.error verbose
  
  %union YYSTYPE {int intValue; char charValue;}
  
  %token COLON SEMICOLON ST SE EQ GE GT PLUS MINUS MULTIPLY DEVIDE BO BC CBO CBC POWER LOOP PRINT
  %token &lt;intValue&gt; NUMBER
  %token &lt;charValue&gt; IDENTIFIER CHAR
  
  %type &lt;charValue&gt; declaration expression
  %type &lt;intValue&gt; numval
  
  %right EQ
  %left PLUS MINUS
  %left MULTIPLY DEVIDE
  %left POWER
  
  %%
  
  declaration : IDENTIFIER EQ expression
  | declaration IDENTIFIER EQ expression
  ;
  
  expression : numval SEMICOLON
  | PRINT BO numval BC SEMICOLON              {printf("Printing");}
  ;
  
  numval : NUMBER                 {$$ = $1;}
  | NUMBER PLUS NUMBER        {$$ = $1 + $3;}
  | NUMBER MINUS NUMBER       {$$ = $1 - $3;}
  | NUMBER MULTIPLY NUMBER    {$$ = $1 * $3;}
  | NUMBER DEVIDE NUMBER      {$$ = $1 / $3;}
  | NUMBER POWER NUMBER       {int i;int j = $1;for(i = 1; i &lt; $3; i++){j=j*$1;};$$ = j;}
  ;
  
  %%
  
  int getVariableValue(char varID) {
  int i, j, localTemp;
  for (i=0;i&lt;((sizeof(varIDs)/sizeof(varIDs[0])));i++) {
      if (varID == varIDs[i]) {
          localTemp = varValues[i];
      }
  }
  return localTemp;
  }
  
  int setVariableValue(char varID, int varValue) {
      int i, varPresent = 0;
      for (i=0;i&lt;((sizeof(varIDs)/sizeof(varIDs[0])));i++) {
          if (varID == varIDs[i]) {
              varValues[i] = varValue;
              varPresent = 1;
          }
      }
  
      if (varPresent == 0) {
          for (i=0;i&lt;((sizeof(varIDs)/sizeof(varIDs[0])));i++) {
              if (&amp;(varIDs[i]) == NULL) {
                  if (&amp;(varValues[i]) == NULL) {
                      varIDs[i] = varID;
                      varValues[i] = varValue;
                  }
                  else {
                      missingVarIDError(varID, varValue);
                  }
              }
              else {
                  notEnoughStorageError(varID, varValue);
              }
          }
      }
  }
  
  int missingVarIDError(char *id, int val){
  printf("\nERROR ON LINE %d : \nIdentifier '%s' not found, but assigned location DOES have a value; %s",yylineno,id,val);
  exit(0);
  }
  
  int notEnoughStorageError(char *id, int val){
  printf("\nERROR ON LINE %d : \nIdentifier '%s' did not fit in StorageArray, '%3' not stored!",yylineno,id,val);
  exit(0);
  }
  
  int main (void) {
  return yyparse ( );
  return 0;
  }
  </code></pre>
  
  <p>Input file;</p>
  
  <pre><code>x=4;
  y=2+6;
  X=2;
  z=5;
  print(4);
  </code></pre>