struct usmtf : public grammar<usmtf> { template <typename ScannerT> struct definition { definition(usmtf const& self) { message = mainText; exerciseSet = !eol_p >> str_p("EXER")[do_print("EXER")]
ch_p('/') >> *(field >> ch_p('/')) >> ch_p('/'); messageIdentifierSet = str_p("MSGID")[do_print("MSGID")] ch_p('/') >> *(field >> ch_p('/')) >> ch_p('/');
field = lexeme_d [ +(upper_p - ch_p('/') - eol_p) ]; mainText = exerciseSet >> eol_p >> messageIdentifierSet
end_p; };
rule<ScannerT> message, mainText, exerciseSet, messageIdentifierSet, field; rule<ScannerT> const& start() const { return message; } }; }; Using this grammar above, it will parse EXER/EE/FF//MSGID// using mainText = exerciseSet >> messageIdentifierSet >> end_p; However, I want it to parse EXER/EE/FF// MSGID// and mainText = exerciseSet >> eol_p >> messageIdentifierSet >> end_p; does not work. Why? How do I parse what I want?
I wouldn't know unless I see the whole picture. Which parse function did you call?
Have you tried using the Spirit debugger?
BTW, please post Spirit related questions to Spirit's mailing list:
Spirit-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spirit-general
Thanks!
Cheers,
--
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net
jwwillcox2003
struct usmtf : public grammar<usmtf> { template <typename ScannerT>
struct definition { definition(usmtf const& self) { message = mainText;
exerciseSet = !eol_p >> str_p("EXER")[do_print("EXER")]
ch_p('/') >> *(field >> ch_p('/')) >> ch_p('/'); messageIdentifierSet = str_p("MSGID")[do_print("MSGID")] ch_p('/') >> *(field >> ch_p('/')) >> ch_p('/');
field = lexeme_d [ +(upper_p - ch_p('/') - eol_p) ];
mainText = exerciseSet >> eol_p >> messageIdentifierSet
end_p; };
rule<ScannerT> message, mainText, exerciseSet, messageIdentifierSet, field;
rule<ScannerT> const& start() const { return message; } }; };
Using this grammar above, it will parse EXER/EE/FF//MSGID// using mainText = exerciseSet >> messageIdentifierSet >> end_p;
However, I want it to parse EXER/EE/FF// MSGID//
and mainText = exerciseSet >> eol_p >> messageIdentifierSet >> end_p; does not work. Why? How do I parse what I want?
participants (2)
-
Joel de Guzman
-
jwwillcox2003