“If you don’t know how compilers work, then you don’t know how computers work. If you’re not 100% sure whether you know how compilers work, then you don’t know how they work.” — Steve Yegge

Like a fews week ago I did research about interpreter for some DSL project. However things happened, and I got crashed away from the project.

Tree Walk Interpreter

This approach called Tree-Walking Interpreter, which is the simplest way to make interpreter

  1. Free text/grammar: literally what you type
  2. Lexer/lexical analysis: text to tokens
  3. Tokens/Lexemes: chunks of your syntaxs
  4. Parser: tokens to syntax tree
  5. Syntax Tree/Abstract Syntax Tree or AST: model represented operator with its precedence level and associativity
  6. Evaluator: running through AST and execute the operation.

For whom looking for more resources to start learn on this subject, I recommend to read Ruslan Blog and Writing An Interpreter In Go