Parsing escaped strings with boost spirit

Я работаю с Spirit 2.4 и хочу проанализировать такую ​​структуру:

Text {text_field};

Дело в том, что в text_field есть экранированная строка с символами '{', '}' и '\'. I would like to create a parser for this using qi. I've been trying this:

using boost::spirit::standard::char_;
using boost::spirit::standard::string;
using qi::lexeme;
using qi::lit;

qi::rule< IteratorT, std::string(), ascii::space_type > text;
qi::rule< IteratorT, std::string(), ascii::space_type > content;
qi::rule< IteratorT, std::string(), ascii::space_type > escChar;


text %= 
  lit( "Text" ) >> '{' >>
    content >>
  "};"
  ;

content %= lexeme[ +( +(char_ - ( lit( '\\' ) | '}' ) )  >> escChar ) ];

escChar %= string( "\\\\" ) 
  | string( "\\{" ) 
  | string( "\\}" );

But doesn't even compile. Any idea?

5
задан Bruno 26 October 2010 в 21:26
поделиться