Library Expression parsing

Discussion in 'Resources' started by MCMastery, Jul 12, 2016.

Thread Status:
Not open for further replies.
  1. Offline


    Hi. I was bored, so I made an expression parser in Java, for evaluating Strings like "sin(3+4*2/(1-5)^2^3)" as mathematical expressions.

    String exp = "sin(3+4*2/(1-5)^2^3)";
    ExpressionParser parser = new ExpressionParser(exp);
    This uses the Shunting Yard Algorithm (


    You could use this for user-given calculations.

    Probably not that useful, but I've seen many questions about how to evaluate expressions in Java elsewhere.

    Thanks for reading ,_,
    Last edited: Jul 12, 2016
  2. Offline

    I Al Istannen

    Looks nice! And a lot better than the recursive one I made some time ago :p
    And better than anything I could come up with :)

    Still wonder why people name Interfaces "Ixxx" though. Any special reason? Shouldn't an IDE format them accordingly?

    Maybe not that useful, I rarely found the need to evaluate an expression myself (and you could use the Rhino engine. If you want to backstab performance and security... Critical.), but I still find it useful to see how other, better, people solve this problem.

    Will try to recreate this, and then compare it to yours. And then probably change it by a ton, to closer resemble what you did :p

    So thank you, random person from the internet ;)
    MCMastery likes this.
  3. Offline


    I just called it "Ixxx" so I could have IFunction and the Function enum :p

    Thanks for the reply lol
  4. Offline


    aw man i was working on this but you beat me.
    I know why you are doing this ^w^
    Message me so we can do more work!
    @MCMastery I might not be on as much as expected- Im on a hotel computer :p
    Last edited: Jul 12, 2016
    MCMastery likes this.
Thread Status:
Not open for further replies.

Share This Page