> I hardly can't believe that this is the way I should have to work with
> Parslet!
>
> My question is how to define transformation rules in a smart way? My
> guess is that I'm not using the right matching features
> like, for example, sequence or subtree?
>

Hi Thiel,

I am guessing that your grammar has a problem. It must be possible to 
add/remove .as(...) so that you get a tree more like the one portrayed 
here: http://kschiess.github.com/parslet/get-started.html (down below).

Specifically, you should have a left hand side of 'a' and a right hand 
side that contains the tree for 'b + c'. This way, recursive matching 
makes actual sense.

The tree you have could be transformed using something like this, 
although my mind rebels against the loss of associativity between 'a' 
and '+b', '+c':

   transform = Parslet::Transform.new do
     rule(:factor => {:ident => simple(:x)}) { x }
     rule(:plus => simple(:op), :term => simple(:x)) { [op, x] }
     rule(:term => simple(:x)) { x }
     rule(:result => subtree(:something)) { something }
   end

regards,
kaspar

Reply via email to