I'm trying to debug a boost::spirit grammar that I want to use in a Visual Studio project: This is my code snippet:
#include <boost/spirit/include/classic.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
// This is pasted and copied from another header file
namespace StateMachine {
namespace Private {
struct LuaParameterData {
std::wstring name;
std::wstring type;
std::wstring unit;
std::wstring cardinality;
std::wstring value;
};
} // namespace Private
} // namespace StateMachine
BOOST_FUSION_ADAPT_STRUCT(
StateMachine::Private::LuaParameterData,
(std::wstring, name)
(std::wstring, type)
(std::wstring, unit)
(std::wstring, cardinality)
(std::wstring, value)
)
// From here original file continues
namespace StateMachine {
namespace Private {
namespace qi = boost::spirit::qi;
template<typename Iterator>
struct LuaParameterDataParser : qi::grammar<Iterator, LuaParameterData(), qi::ascii::space_type>
{
LuaParameterDataParser() : LuaParameterDataParser::base_type(start)
{
quotedString %= qi::lexeme['"' >> +(qi::ascii::char_ - '"') >> '"'];
start %=
qi::lit("\"parameter\"")
>> ':'
>> '{'
>> qi::lit("\"name\"" ) >> ':' >> quotedString >> ','
>> qi::lit("\"type\"" ) >> ':' >> quotedString >> ','
>> qi::lit("\"unit\"" ) >> ':' >> quotedString >> ','
>> qi::lit("\"cardinality\"") >> ':' >> quotedString >> ','
>> qi::lit("\"value\"" ) >> ':' >> quotedString
>> '}'
;
}
qi::rule<Iterator, std::string(), qi::ascii::space_type> quotedString;
qi::rule<Iterator, LuaParameterData(), qi::ascii::space_type> start;
};
} // namespace Private
} // namespace StateMachine
BOOST_SPIRIT_DEBUG_RULE(StateMachine::Private::LuaParameterDataParser<std::string::const_iterator>::quotedString);
The macro BOOST_SPIRIT_DEBUG
is defined in project properties.
When I compile it I obtain following errors in the last line where I use BOOST_SPIRIT_DEBUG_RULE
:
error C3484: syntax error: expected '->' before the return type
error C2061: syntax error : identifier 'register_node'
I don't know if I'm doing the right thing. I want to debug my grammar, but I've seen only hints for debugging rules (here and here) so I've tried to adapt my code.
What I'm doing wrong and what I must do in order to print debugging information when I use this grammar with phrase_parse
?