Subject: Re: [proto] Visitor Design Pattern
From: Joel de Guzman (joel_at_[hidden])
Date: 2010-10-22 06:18:59
On 10/22/10 5:44 PM, Thomas Heller wrote:
> On Friday 22 October 2010 11:29:07 Joel de Guzman wrote:
>> On 10/22/10 4:17 PM, Thomas Heller wrote:
>>> On Friday 22 October 2010 09:58:25 Eric Niebler wrote:
>>>> 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.
>>> Ok, this formulation makes it much clearer :)
>> It's just the metaphor! And what I saying is that you will get into
>> confusion land if you mix metaphors from different domains. Proto uses
>> the parsing domain and it makes sense (*). It may (and I say may) be
>> possible to extend that metaphor and in the end it may be possible
>> to incorporate that into proto instead of phoenix (if it is indeed
>> conceptually understandable and reusable) --an opportunity that may
>> be missed if you shut the door and dismiss the idea prematurely.
>> It is OK to switch metaphors and have a clean cut. But again,
>> my point is: use only one metaphor. Don't mix and match ad-hoc.
>> (* regardless if it doesn't do any parsing at all!)
> Makes sense. Letting the idea of two level grammars sinking in ... I still
> have problems to adapt it to the parameterized semantic actions solution we
I don't think 2-level grammars include semantic actions. Attribute
grammars include (semantic)actions while 2-level grammars include
parameterized rules and generic reusable grammars (plus more). To
my mind though, in a conceptual POV, a semantic action is just
an epsilon node in the grammar and is indistinguishable from any
other. In Spirit, for example, it's just a node like any other
parser node. The main difference is that it is a generator instead
of a consumer; but that too is an arbitrary distinction.
-- Joel de Guzman http://www.boostpro.com http://spirit.sf.net
Proto list run by eric at boostpro.com