RE: [boost] Re: Re: Spirit and typeof [was typeof]

Arkadiy Vertleyb wrote:
"Reece Dunn" <msclrhd@hotmail.com> wrote
One question though: I have a parser where I have created several external grammars to help modularize the grammar and employ the trick suggested in the techniques section (c.f. sub-grammar):
[snip] Once you have a (sub-)rule like this, you can use it like:
rule_t<ScannerT> tagName = !( identifier >> ':' ) >> identifier;
I was wondering if this would cause any major problems when implemented with the typeof/auto hack (since it could then be implemented as a grammar).
I think you would just have to register your identifier_parser class. The typeof system then would treat it as an atom and not care what is behind it.
This was what I was thinking. But is there a way of handling the grammar template as a special case, e.g.: template< typename T > class deduce_type { typedef ... type; }; template< typename DerivedT > class deduce_type< boost::spirit::grammar< DerivedT > > { typedef DerivedT::type type; }; I am not saying that this is what it will look like as I am not up to speed with your typeof mechanism, but if something similar could be implemented, it would make custom grammars more powerful (may even reduce the number of types that need explicit registration). Regards, Reece _________________________________________________________________ Tired of 56k? Get a FREE BT Broadband connection http://www.msn.co.uk/specials/btbroadband

"Reece Dunn" <msclrhd@hotmail.com> wrote
This was what I was thinking. But is there a way of handling the grammar template as a special case, e.g.:
template< typename T > class deduce_type { typedef ... type; };
template< typename DerivedT > class deduce_type< boost::spirit::grammar< DerivedT > > { typedef DerivedT::type type; };
I am not saying that this is what it will look like as I am not up to speed with your typeof mechanism, but if something similar could be implemented, it would make custom grammars more powerful (may even reduce the number of types that need explicit registration).
Hmmm, I am afraid this might not be possible... Once your DerivedT is present anywhere in the template tree, the typeof mechanism needs to know about it in order to be able to encode/decode it. This applies to any type or template. The library-defined types/templates can (and should) be registered by the library, but once a user defines a new type, it has to be registered too, by the user. Regards, Arkadiy
participants (2)
-
Arkadiy Vertleyb
-
Reece Dunn