|
Boost : |
From: Joel de Guzman (djowel_at_[hidden])
Date: 2003-03-20 21:00:54
Jon Wray wrote:
> What happened to spirit::rule<>::set_id()? It was in Spirit 1.5.1, but it's
> missing from 1.6.0. The doc still refers to it (see the very bottom of
> http://www.boost.org/libs/spirit/doc/rule.html).
Giovanni Bajo wrote:
> I might be dumb, but I read in the documentation that each rule
> should have a member called set_id() to modify the parser ID. Now,
> looking into the code that method does not exist. Not only that, but
> there is not even a member holding the parser_id, it's just computed
> on the fly through a policy, which means that it is impossible to
> modify at runtime.
No, you are not dumb. This is a documentation oversight.
> The only way I found was:
>
> rule<T, parser_context, parser_tag<AST::ID_INTERFACE> >
> interf;
This is correct. Pardon the oversight. The change was done so as to
have a consistent interface for rules, subrules and grammars. Following
the precept that "the user should not pay for features she does not need",
the member variable was taken out in favor of a static constant. The
additional member variable is not needed in many cases.
> which is quite bloated, especially since I have to do this for many
> many rules. So, where is the missing set_id() member?
In the meantime, this is the way to do it. You can write a simple
metaprogram to ease the typing (pun?). Example:
template <typename ScannerT, in ID>
struct rule_
{
rule<ScannerT, parser_context, parser_tag<ID> > type;
};
Then:
rule_<T, AST::ID_INTERFACE>::type interf;
Sometime in the future, the interface to rules will be made easier
such that the optional template arguments can be passed in
arbitrary sequence.
Hope this helps. Again pardon the oversight.
-- Joel de Guzman joel at boost-consulting.com http://www.boost-consulting.com http://spirit.sf.net
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk