Boost logo

Proto :

Subject: Re: [proto] Thoughts on traversing proto expressions and reusing grammar
From: Eric Niebler (eric_at_[hidden])
Date: 2010-10-20 09:02:01


On 10/14/2010 12:27 PM, Eric Niebler wrote:
<snip>
> - A new set of actions can be created easily by delegating
> to MyActions::action by default, and specializing only those
> rules that need custom handling.

The code I sent around actually falls short on this promise. Here's an
updated design that corrects the problem. The key is realizing that the
actions need to be parameterized by ... the actions. That way, they can
be easily subclassed.

That is, we now have this:

// A collection of semantic actions, indexed by phoenix grammar rules
struct PhoenixDefaultActions
{
    template<typename Rule, typename Actions = PhoenixDefaultActions>
    struct action;
};

struct MyActions
{
    // Inherit default behavior from PhoenixDefaultActions
    template<typename Rule, typename Actions = MyActions>
    struct action
      : PhoenixDefaultActions::action<Rule, Actions>
    {};

    // Specialize action<> for custom handling of certain
    // grammar rules here...
};

If you don't ever pass MyActions to PhoenixDefaultActions, then any
specializations of MyActions::actions will never be considered.

-- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com



Proto list run by eric at boostpro.com