mirror of
https://github.com/Ed94/LangStudies.git
synced 2024-11-13 21:54:52 -08:00
2.7 KiB
2.7 KiB
Pipeline
Interpretation Involves RUNTIME SEMANTICS
THE MEANING OF THE PROGRAM MODEL
Compliation delegates semantics of runtime behavior to a TARGET language
Interpetation deals with the semantics itself.
Types of Interpreter implementation:
- AST-based (recursive)
- Bytecode (Virtual Machines)
Types of Compiler implementation:
- Ahead-of-time (AOT)
- Just-in-time (JIT)
Interpeter-AST:
Translation Stage:
- Program Model
- Lexer: Processing into token elements for a parser.
- Output : Tokens
- Parser: Syntactic Analysis
- Output : Abstract Syntax Tree (AST)
Runtime Stage: 4. Interpeter 5. Runtime Behavior
Interpreter-Bytecode:
Translation Stage:
- Program Model
- Lexer: Processing into token elements for a parser.
- Output : Tokens
- Parser: Syntactic Analysis
- Output : Abstract Syntax Tree (AST)
- Bytecode Emitter
- Bytecode instructions primed.
Runtime Stage: 6. Interpreter 7. Runtime Behavior
Types of Virtual Machine behavior:
- Stack based
- Stack for operands and operators
- Result is always on top of stack
- Register based
- Virtual registers
- Result in accumulation register
- Map to real via register allocation
Compiler Ahead-of-Time:
- Program Model
- Lexer: Processing into token elements for a parser.
- Output : Tokens
- Parser: Syntactic Analysis
- Output : Abstract Syntax Tree (AST)
- Code Generator
- Intermediate representation primed
- Target machine instruction set code generation
- Target machine is intended interpretation platform.
- Runtime Behavior.
Compiler with LLVM platform:
- Program Model
- Lexer: Processing into token elements for a parser.
- Output : Tokens
- Parser: Syntactic Analysis
- Output : Abstract Syntax Tree (AST)
- LLVM IR generator
- LLVM Native code generator
- Target machine is intended interpretation platform
- Runtime Behavior.
Lexer, and parser are considered FRONT-END.
Code Generation or byte-code gen or interpreter ast impelementation gen
for target instruction platform is considered BACK-END.
Jit Compiler:
- Program Model
- Lexer: Processing into token elements for a parser.
- Output : Tokens
- Parser: Syntactic Analysis
- Output : Abstract Syntax Tree (AST)
- Bytecode Emitter
- Bytecode fed to interpeter
- Interetor may code gen immediately to target hardware platform or interpret ast directly.
- Runtime Behavior.
Transpiler:
- Program Model in input langauge
- Lexer: Processing into token elements for a parser.
- Output : Tokens
- Parser: Syntactic Analysis
- Output : Abstract Syntax Tree (AST)
- AST Transformation to target AST
- Code generation
- Program Model in output langauge