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 6798609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:45:03+00:00 2026-05-26T18:45:03+00:00

I am (too) often confronted with the task of having to parse textual data

  • 0

I am (too) often confronted with the task of having to parse textual data files — the kind of textual structured data representation you used before “everyone” used XML — that are some kind of industry standard. (There are too many of these.)

Anyways, the basic task is always taking a text file and stuffing what’s in there in some kind of datastructure so that our C++ code can do something with the info.

Now, I have implemented a few simple (and oh so buggy) parsers by hand, and there is little I despise more. 🙂

So – I was wondering what the current state of the art is when I want to “parse” structured textual data into a in-memory representation (think: XML data binding for an arbitrary language).

What I found so far was “What parser generator do you recommend“, but I’m not so sure I’m after a parser generator (like ANTLR).

Obvious candidates seem to be pegtl and Boost.Spirit but they both seem rather complicated (but at least they’re in-language) and last time I tried Spirit, the compiler errors drove me nuts. (And pegtl needs a C++11 compatible compiler which is still a problem here (VC++ 2005).)

So am I missing a simpler solution for just getting something like

/begin COMPU_METHOD
  DEC "  Decimal value"
  RAT_FUNC
  "%3.0"
  "dec"
  COEFFS 0 1.000000 0.000000 0 0.000000 1.000000
/end COMPU_METHOD

into a C++ datastructure? (This is just an arbitrary example of how part of such a file may look. For this format I could (and probably should) buy a library to parse it, as it is widespread enough — which is not the case for all formats I encounter.)

— or should I just go for the complexity of, say Boost.Spirit?

  • 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-26T18:45:04+00:00Added an answer on May 26, 2026 at 6:45 pm
    • Boost Spirit

      See

      • my answer here for a demo that resembles your sample;
      • a more advanced, shorter demo here that parses into a tree structure
      • more samples search
    • Coco/R (C++)

      I have had good results with this very pragmatic parser generator that supports many lnaguages/platforms using a common grammar format. The speed of parsing is comparable to Boost Spirit (allthough the processing of parsed data may be more efficient using generic programming)

    Edit To make things perfectly clear, there never has been a thing that I wasn’t able to do with Coco/R.

    However, I’m really addicted to the ease with which Spirit deduces attribute type (conversions) for me generically. That is the main timesaver. There is a cost involved though:

    • learning curve, maintenance
    • compile time (but parsers don’t often change)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All too often I find myself storing object data in hidden dom elements. I
All too often I want a WPF slider that behaves like the System.Windows.Forms.TrackBar of
I'm a VMware user and far too often I use keyboard shortcuts while programming.
I tend to take the academic approach all too often and adhere to strict
I am finding myself doing the following a bit too often: attr = getattr(obj,
I've learned the basic/intermediate levels of VIM (it's too vast to list). I often
Not too practical maybe, but still interesting. Having some abstract question on matrix multiplication
I have read about this and people ask this a bit too often. lets
Too often I find myself including a list of options in a view model,
Often I test a function or click too often on an key on my

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.