From: Anicka Bernathova Date: Wed, 2 Jul 2008 13:07:38 +0000 (+0200) Subject: uaaa! X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=2d4891ec215352b630f92fc5265870a29e72d91e;p=umpf.git uaaa! --- diff --git a/Makefile b/Makefile index 32acee5..5734f8f 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ all: bison - gcc -Wall -O2 -o cond cond.tab.c + gcc -Wall -O2 -o cond -g cond.tab.c bison: bison cond.y diff --git a/cond.y b/cond.y index a199ed9..1a8e160 100644 --- a/cond.y +++ b/cond.y @@ -1,13 +1,19 @@ %{ #include +#include int yylex (void); void yyerror (char const *); %} -%token CONST +%union { + int b; + char* str; +} + +%token CONST %left EQ %left '|' '&' '^' %left '!' @@ -18,21 +24,22 @@ input: /* empty */ ; 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 -#include #define BUFSIZE 4096