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

  • SEARCH
  • Home
  • 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 6894403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:46:42+00:00 2026-05-27T06:46:42+00:00

I have a huge grammar for xml parsing but written a while back in

  • 0

I have a huge grammar for xml parsing but written a while back in pre 2.x boost spirit. I would like slightly more meaningful error messages and so I though of saying:

#include <boost/spirit/core.hpp>
#include <boost/spirit/iterator/multi_pass.hpp>

const char* sourcefile;

typedef const char* base_iteratory_type
typedef boost::spirit::multi_pass<base_iterator_type> forward_iterator_type;
typedef boost::spirit::position_iterator2<forward_iterator_type> pos_iterator_t;

base_iterator_type begin(m_document.c_str());
base_iterator_type end = m_document.c_str() + m_document.size();

forward_iterator_type fwd_begin = boost::spirit::make_multi_pass(begin);
forward_iterator_type fwd_end;

pos_iterator_t pos_begin(fwd_begin, fwd_end, sourcefile);
pos_iterator_t pos_end;

try{
parse(pos_begin, pos_end, document_p);
}
catch(const boost::spirit::qi::expectation_failure<pos_iterator_t>& e)
{
//retrieve info from e.first.get_position of type file_position_base;
}

This, however, is not compiling with error on the line which catches the exception and complaining expected unqualified-id before :: token… Can i pull this off in pre 2.x spirit? the so-called “classic” interface? If so, what modifications would this need?

  • 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-27T06:46:42+00:00Added an answer on May 27, 2026 at 6:46 am

    AFAICT the expectation_failure class didn’t exist in classic Spirit:

    • http://www.boost.org/doc/libs/1_41_0/libs/spirit/classic/doc/error_handling.html

    You will want to look at explcitily specified parse_error, like in the error_handling.cpp sample from boost 1.41.

    Also, in case anyone wants to spend some more time working on the above example, here’s a modified version that actually compiles (modulo the broken exception handling):

    #include <boost/spirit/include/classic_core.hpp>
    #include <boost/spirit/include/classic_multi_pass.hpp>
    #include <boost/spirit/include/classic_position_iterator.hpp>
    
    typedef const char* base_iterator_type;
    typedef boost::spirit::classic::multi_pass<base_iterator_type> forward_iterator_type;
    typedef boost::spirit::classic::position_iterator2<forward_iterator_type> pos_iterator_t;
    
    int main()
    {
        const char* sourcefile;
    
    
        std::string m_document;
        base_iterator_type begin(m_document.c_str());
        base_iterator_type end = m_document.c_str() + m_document.size();
    
        forward_iterator_type fwd_begin = boost::spirit::classic::make_multi_pass(begin);
        forward_iterator_type fwd_end;
    
        pos_iterator_t pos_begin(fwd_begin, fwd_end, sourcefile);
        pos_iterator_t pos_end;
    
        try{
            parse(pos_begin, pos_end, boost::spirit::classic::real_p);
        }
        catch(...) {}
        //catch(const boost::spirit::classic::expectation_failure<pos_iterator_t>& e)
        //{
            ////retrieve info from e.first.get_position of type file_position_base;
        //}
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have huge table with 1 million records, i would like to modify some
I have a huge dictionary of blank values in a variable called current like
I have a huge grammar developed for pyparsing as part of a large, pure
I have a huge XML file (114 KB/1719 lines; see the error message below
We have huge stack of xml files (around 5000+ files) possibly about 80 MB
I want to have huge background images on my site but without giving the
Sorry for maybe dumb question, but i have HUGE problem with one case when
I have huge dataframe like this: SN = c(1:100, 1:100, 1:100, 1:100) class =
I have huge 3D arrays of numbers in my .NET application. I need to
I have huge number of Word files I need to merge (join) into one

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.