Strategies of Evaluation
Evaluation is where interpreter implementations diverge the
most.There are a lot of different strategies to choose from when
evaluating source code.so looking at different options is
worthwhile.
Before we start, though, it's also worthy noting again that
the line between interpreter and compiler is a blurry one.
tree-walking interpreter
the most obvious and classical choice of what to do with the AST is
to just interpret it. Traverse the AST,visit each node and do what the
node signifies: print a string,add two number, execute a function's
body.Sometimes their evaluation is preceded by small optimization that
rewrite the AST(e.g. remove unused variable bindings) or convert it into
another intermediate representation(IR)
that's more
suitable for recursive and repeated evaluation.