A Simple Interpreter in Python
ruslanspivak.com
ruslanspivak.com
I also recommend people reading this book: it is super complete and comprehensive to get started and get your hands dirty https://monkeylang.org/
Another thing i recommend which is what i ended up doing: instead of interpreting stuff like
def visit_BinaryOperation(self, node): if node.operation == “add”: return node.right + node.left
I just simply add the values inside of an object and then add like
def visit_BinaryOperation(self, node): if node.operation == “add”: return node.right._add_(node.left)
This way i can handle for example what happens if we add a string with a string, or a int with a float INSIDE of the object of this value. So if node.right is an object of type String we handle in the _add_ method in the String class what happens if we add together objects of different types like for example an Int with a String.
But that’s it. It is an awesome recommendation
Do you know if the tutorials strongly depend on Go or can I easily map it to other languages?