In C ++, the final parser is Boost.Qi
#include <boost/spirit/include/qi.hpp> #include <string> namespace qi = boost::spirit::qi; int main() { int level, relative; float x, y, angle, length, minAngle, maxAngle; std::string name, parentName; std::string input = "20 1.3 3.7 1.234 100.0 0.0 3.14 2 \"Foo\" \"Bar\""; std::string::iterator begin = input.begin(); std::string::iterator end = input.end(); using qi::int_; using qi::float_; using qi::char_; using qi::lit; using qi::ascii::space; qi::phrase_parse(begin, end, int_ >> float_ >> float_ >> float_ >> float_ >> float_ >> float_ >> int_ >> lit("\"") >> *(~char_('"')) >> lit("\"") >> lit("\"") >> *(~char_('"')) >> lit("\""), space, level, x, y, angle, length, minAngle, maxAngle, relative, name, parentName); }
source share