Making A Compiler: Difference between revisions
Jump to navigation
Jump to search
Line 9: | Line 9: | ||
*Decide what AST should look like | *Decide what AST should look like | ||
*Create Nodes | *Create Nodes | ||
=Parsing Context= | |||
We made a context to store | |||
* type e.g. integers | |||
* variables e.g. a, b | |||
==Types== | |||
This is the storing of which types would be valid in our code | |||
==Variables== | |||
This is the storing of which variable are in our code. Against each variable we store which type and which variable e.g. '''a : integer = 69''' | |||
=Things I learnt= | =Things I learnt= | ||
==Abstract Syntax Tree== | ==Abstract Syntax Tree== |
Revision as of 00:33, 28 September 2024
Introduction
This page is how someone went about build a compiler and is here for reference
Steps
- Write example file
- Read contents of file
- Parse Lines
- Parse Tokens in
- Decide on Node Types
- Decide what AST should look like
- Create Nodes
Parsing Context
We made a context to store
- type e.g. integers
- variables e.g. a, b
Types
This is the storing of which types would be valid in our code
Variables
This is the storing of which variable are in our code. Against each variable we store which type and which variable e.g. a : integer = 69
Things I learnt
Abstract Syntax Tree
Continuation vs Recursion
Typical Flow Control
- Jump goto, while, functions
- Conditional (if/then/else)
- Early Exit (break, continue, skip)
- Exception handling (try/throw/catch)
- Lazy evaluation (delay/force)
- Threading (thread create,stop, yield)
- Generator (yield)