Q:

Flex Bison Not Reading Full Input

I am writing a nor calculator using Flex and Bison. Here is my .l file:
%{
#include <stdlib.h>
#include "y.tab.h"
%}

%% 
("true"|"false")    {return BOOLEAN;}
"nor"               {return NOR;}
.                   {return yytext[0];}

%%

int main(void)
{
    yyparse();
    return 0;
}

int yywrap(void)
{
     return 0;
}
int yyerror(void)
{
    getchar();
    printf("Error\n");
}

Here is my .y file:
/* Bison declarations.  */
 %token BOOLEAN
 %token NOR
 %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;           }
 ;
 %%

The problem is that if I type an input such as "true nor false", the lexer only gets to return BOOLEAN, then return yytext[0], then throws my error (in the flex code). Anyone see what's wrong?

A:

the problem is here :
%left 'nor'

and 
exp:
   BOOLEAN            { $$ = $1;           }
 | exp 'nor' exp      { $$ = !($1 || $3);  }
 | '(' exp ')'        { $$ = $2;           }
 ;

you'v written 'nor' as a terminal token, your parser can't recognize 'nor' as token, so you should substitute this by NOR as the lexer returns:
"nor"               {return NOR;}

solution
    %left NOR

and 

    exp:
       BOOLEAN            { $$ = $1;           }
     | exp NOR exp      { $$ = !($1 || $3);  }
     | '(' exp ')'        { $$ = $2;           }
     ;

