# What am I doing to get a cycle in my tree?

Created May 3, 2012

**Monty Zukowski**

Remember that tree construction doesn't deal only with nodes, but with siblings as well.

I was trying to turn `#(PLUSEQ pi:idRef pe:expr)` into
`#(ASSIGNMENT pi #(PLUS pi pe))` (Like `a+=b --> a = a + b`)

assignment : #(ASSIGNMENT idRef expr) |! #(PLUSEQ pi:idRef pe:expr) { newExpr = #(#[PLUS, "+"], pi, pe); #assignment = #(#[ASSIGNMENT,"ASSIGNMENT"], pi, newExpr); } }

The solution is to copy pi like so:

newExpr = #(#[PLUS, "+"], #[pi.getType(), pi.getText()], pe); #assignment = #(#[ASSIGNMENT,"ASSIGNMENT"], pi, newExpr);

Thanks again to Johan Rosman for help on this one!