Boost logo

Proto :

Subject: Re: [proto] Visitor Design Pattern
From: Eric Niebler (eric_at_[hidden])
Date: 2010-10-22 03:58:25


On 10/22/2010 12:33 AM, Thomas Heller wrote:
> On Friday 22 October 2010 09:15:47 Eric Niebler wrote:
>> On 10/21/2010 7:09 PM, Joel de Guzman wrote:
>>> Check out the doc I sent (Annex A). It's really, to my mind,
>>> generic languages -- abstraction of rules and templated grammars
>>> through metanotions and hyper-rules.
>>
>> Parameterized rules. Yes, I can understand that much. My
>> understanding stops when I try to imagine how to build a parser
>> that recognizes a grammar with parameterized rules.
>
> And I can't understand how expression templates relate to parsing.

It doesn't in any practical sense, really. No parsing ever happens in
Proto. The C++ compiler parses expressions for us and builds the tree.
Proto grammars are patterns that match trees. (It is in this sense
they're closer to schemata, not grammars that drive parsers.)

They're called "grammars" in Proto not because they drive the parsing
but because they describe the valid syntax for your embedded language.

>>> I have this strong feeling that that's the intent of Thomas and
>>> your recent designs. Essentially, making the phoenix language a
>>> metanotion in itself that can be extended post-hoc through
>>> generic means.
>>
>> I don't think that's what Thomas and I are doing. vW-grammars
>> change the descriptive power of grammars. But we don't need more
>> descriptive grammars. Thomas and I aren't changing the grammar of
>> Phoenix at all. We're just plugging in different actions. The
>> grammar is unchanged.
>
> Exactly.
> Though, I think this is the hard part to wrap the head around. We
> have a grammar, and this very same grammar is used to describe
> "visitation".

It's for the same reason that grammars are useful for validating
expressions that they are also useful for driving tree traversals:
pattern matching. There's no law that the /same/ grammar be used for
validation and evaluation. In fact, that's often not the case.

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

Proto list run by eric at boostpro.com