0

I am learning erlang recently and I have a question.

I have an equation like this (~(2+1)). I want to parse to polish notation? For eg.{unaryMin{add,2,1}}

How do I start?

FireNewbie
  • 123
  • 2
  • 12

1 Answers1

1

If you want to parse something, from a simple formula to a programming language, you should start by learning about grammar, language and Compiler-compiler. Learning how to parse and translate/interpret something to another format is a very common task for any programmer (pretty much everything has a compiler/interpreter, even you image viewer, web browser, etc ...) so it's very important to learn about those things.

For Erlang, LYSE got a chapter about making a reverse-polish notation calculator here, and for converting from an infix equation to a prefix/postfix one, you should read about Shunt-Yard algorithm. Erlang also have is own version of yacc & lex : yecc, leex.

Maeln
  • 370
  • 1
  • 21