Share your repls and programming experiences

← Back to all posts
Math Parser
DynamicSquid (4622)

So in my journey to develop my own language, I've created a simple lexer (definitely check that out), and that's about it. But now (well, this morning actually), I made a math parser (with the help of @ChezCoder)! Think of it like a calculator.

It supports:

  • addition
  • subtraction
  • multiplication
  • division
  • 1 pair of brackets (2+ pairs will break it)

So as input, enter one digit (the real parser supports 2+ digit numbers, but this is just a showcase) followed by an operation. Make sure it's correct! For example:

Sample inputs:

5 + 3 - 9 * 2
5 * 4 - 1
(3 + 2) / 6
(3 + 2) * (1 - 4) // WRONG! 2+ pairs of brackets will break it

Just like that!

Well, the next step is to put everything together, and hopefully I can get it done by next week?

Enjoy :)