]> mj.ucw.cz Git - umpf.git/blobdiff - cond.y
fix ass_right bugs, finish print_code
[umpf.git] / cond.y
diff --git a/cond.y b/cond.y
index 5d5751b3c32751bb3edf3c3af0245eae5164cc2b..5410156de9db8915290caf5550d866641268f55f 100644 (file)
--- a/cond.y
+++ b/cond.y
@@ -16,6 +16,7 @@ static struct tree* tree_malloc(int type);
        struct tree* tr;        
 }
 
+%right <n> '!'
 %token <str> CONST
 %token <n> NUM
 %token <str> VAR
@@ -26,19 +27,19 @@ static struct tree* tree_malloc(int type);
 %nonassoc KW_ELSE
 %left ARROW
 %left <n> EQ NEQ GE LE '<' '>' RE NRE
-%left '='
-%left '.'
-%left '+' '-' 
-%left '*' '/'
+%left <n> '='
+%left <n> '.'
+%left <n> '+' '-' 
+%left <n> '*' '/'
 %left <n> '|'
 %left <n> '^'
 %left <n> '&'
-%left <n> '!'
 %type <tr> input 
 %type <tr> command 
 %type <tr> next 
 %type <tr> ass 
 %type <tr> ass_right 
+%type <tr> ass_right_p
 %type <tr> cif
 %type <tr> arrow 
 %type <tr> cond
@@ -146,7 +147,7 @@ rop:        '>'
 ;
 
 ass:
-       VAR '=' ass_right       {
+       VAR '=' ass_right_p     {
                                        $$ = tree_malloc(ST_ASS);
 
                                        $$->pt.ass.left = tree_malloc(ST_LEAF);
@@ -195,10 +196,38 @@ right:    /* empty */ { $$ = K_EMPTY; }
        | KW_MAIL { $$ = K_MAIL; }
 ;
 
+ass_right_p:   '(' ass_right ')'       {$$ = $2; }
+               | ass_right     {$$ = $1; }
+;
+
 ass_right:     leaves
                | ass_right '.' ass_right       {
                                        $$ = tree_malloc(ST_OP);
-                                       $$->pt.op.op = '.';
+                                       $$->pt.op.op = $2;
+                                       $$->pt.op.left = $1;    
+                                       $$->pt.op.right = $3;   
+                               }
+               | ass_right '+' ass_right       {
+                                       $$ = tree_malloc(ST_OP);
+                                       $$->pt.op.op = $2;
+                                       $$->pt.op.left = $1;    
+                                       $$->pt.op.right = $3;   
+                               }
+               | ass_right '-' ass_right       {
+                                       $$ = tree_malloc(ST_OP);
+                                       $$->pt.op.op = $2;
+                                       $$->pt.op.left = $1;    
+                                       $$->pt.op.right = $3;   
+                               }
+               | ass_right '*' ass_right       {
+                                       $$ = tree_malloc(ST_OP);
+                                       $$->pt.op.op = $2;
+                                       $$->pt.op.left = $1;    
+                                       $$->pt.op.right = $3;   
+                               }
+               | ass_right '/' ass_right       {
+                                       $$ = tree_malloc(ST_OP);
+                                       $$->pt.op.op = $2;
                                        $$->pt.op.left = $1;    
                                        $$->pt.op.right = $3;   
                                }