Hi all,
I have some problem with precedence declaration in OCaml parser.
If I what to say exponential(ATOB) is prior to *(STAR) and / (DIVIDE),
* and / are prior to +(PLUS) and -(MINUS),
I wrote the following in the parser:
/***** Precedence Rules *****/
...
%left PLUS MINUS
%left STAR DIVIDE
%left ATOB
...
But I still have the following problems:
(1) It appears that the parser
reads "test = 2^2 + 7;" as "test = 2^9" instead of "test = 4+7", which
would follow the conventional order of operations.
(2)It also interprets "test = (1^2)/3 + 1;" as "test = (1 ^ 2
/ (3 + 1));"
Can any one help me to see why it happens? Why the precedence rules doesn't work?
Thanks,
Angela
------------------------------------------
Dept. of CS, Rice U.
------------------------------------------