Boost logo

Boost :

From: Larry Evans (cppljevans_at_[hidden])
Date: 2005-10-23 13:08:29

On 10/23/2005 12:12 PM, Korcan Hussein wrote:
>>I'm quite interested if you have a better alternative. For example,
>>how do you write the Spirit calculator using your scheme:
>> rule<> group, factor, term, expression;
>> group = '(' >> expression >> ')';
>> factor = integer | group;
>> term = factor >> *(('*' >> factor) | ('/' >> factor));
>> expression = term >> *(('+' >> term) | ('-' >> term));
> I'll get back to you on that one, for the time being i have uploaded the
> example i have been writing about, it is in the vault here:
> In the example program you should see something similar, take note however
> this isn't a library in any form it is just a (very) rough example of the
> technique, it has (as of yet) not been fully generalized but it should not
> be to diffcult. It should be enough to give people an idea to discuss about
> and consider a possibility.

Hopefully, the file:


will also generate some ideas. AFAICT, the arith_expr_gram typedef
in that file contains all the grammar (which is recursive) and
*maybe* could be further developed to eliminate dynamic dispatching.
Of course, I've only compiled it and not yet tried to parse anything
with it. It's also not readable, but I'm thinking that maybe
the proposed typeof and << and | and spirit operators could be used to
replace the 2nd part of the mpl::pair's in the mpl::map.

Boost list run by bdawes at, gregod at, cpdaniel at, john at