
"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):
using namespace boost::spirit;
struct identifier_parser: public sub_grammar< identifier_parser > { public: typedef sequence_t < alternative< alpha_parser, chlit<> >, kleene_alternative_t< alnum_parser, chlit<> >::type >::type start_t; public: start_t start; public: inline identifier_parser(): start ( ( alpha_p | '_' ) >> *( alnum_p | '_' ) ) { } } identifier;
NOTE: This is using various type construction helpers.
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. Regards, Arkadiy