Hello i have a problem with types of non-terminals in bison

The testing of the types doesn't run as it have to do in the following example


expr:
expr '+' expr {if ($<intValue>1 && $<intValue>3) {$<intValue>$= $<intValue>1+$<intValue>3 ;} /* beides int*/

else if($<floatValue>1 && $<floatValue>3) {$<floatValue>$= $<floatValue>1+$<floatValue>3 ;} /* beides float*/

else if($<intValue>1 && $<floatValue>3) {$<floatValue>$= $<intValue>1+$<floatValue>3 ;} /* eins int eins float*/

else if($<floatValue>1 && $<intValue>3) {$<floatValue>$= $<floatValue>1+$<intValue>3 ;} /* eins foat eins int*/

                    else yyerror("unmatching types!");
                   }


Only if both Types of expr are from intValue $$ should become intValue, but the first if-clause always match also by 4.5 + 3.4 .

%union {
   double floatValue;
int intValue; }

So where is my Error. I thought that $<intValue>1 tests if the first expr ist an int or not, is this correct ?
If not how can I check if $1 is an int or an float ?


Thanks David



_______________________________________________
help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to