Re: spirit grammar graphs
Gordon Woodhull <[email protected]> Wed, 30 Mar 2011 22:53:44 -0400
| Newsgroups | gmane.comp.parsers.spirit.devel |
|---|---|
| Message-ID | <[email protected]> |
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. Thanks! Gordon ------------------------------------------------------------------------------ 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