rpn functions

I am developing an interpreter and thought it would be a good idea to evaluate expressions with a shunting yard algorithm and rpn calculator but I am not sure how I would do functions. Does anyone have any ideas?
well, a function is basically the sum of all its operations, so that's a starting point. Perhaps the interpreter should ignore the function declarations and process them each time they are called? What kind of interpreting are you doing? You will still need a way to direct the flow to the appropriate function tho, it really doesn't make sense to insert the full function each time in the code, only to process it multiple times.
You could build an abstract syntax tree.
Consider this:
* A function contains a code block.
* A code block contains a vector of statements that are executed in succession.
* A statement can be: an expression; an if, which can contain one or two code blocks; a loop, which contains a code block; or a code block.
* An expression is made up of: a literal; a symbol; an operator with its operand/s, which are also expressions; or a function call with arguments, which are expressions.
Topic archived. No new replies allowed.