Posted By:
David_Jones
Posted On:
Thursday, January 24, 2002 01:54 PM
I want to parse expressions such that the resulting parse trees are of the form: #(BIN_OP left op right) For "a+b-1", I want to see: #(BIN_OP #(BIN_OP a PLUS b) MINUS 1) I have the following code: exp7 : exp8 ( binop7 exp8 { #exp7 = #([BIN_OP, "BIN_OP"], exp7); } )* ; However, after assigning to #exp7, subsequent children are added to the right of the last child, which is not what I want. I get instead: #(BIN_OP #(BIN_OP a PLUS b MINUS 1)) Since the documented behavior of assigning to #exp7 is not what I want, how
More>>
I want to parse expressions such that the resulting parse trees are of the form:
#(BIN_OP left op right)
For "a+b-1", I want to see:
#(BIN_OP #(BIN_OP a PLUS b) MINUS 1)
I have the following code:
exp7 :
exp8 ( binop7 exp8
{ #exp7 = #([BIN_OP, "BIN_OP"], exp7); } )*
;
However, after assigning to #exp7, subsequent children are added to the right of the last child, which is not what I want. I get instead:
#(BIN_OP #(BIN_OP a PLUS b MINUS 1))
Since the documented behavior of assigning to #exp7 is not what I want, how do I construct this tree, such that the snippet in
( )*
works properly? (Note: if I don't have
( )*
then I do get an imaginary parent. This is well documented with plenty of examples.)
<<Less