spirit's functor_parser<functor>

Hi, I'm using a lot of functor parsers and combine them in one grammar. Now, my grammar explodes at the time. Therefore I want to split/compile the functor parsers into separate files. This requires a forward declaration. Well, how to perform this?? spirit::functor_parser<functor> functor_p; is an instance. Thanks, Olaf

at this time, I try to separate the instances of spirit grammars into several files; this mean rewrite the functor parsers to grammars and move the implementation of grammar ctor into an own file. Anyway, this does not compile: --- header--- struct left_bracket_termated_string_parser : spirit::grammar<...> { template <typename ScannerT> struct definition { typedef sp::rule<ScannerT> rule_t; rule_t str; rule_t const& start() const { return str; } definition( const left_bracket_termated_string_parser& self ); }; }; const left_bracket_termated_string_parser sbt_str_p; ---- --- source --- template<> left_bracket_termated_string_parser::definitionsp::scanner::definition( const left_bracket_termated_string_parser& self ) { using namespace ::boost::spirit; using namespace ::phoenix; str = ( *( anychar_p - ch_p( '[' ) ) )[ self.result_ = construct_std::string( arg1, arg2 ) ] ; } ---- The error is: error: type/value mismatch at argument 1 in template parameter list for 'template<class ScannerT> struct left_bracket_termated_string_parser::definition' error: expected a type, got 'scanner' error: 'definition' is not a template function Anyway, does this help t reduce compile time. Thanks, Olaf

Olaf Peter wrote:
Hi,
I'm using a lot of functor parsers and combine them in one grammar. Now, my grammar explodes at the time. Therefore I want to split/compile the functor parsers into separate files. This requires a forward declaration. Well, how to perform this??
spirit::functor_parser<functor> functor_p;
is an instance.
The same ideas mentioned here: http://spirit.sourceforge.net/distrib/spirit_1_8_5/libs/spirit/doc/faq.html#... should help. I.e. Put the function bodies in separate cpp files (possibly using explicitly) instantiation) Anyway, FYI, here's the Spirit user's mailing list: https://lists.sourceforge.net/lists/listinfo/spirit-general Regards, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net

Thanks for answers,
The same ideas mentioned here: http://spirit.sourceforge.net/distrib/spirit_1_8_5/libs/spirit/doc/faq.html#...
should help. I.e. Put the function bodies in separate cpp files (possibly using explicitly) instantiation)
Spirit cpp_lexer example splits the grammar, yes. But all instances are in the same file - not splitted. If I split it I get problems with uncomplete types.
Anyway, FYI, here's the Spirit user's mailing list: https://lists.sourceforge.net/lists/listinfo/spirit-general
Correct, but this problem falls into the category: How to instantiate a template where a complete type is required. It seems, that the specializing, as in my 2nd post, is not correct. Thanks, Olaf
participants (2)
-
Joel de Guzman
-
Olaf Peter