Open ghost opened 3 years ago
I think it could be implemented as another parse function, like parse_polish or so. The resulting AST would be the same (as it's elixir AST anyway).
I think it could be implemented as another parse function, like parse_polish or so. The resulting AST would be the same (as it's elixir AST anyway).
Do you like the idea of having this in your library? Or would it be something that would be at application level? Update: I think I am going to create add-on library for fun and call it PolishAbacus or smth like this. It would would have a function that would parse to a syntax tree that could be used with eval etc
I'll gladly accept a PR that adds a second function to parse a different syntax into the same internal representation (the AST). If you need any pointers, feel free to ask. I think writing your own parser is an excellent excercise.
You can probably get away with copying and then modifying this file: https://github.com/narrowtux/abacus/blob/master/src/math_term_parser.yrl
This is in erlangs yecc language: https://erlang.org/doc/man/yecc.html
When it's compiled, a module named :math_term_parser
will be available.
Thanks, I will try it out and send a PR! :)
Supporting Polish Notation would be a cool addition to this library in my opinion. Or a polish notation evaluation library may be a idea for another math library? But I dont know how something like this would be done. Just throwing the idea out here.
https://en.wikipedia.org/wiki/Polish_notation
Thanks for reading my issue!