
I am resurrecting some ancient code written back before Proto was
an official Boost library. Things have changed quite a bit since then
so I need to port the code.
The code was never complete in the first place but I think much of it
still applies.
In any case, my goal is to take a Proto expression tree and transform
it into another kind of tree using custom classes. Essentially it's an
IR translation problem.
Let's take an add node for example. Here's what I have so far:
struct Base { ... };
struct Add : Base { ... }; // Custom expression nodes.
// Transform a two-operand node.
template

In the grammar rule when<>, I'm not sure I can make a nested function type like that. I'm trying to tell the grammar to match the children and transform them, passing them to the ConstructBinary transformation to build the Add subtree.
Any help is greatly appreciated. Thanks!
Here is a compilable testcase. Surprisingly, the nested function type seems
to compile. But how can I statically initialize a terminal that refers to a
boost::shared_ptr? I can't statically initialize the shared_ptr. Is there a
way to set a terminal's value after the fact?
-Dave
#include

// How to initialize? Variable av = {}; Variable bv = {}; Variable cv = {};
Hmm, surprisingly (to me), this works: Variable av = {boost::shared_ptr<Reference>(new Reference("a"))}; Variable bv = {boost::shared_ptr<Reference>(new Reference("b"))}; Variable cv = {boost::shared_ptr<Reference>(new Reference("c"))}; How can this be static initialization when it includes a dynamic allocation? With this, the testcase compiles and runs correctly. -Dave
participants (2)
-
David A. Greene
-
David Greene