Boost logo

Boost :

From: Larry Evans (cppljevans_at_[hidden])
Date: 2005-11-01 09:42:39


On 10/30/2005 09:27 PM, Larry Evans wrote:
> On 10/23/2005 01:08 PM, Larry Evans wrote:
[snip]
>
> There's now a proto_static_disp.zip containing code and it's output for

I should have said where. It's in http://boost-consulting.com/vault
in "Template Metaprogramming" directory.

I also should have said it uses a modifcation of the
range/iterator_range.hpp that's here:

http://cvs.sourceforge.net/viewcvs.py/boost-sandbox/boost-sandbox/boost/

> two inputs:
>
> ident
> ident * ident
>
> The code avoids any dynamic dispatching by using the "Curiously
> Recurring Template Pattern" (See Abrahams and Gurtovoy's _C++ Template
i.e. CRTP
> Metaprogramming_, section 9.8) in Grammar template.

It uses the mpl::map where keys are non-terminals and values are rhs for
those non-terminals. It then uses mpl::fold to create a grammar
class with a parser_production superclass for each non-terminal.
The only place the CRTP is actually useful is where the a non-terminal
is encountered on the rhs of the production. This is in:

   struct
parser_rhs
   < vocabulary<nonterminal>::variable<WordId>
   , Grammar
>
{...};

Any comments or suggestions welcome.

Since spirit also uses CRTP, I'm guessing it uses
it for another purpose, i.e. a purpose other than
eliminating the need for virtual functions.

Anyone got a simple answer?

Since this topic seems more relevant to spirit, I'm
posting there also.

TIA.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk