How to write an interpreter?