How a compiler works

Core Components:

  1. Lexical Analyzer
  2. AST Parser
  3. Interpreter (use visitor pattern to traverse the AST)
  4. Symbol table

AST

context-free grammers

example:
Parsing
7 + 3 * (10 / (12 / (3 + 1) - 1))


context-free grammers to AST:

parsing a programe: