Re: spirit grammar graphs

Joel de Guzman <[email protected]> Fri, 01 Apr 2011 19:33:39 +0800
Newsgroups gmane.comp.parsers.spirit.devel
Message-ID <[email protected]>
On 3/31/2011 10:53 AM, Gordon Woodhull wrote:
> Hi Larry -
>
> On Mar 30, 2011, at 8:20 PM, Larry Evans wrote:
>> mout()<<"test:3 subrules with sr0 terminal\n"; spirit_simple::subrule<0>  sr0;
>> spirit_simple::subrule<1>  sr1; spirit_simple::subrule<2>  sr2;
>> spirit_simple::terminal term0; #ifndef SubruleMapBuildMethodTemplate typedef map <
>> typeof(sr0=sr1>>term0) , typeof(sr1=sr2) , typeof(sr2=sr0)
>>>
>> lhs2rhs_map0 ;
>>
>> where map is the mpl::map; hence, is generated at compile time. The, sr0....sr2, are
>> non-terminals, and term0 is a terminal in the grammar defined by productions:
>>
>> sr0=sr1>>term0 sr1=sr2 sr2=sr0
>
> Yes!  I was thinking something similar.  I'll take a look and maybe put a reference in
> my paper.  :-D
>
>>
>> Note, there's only 1 binary operator,>>, but it should be no problem to define others
>> similarly.  Also note that the grammar productions do contain a cycle:
>>
>> sr0->sr1->sr2->sr0
>>
>> Hope the code gives you some ideas :)
>
> Nice proof-of-concept; I think so!  I bet you didn't try to cross the runtime barrier
> so you could have live data in there, but I think there's a way to do it with proto.
>
> Seems like at worst you could have the whole grammar as a proto expression and produce
> the whole grammar graph at once.  Another possibility is that each statement produces a
> tree and they are glued together afterward.
>
> Well I better not think too much on a tangent here.
>
>> Good luck.
>
> Obviously I'm not trying to implement this before May, just looking for some
> interesting examples for my talk at this point.

Just a quick note for now: FYI, classic Spirit had subrules and has been
ported to Spirit2 recently. Anyway, see:

http://www.boost.org/doc/libs/1_41_0/libs/spirit/classic/doc/subrules.html

There's a long history in there and in fact, this predates fusion and
also became a motivation for fusion. Why is it not a full fledged citizen
in Spirit2 yet? That's another long story. I'll keep this short for now.

Regards,
-- 
Joel de Guzman
http://www.boostpro.com
http://boost-spirit.com




------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf