Boost logo

Boost Users :

Subject: [Boost-users] Boost qi parser
From: Uthpal Urubail (uthpal.urubail_at_[hidden])
Date: 2014-02-28 13:12:31


{

    name = "new"

    sub_name = "SUBTITLE"

    values = { 1, 2, 3; }

    input_values = { 1, 2, 3;

5, 5, 6

10, 12, 3}

    type = input

intval = 100

}

Can some one help me to write the parser for the above format?
I am trying something like below and this doesn’t seem to work for me.

template <typename Iterator>

struct keys_and_values

    : qi::grammar<Iterator, mapDef()>

{

    keys_and_values()

        : keys_and_values::base_type(query)

    {

        using namespace qi;

        query = '{' >> *lit(' ') >> pair >> *(lit(' ') >> *lit(' ') >> pair) >> *lit(' ') >> '}';

        pair = key >> -(*lit(' ') >> "=" >> *lit(' ') >> value);

        key = +char_("a-zA-Z0-9_") ;

        value = +char_("a-zA-Z0-9") | lexeme[('{' >> +char_("\"@+*.( , ) $ a-zA-Z0-9_ -") >> '}')] | lexeme[('"' >> +char_("\"@+*.( , ) $ a-zA-Z0-9_ -") >> '"')];

    }

    qi::rule<Iterator, mapDef()> query;

    qi::rule<Iterator, std::pair<std::string, std::string>()> pair;

    qi::rule<Iterator, std::string()> key, value;

};

Any help would be highly appriciated.

Regards,

UJ



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net