#How to parse functions with multiple parameters using shunting yard
8 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
when you see the function name, push to the operator stack and similarly the following left parentheses.
When the number is encountered push it to the ouput queue.
When you see a comma pop the operator stack and into the ouput queue as long as the top operator is not a left paren.
And then when you finally get a right parentheses again pop the operator stack into the queue until you get a left parenthese on top of the stack, finally remove that left paren alongwith the function on top.
So the ouput queue looks like
2 16 log
Also post in the #algorithms-and-compsci instead
In computer science, the shunting yard algorithm is a method for parsing arithmetical or logical expressions, or a combination of both, specified in infix notation. It can produce either a postfix notation string, also known as reverse Polish notation (RPN), or an abstract syntax tree (AST). The algorithm was invented by Edsger Dijkstra, first p...

ok
However if the functions have differing arity (number of arguments they take) then you need a way to track how many argument a specific function takes. For example log takes 2 and sin takes 1, then you need to store this somewhere so at the time of evaluating you can pass the correct number of arguments to the function being evaluated.