Compilation process - metzzo/123-basic GitHub Wiki

Architecture

The 123basic is a self hosting multi pass compile on demand compiler.

The compiler architecture of 123 basic is very simple:

  1. Lexer/Tokenizer: Splits the source code into small "tokens"
  2. Preprocessor: Parses all the preprocessor commands (with "?" prefix)
  3. Analyser: Searches for all variables/functions and types
  4. Parser: Transforms the tokens into an abstract syntax tree(AST), checks for errors
  5. Generator: Generates the code for the target language out of the AST
  6. Target: Does all the target specific stuff (converting sound, include standard library,... )

Every pass is divided into several (little) sub passes. The compiler itself is a compile on demand parser, which means, it just compiles functions that are really used within the source code.

Lexer

TODO

Preprocessor

TODO

Analyser

TODO

Parser

TODO

Generator

TODO

Target

TODO