|
Boost Users : |
Subject: Re: [Boost-users] [spirit] first steps
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2010-02-18 14:07:07
> > qi::string is not a valid parser primitive. What would you expect it
> to match anyway? You'll have to be a bit more specific about what kind
> of string you need to parse, for instance:
> >
> > '"' >> ~+char_('"') >> '"'
>
> Ok, I see...
> Actually, I have to parse a list of strings, where every line consists
> of numbers and "strings" delimited by ":" -- where "strings" may be
> empty or may contain virtually any character (except for the
> delimeter), like this:
> 1:23:string#1:optional&string_at_2
> 2:34:string#2:optional.string%3
>
> besides, the last "string" in the line may be absent with the
> preceeding delimeter, i.e. both "1:23:string#1:" and "1:23:string#1"
> are valid (of course, "1:23::" is valid too)
>
> Is it possible with Spirit? Would it be the right tool?
Definitely. I'd start looking at the list parser (operator %), Kleene and plus operators (operator*, operator+), the primitive character parsers, and at attribute handling allowing to fill your data structure directly during the parsing. Did you see Spirit's web site (http://boost-spirit.com/)? The examples and tests provided with Spirit are a good source of information as well (in addition to the docs).
HTH
Regards Hartmut
---------------
Meet me at BoostCon
www.boostcon.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