Boost logo

Boost Users :

Subject: [Boost-users] [spirit2] Trivial parser crashes
From: sm4 (sunnyim4_at_[hidden])
Date: 2008-09-23 06:26:44


Hello,

Playing with spirit-2 (boost 1.36 release) I got the following code to
ASSERT when compiled on Visual Studio 2008/SP1.

Any ideas what's wrong?

----------------------------------------------------------

#include
#include
#include
#include
#include
#include
#include

#include
#include

using namespace boost::spirit;
using namespace boost::spirit::qi;
using namespace boost::spirit::ascii;
using namespace boost::spirit::arg_names;

namespace phoenix = boost::phoenix;

using phoenix::at_c;

struct key_val
{
    std::string key;
    std::string value;
};

BOOST_FUSION_ADAPT_STRUCT(
    key_val,
    (std::string, key)
    (std::string, value)
)

template
struct my_grammar : grammar
{
    my_grammar() : my_grammar::base_type(start)
    {
        quoted_string %= lexeme['"' >> +(char_ - '"') >> '"'];
        key %= quoted_string;
        value %= quoted_string;

        start =
                key [at_c<0>(_val) = _1]
>> ':'
>> value [at_c<1>(_val) = _1]
             ;
    }

    rule key;
    rule quoted_string;
    rule value;

    rule start;

};

int main()
{
    typedef std::string::const_iterator citerator;
    std::string str = "\"x\": \"25\" ";

    citerator iter = str.begin();
    citerator end = str.end();

    my_grammar my_parser;
    key_val kv;
    phrase_parse(iter, end, my_parser, kv, space); // ASSERTs

    return 0;
}
--------------------------------------------------------------------------

thanks

-- 
View this message in context: http://www.nabble.com/-spirit2--Trivial-parser-crashes-tp19624910p19624910.html
Sent from the Boost - Users mailing list archive at Nabble.com.



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