X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=cond.y;h=5410156de9db8915290caf5550d866641268f55f;hb=8c49eea02255539aa7c92ec3c1bdd5dc9bc737c5;hp=ec5bc8e34a53b32580e55c56f46b705ef66d3360;hpb=0dc94edb85ce7d4f6972a5a2339e7500a9a30dbe;p=umpf.git diff --git a/cond.y b/cond.y index ec5bc8e..5410156 100644 --- a/cond.y +++ b/cond.y @@ -16,6 +16,7 @@ static struct tree* tree_malloc(int type); struct tree* tr; } +%right '!' %token CONST %token NUM %token VAR @@ -26,24 +27,23 @@ static struct tree* tree_malloc(int type); %nonassoc KW_ELSE %left ARROW %left EQ NEQ GE LE '<' '>' RE NRE -%left '=' +%left '=' %left '.' %left '+' '-' %left '*' '/' %left '|' %left '^' %left '&' -%left '!' %type input %type command %type next %type ass %type ass_right +%type ass_right_p %type cif %type arrow %type cond %type rop -%type bop %type left %type right %type leaves @@ -147,7 +147,7 @@ rop: '>' ; ass: - VAR '=' ass_right { + VAR '=' ass_right_p { $$ = tree_malloc(ST_ASS); $$->pt.ass.left = tree_malloc(ST_LEAF); @@ -196,20 +196,41 @@ right: /* empty */ { $$ = K_EMPTY; } | KW_MAIL { $$ = K_MAIL; } ; +ass_right_p: '(' ass_right ')' {$$ = $2; } + | ass_right {$$ = $1; } +; + ass_right: leaves - | ass_right bop ass_right { + | 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; + } + | ass_right '/' ass_right { $$ = tree_malloc(ST_OP); $$->pt.op.op = $2; $$->pt.op.left = $1; $$->pt.op.right = $3; } -; - -bop: '.' {$$ = $1} - | '+' {$$ = $1} - | '-' {$$ = $1} - | '*' {$$ = $1} - | '/' {$$ = $1} ; %%