On Friday, 10 June 2016 at 15:03:30 UTC, jmh530 wrote:
Let's say you have something simple like 1+2, you would build an AST that looks something like
   +
  / \
 1   2
What would be the next step?

https://github.com/adamdruppe/arsd/blob/master/script.d#L879

The function is pretty simple: interpret the left hand side (here it is 1, so it yields int(1)), interpret the right hand side (yields int(2)), combine them with the operator ("+") and return the result.

Notice that interpreting the left hand side is a recursive call to the interpret function - it can be arbitrarily complex, and the recursion will go all the way down, then all the way back up to get the value.

Reply via email to