Hacker News new | ask | show | jobs
by ralphb 1403 days ago
I've found that a super simple way to parse basic expressions is a recursive descent parser. It is very simple to implement. No need to to break into tokenizer/parser, no need to generate an AST, just evaluate the expression while parsing.
1 comments

Do you have an example of a simple parser like that?
https://gist.github.com/revivalizer/935dfcc345b009a0207a033c...

Even includes error handling :)

At the bottom you can see some test examples of what it can do. Obviously it is a basic calculator.