Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6604171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:07:07+00:00 2026-05-25T19:07:07+00:00

I am using Boost 1.44, The Spirit parser works well for numeric parsing but

  • 0

I am using Boost 1.44, The Spirit parser works well for numeric parsing but really is tricky for string parsing. I am trying to parse a string to be split using multiple delimiters: ‘,’ ,’;’ or ‘ ‘. It works well for numbers when I do this (where vect = vector < double >):

qi::parse(first,last,double_ >> *(',' >> double_  | ' ' >> double_ | ';' >> double_),

vect,space);

However when I modify the grammer for strings using vect = vector< string >,

+char_ >> *(',' >> +char_  | ' ' >> +char_ | ';' >> +char_)

I get the following error:

/usr/include/boost/spirit/home/qi/detail/assign_to.hpp:109:13: error: invalid conversion from ‘char’ to ‘const char*’/usr/include/boost/spirit/home/qi/detail/assign_to.hpp:109:13: error:   initializing argument 1 of ‘std::basic_string<_CharT, _Traits,_Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]’

I narrowed down the error to being the first +char_ in the grammar syntax which is being taken as a series of chars rather than a string. Is there any way to fix this issue?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:07:08+00:00Added an answer on May 25, 2026 at 7:07 pm

    String handling (the way you do it) got a lot easier with more recent versions of Spirit. I’d suggest to use Spirit from Boost V1.47, which got a major rewrite of the attribute handling code.

    But even if it compiled the way you want, it wouldn’t parse the way you expect. Spirit is inherently greedy, that means that +char_ will consume whatever is left in your input unconditionally. It seems to be better to have

    +~char_(", ;") % char_(", ;")
    

    i.e. one or more (+) characters which are not (~) in the set ", ;" interpersed with exactly one of those characters. The list parser (%) exposes a vector<A>, where A is the attribute of the left hand expression, a vector<string> in the case above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to parse JSON string using Boost Spirit store JSON object into recursive
I am using Boost Spirit parser, and as the parser is parsing, semantic actions
I'm new to Boost Spirit and trying to write JSON parser using Boost Spirit
I'm trying to get a handle on using boost::spirit to parse character tokens, and
Recently, I try to use the boost::spirit::qi binary endian parser to parse some binary
I want to parse a file into an AST using Boost Spirit. The root
I have been successfully using boost::spirit::qi to to parse a stream consisting of the
I'm using Boost Spirit to parse source files in a little compiler project. If
I'm trying to compile a simple grammar using Boost.Spirit. I'm using g++ 4.7.0 and
I'm trying to learn Boost Spirit and as an exercise, I've tried to parse

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.