title: Flex and Bison Calculator
body: <p>I'm trying to implement a calculator for nor expressions, such as <code>true nor true nor (false nor false)</code> using Flex and Bison, but I keep getting my error message back. Here is my .l file:</p>
  
  <pre><code>%{
  #include &lt;stdlib.h&gt;
  #include "y.tab.h"
  %}
  
  %% 
  ("true"|"false")    {return BOOLEAN;}
  
  .|\n    {yyerror();}
  
  %%
  
  int main(void)
  {
      yyparse();
      return 0;
  }
  
  int yywrap(void)
  {
       return 0;
  }
  int yyerror(void)
  {
       printf("Error\n");
  }
  </code></pre>
  
  <p>Here is my .y file:</p>
  
  <pre><code>/* Bison declarations.  */
   %token BOOLEAN
   %left 'nor'
  
   %% /* The grammar follows.  */
   input:
     /* empty */
   | input line
   ;
  
   line:
     '\n'
   | exp '\n'  { printf ("%s",$1); }
   ;
  
   exp:
     BOOLEAN            { $$ = $1;           }
   | exp 'nor' exp      { $$ = !($1 || $3);  }
   | '(' exp ')'        { $$ = $2;           }
   ;
   %%
  </code></pre>
  
  <p>Does anyone see the problem?</p>