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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:58:22+00:00 2026-06-02T14:58:22+00:00

I’m coding a project in C++, and I’m looking for a way to put

  • 0

I’m coding a project in C++, and I’m looking for a way to put in a text file ( usergrammar.txt ), in a humanly readable/writable form, a user-defined grammar which defines objects.

Once done this I’d like to be able to instance some of those objects in the code, and save the created instances in another file ( instances.txt ), always in humanly accessible format. This second file is obviously dependent on the first to be read correctly.

What I’m having trouble with is how to define the grammars and parsing them. I’ve been looking at Boost::Spirit, but while it would do a good job on reading the first file ( since its rules are predefined ), I don’t think it is applicable to the second one since Spirit grammars are only defined a compile time and cannot be loaded at runtime ( at least that’s what I understood ).

Now I’m reading about the ENBF form, but I also have the problem that I not only have the language rules, but that each object has a particular and different name/description/options every time its included in another one ( For example, if I have the object colour, the integers inside it would be called red, blue, yello, while if the object is ruler, its integer would be called length ), so I have a way to include these informations into the file as well, and getting them to be associated with the corrisponding values correctly.

Do you have any pointers to what to look/study/use/do for a project like this?
Thanks in advance.

  • 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-06-02T14:58:23+00:00Added an answer on June 2, 2026 at 2:58 pm

    If you are open to having some restrictions on the format of your files, you could look into using XML or JSON to describe your grammars.

    You could have a grammar file that looks like

    {
        "ObjectTypes" : {
            "ruler" : { "properties" : [ "length" ] },
            "color" : { "properties" : [ "red", "green", "blue" ] }
        }
    }
    

    After reading in this file (using some pre-existing library, most likely), you could then read in another file that would have your actual objects. It could look something like this:

    {
        "Objects" : [
            { name : "object1", "type" : "ruler", "length" : 5 },
            { name : "object2", "type" : "color", "red" : 5, "blue" : 127, "green" : 150, }
        ]
    }
    

    And so forth. A more descriptive overview of JSON is given here, which includes links to several C++ libraries that handle JSON (My personal favorite is JsonCpp).

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

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I have a reasonable size flat file database of text documents mostly saved in
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I am trying to render a haml file in a javascript response like so:

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.