]> mj.ucw.cz Git - umpf.git/commitdiff
uaaa!
authorAnicka Bernathova <anicka@anicka.net>
Wed, 2 Jul 2008 13:07:38 +0000 (15:07 +0200)
committerAnicka Bernathova <anicka@anicka.net>
Wed, 2 Jul 2008 13:07:38 +0000 (15:07 +0200)
Makefile
cond.y

index 32acee5f25c59306bc6297a2a97d1135a5420e6e..5734f8f44f3cbe866e66c0822229ffb4780fa722 100644 (file)
--- 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 a199ed98463496506a485d4453d8bf3459a94be9..1a8e16078bbf609bfe13996f26eeeabdf1fcdeae 100644 (file)
--- a/cond.y
+++ b/cond.y
@@ -1,13 +1,19 @@
 %{
 
 #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 '!'
@@ -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 <ctype.h>
-#include <string.h>
 
 #define BUFSIZE 4096