Interpreters
Introduction / Definition
An interpreter executes a program representation by evaluating it according to language rules. The representation may be source code, bytecode, or an AST. Interpreters are common in scripting runtimes. Modern runtimes may combine interpretation with compilation.
Syntax / Structure / Formula
source → parse → AST/bytecode → execute
Detailed Explanation
A simple interpreter walks an AST and evaluates each node. Variables, operators, calls, and control constructs each have evaluation rules.
Example
Example: An expression interpreter evaluates (2+3)\*4.
Output / Result
The interpreter returns 20.
Important Points / Notes
- Execution follows language semantics.
- JIT compilation may be combined with interpretation.
Mini Practice Question
What can an interpreter execute after parsing?