[Proto] Splitting AST
Let's say I want to take an expression involving operators +,-,*,/ and a function split. What I want to do is writing a transform taking such an expression and returning a fusion::vector or list (I guess) of expressions containing all sub-expressions of the original AST only separated on each insatcne of a split call. E.g : Xpr = a+b+split( c*d + split(e-f)); is turned into Xprs = [ a+b+placeholder<1>, c*d+placeholder<2>, e-f]; I guess I should use the State/Data parameters of the transform but i can't get the thing right. Any hints on how to tackle this without losing hairs ? -- ___________________________________________ Joel Falcou - Assistant Professor PARALL Team - LRI - Universite Paris Sud XI Tel : (+33)1 69 15 66 35
Joel Falcou wrote:
Let's say I want to take an expression involving operators +,-,*,/ and a function split.
What I want to do is writing a transform taking such an expression and returning a fusion::vector or list (I guess) of expressions containing all sub-expressions of the original AST only separated on each insatcne of a split call.
E.g :
Xpr = a+b+split( c*d + split(e-f)); is turned into
Xprs = [ a+b+placeholder<1>, c*d+placeholder<2>, e-f];
I guess I should use the State/Data parameters of the transform but i can't get the thing right. Any hints on how to tackle this without losing hairs ?
You're right, that's tricky. I'll think about it as time allows. -- Eric Niebler BoostPro Computing http://www.boostpro.com
You're right, that's tricky. I'll think about it as time allows. Best I have is having a state which is a pair of mpl::int and fusion::vector. Each split push_back its siblings, add the proper
Eric Niebler a écrit : placeholder to its parent and increment the placehodler # in the state. Hardest part is putting the placeholder in the parent :/ Maybe a two pass trasnform is needed ? -- ___________________________________________ Joel Falcou - Assistant Professor PARALL Team - LRI - Universite Paris Sud XI Tel : (+33)1 69 15 66 35
Joel Falcou wrote:
You're right, that's tricky. I'll think about it as time allows. Best I have is having a state which is a pair of mpl::int and fusion::vector. Each split push_back its siblings, add the proper
Eric Niebler a écrit : placeholder to its parent and increment the placehodler # in the state. Hardest part is putting the placeholder in the parent :/
Maybe a two pass trasnform is needed ?
I was thinking along the same lines. Maybe a first transform finds all unnumbered placeholders and replaces them with monotonically increasing placeholders. The following transform does just that: http://codepad.org/A7HnOvgd. It's not what you asked for, but maybe it helps. (Tested on msvc-9.) -- Eric Niebler BoostPro Computing http://www.boostpro.com
participants (2)
-
Eric Niebler
-
Joel Falcou