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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:59:11+00:00 2026-05-18T02:59:11+00:00

I’m trying to write an MSBuild condition parser. The conditions are described here .

  • 0

I’m trying to write an MSBuild condition parser. The conditions are described here.

So I’ve come up with a grammar that appears to work fine:

S -> !S
S -> S == S
S -> S != S
S -> S && S
S -> S || S
S -> Fn( str )
S -> str == str
S -> str != str 
S -> n < n
S -> n <= n
S -> n > n
S -> n >= n

This seems to fit my needs and I’ve come up with a set of C++ classes that define this simple language. ie I can create the classes such that they fit above and then I can call “run” on the base statement and I get a boolean value out of the other end.

Using this language the following:

(!Exists( "C:\\config.sys" ) && 14 < 17) || (AString == AString2 && HasTrailingSlash( "C:" ))

becomes defined as (And forgive the huge line of code! ;)):

Statement baseStatement( new StatementOrStatement( new StatementAndStatement( new NotStatement( new ExistsFunctionStatement( "C:\\Config.sys" ) ), new NumberLessThanNumberStatement( 14.0, 17.0 ) ), new StatementAndStatement( new StringEqualStringStatement( "AString", "AString2" ), new HasTrailingSlashFunctionStatement( "C:\\" ) ) ) );

I can simply run the above statement as follows:

const bool result = baseStatement.Run();

So thus far all is fine. It seems I can represent the whole “language” using my grammar and i can build the grammar into a valid full statement.

However now I have the next problem. I need to actually parse the string. I have no idea of where to start on this. Can anyone help me on how I write the actual string parser to parse the original statement into the set of C++ classes above? I’m rather lost on this front.

I’m doing this purely for my own learning reasons so as far as possible I don’t want to use someone else’s parser library.

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-05-18T02:59:12+00:00Added an answer on May 18, 2026 at 2:59 am

    There are quite a few relevant questions already

    What's the best way to write a parser by hand?

    Resources for writing a recursive descent parser by hand

    How to write a recursive descent parser from scratch?

    https://stackoverflow.com/questions/2405623/looking-for-a-tutorial-on-recursive-descent-parsing

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

Sidebar

Related Questions

No related questions found

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.