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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:50:44+00:00 2026-05-25T16:50:44+00:00

Soulver is a great scratch pad for math that allows you to write expressions

  • 0

Soulver is a great scratch pad for math that allows you to write expressions in a very natural form, which makes it versatile and fun to use in many occasions. There’s a short video on the site that displays a lot of its functionality.

I’d like to tackle writing a parser that behaved much as that of that app’s. For instance, if you go shopping, you can write a big list like

2 * 1.99 soap + 2.99 cereal + 39.59 organic magic beans 

and see, as you type, the sum of what’s in the line (46.56).

You can also create variables, such as

March = 2 * 1.99 soap + 2.99 cereal + 39.59 organic magic beans 

and reference them in later operations. Other operators, such as ‘off’ (40% off $200), also exist.

Considering it has some level of sophistication and it should distinguish meaningful terms while ignoring some of the input, what sort of grammar should I be using to represent this little language? I could probably cobble some spaghetti regex together, but I’d honestly like to do something a little better, even if it requires a lot of study from my part. What would you recommend?

  • 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-25T16:50:45+00:00Added an answer on May 25, 2026 at 4:50 pm

    A regexp by itself is likely not expressive enough to the job if you want to model real mathematics, e.g., anything with nested parentheses.

    Context-free grammars are remarkably expressive. You should learn about Backus Normal Form (BNF), a means for writing down the description of languages as context-free grammars.
    You can choose from among many parser generator tools, to convert that grammar into a real parser.

    Which specific grammar you write depends on what you want the expressions to mean, and which atoms in the expression really get ignored.
    As a practical matter, the way you write the BNF varies from tool to tool, so choosing your parser generator tool first will save you the trouble of rewriting your BNF later.

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

Sidebar

Related Questions

i'm trying to write a Sudoku solver which will return only the first possible
Visual C++ 2008 has a great tool called Attach to Process, which start watching
I have a homework assignment to write a multi-threaded sudoku solver, which finds all
This great SO answer points to a good sparse solver for Ax=b , but
I'm attempting to write a solver for a particular puzzle. It tries to find
I've recently completed an algorithmic sudoku solver in C, one in which three different
I'm doing a Sudoku solver and for that I want my JTextFields to only
Let's say I want to write a Sudoku solver with some representational abstraction using
I am working on a forms application that reports based on observed data. Prior
im writing a Soulver-like application with html+js. I need to customize text from input(highlight).

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.