Problem with bison 2.4.1
Hi,
Iam using fedora 11 version. I have a problem with bison 2.4.1. I am writing compiler for ADA programs %token INTEGER_TOK 347 %left AND_TOK OR_TOK XOR_TOK %left EQUAL_TOK NOT_EQUAL_TOK LESS_TOK GREATER_TOK LESS_EQUAL_TOK GREATER_EQUAL_TOK %left PLUS_TOK MINUS_TOK %left MULT_TOK DIVIDE_TOK MOD_TOK REM_TOK %left DOUBLE_STAR_TOK ABS_TOK %right NOT_TOK %left UPLUS UMINUS }% unary_operator : PLUS_TOK %prec UPLUS { if(trace) printf("Unary_operator 1\n"); $$.st_ptr=mknode1("adding_operator",NULL,mknode1("PLUS_TOK",NULL,NULL,NULL,NULL),NULL,NULL); } |MINUS_TOK %prec UMINUS { if(trace) printf("Unary_operator 2\n"); $$.st_ptr=mknode1("adding_operator",NULL,mknode1("MINUS_TOK",NULL,NULL,NULL,NULL),NULL,NULL); } ; Here %token is working. But operator precedence relation is not working. Operator precedence relation code is %left AND_TOK OR_TOK XOR_TOK %left EQUAL_TOK NOT_EQUAL_TOK LESS_TOK GREATER_TOK LESS_EQUAL_TOK GREATER_EQUAL_TOK %left PLUS_TOK MINUS_TOK %left MULT_TOK DIVIDE_TOK MOD_TOK REM_TOK %left DOUBLE_STAR_TOK ABS_TOK %right NOT_TOK %left UPLUS UMINUS is not working. i believe this is a problem with bison. For example if give an operation a:=2*3**2/9 mod 2+b*2 rem 2; then first operation should be exponential operation then multiplication. Instead it works in the order it is given. |
Quote:
|
All times are GMT -5. The time now is 06:24 PM. |