Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-01-17 14:49:28


On Thursday 17 January 2002 02:00 pm, you wrote:
> I think people are arguing is that the CLA parser should use
> Spirit to provide flexibility and reduce programmer burden. The
> interfaces to the programmer are yet-to-be determined. I think
> one of them should expose a (possibly limited) Spirit interface.

I disagree strongly with this. Exposing Spirit in the interface forces the
underlying implementation to use Spirit. Instead, I would strongly suggest
defining a Parser concept that can facilitate any type of parser, so that
Spirit and the CLA parser interfaces are decoupled. Perhaps the CLA interface
would allow a custom parser to be added as such:

  template<typename Parser>
  void add_custom_parser(const Parser& parser);

The Parser concept could be (loosly) defined by one valid expression:

  parser(i, j): [i, j) is an input iterator sequence that is to be parsed by
the parser. The return value could include the position at which parsing
should resume to parse other arguments, and perhaps some value that describes
the argument/value parsed in a manner that is common within the CLA parser.

It is very easy to add a Spirit rule as an argument parser:

  rule<> my_arg_parser;
  cla.add_custom_parser(
    boost::bind<R>(&rule<>::parse, &my_arg_parser, _1, _2));

This does not prevent nor force the use of Spirit to implement the CLA parser.

        Doug


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