%{
#include <stdio.h>
+#include <string.h>
int yylex (void);
void yyerror (char const *);
%}
-%token CONST
+%union {
+ int b;
+ char* str;
+}
+
+%token <str> CONST
%left EQ
%left '|' '&' '^'
%left '!'
;
line: '\n'
- | boo '\n' { printf("%s\n",$1?"true":"false"); }
- | boo EQ boo { $$ = $1 == $2 }
- | boo '|' boo { $$ = $1 || $2 }
- | boo '&' boo { $$ = $1 && $2 }
- | boo '^' boo { $$ = ($1 || $2) && !($1 && $2) }
- | '!' boo { $$ = ! $1 }
+ | boo '\n' { printf("%s\n",$1?"true":"false"); }
;
boo:
+ CONST EQ CONST { $$ = ! strcmp($1, $2); }
+ | boo EQ boo { $$ = $1 == $2 }
+ | boo '|' boo { $$ = $1 || $2 }
+ | boo '&' boo { $$ = $1 && $2 }
+ | boo '^' boo { $$ = ($1 || $2) && !($1 && $2) }
+ | '!' boo { $$ = ! $1 }
+;
;
%%
#include <ctype.h>
-#include <string.h>
#define BUFSIZE 4096