education-2022/selected/compilers.md

5.7 KiB
Raw Blame History

Compilers: How To Make a Programming Language

Other compiler-related topics out of scope:

  • What are programs anyway (Forth, LISP)
  • Computation: Turing machines, lambda calculus
  • Compiler optimization
  • GC (motivated by LISP)

aesthetics:

  • stay motivated; stick close to a c-like, imperative, procedural model because that's what people are used to

motivation / goals / what questions are we trying to answer:

  • I want to be able to make a toy procedural language.
    • like C, Algol, JS, Lua, etc.
    • possible user motivations:
      • I want to make a game scripting language
      • I want to make a DSL for my job (and I want syntax highlighting!)
  • I want to do simple static analysis of my projects

ok what do we want to cover

  • classical compiler structure (lexer -> parser -> codegen)
Title Page
Phases of a Compiler https://www.geeksforgeeks.org/phases-of-a-compiler/
Compiler Architecture https://cs.lmu.edu/~ray/notes/compilerarchitecture/
Compiler Design https://www.tutorialspoint.com/compiler_design/compiler_design_phases_of_compiler.htm
Structure of a Compiler https://www.csd.uwo.ca/~mmorenom/CS447/Lectures/Introduction.html/node10.html
The Structure of a Compiler https://www.brainkart.com/article/The-Structure-of-a-Compiler_8121/
Wikipedia: Compiler https://en.wikipedia.org/wiki/Compiler
Compiler Phases https://www.javatpoint.com/compiler-phases
The Structure of a Compiler https://pages.cs.wisc.edu/~fischer/cs536.s08/lectures/Lecture04.4up.pdf
Phases of a Compiler https://www.guru99.com/compiler-design-phases-of-compiler.html
Writing a C Compiler (Pt. 1) https://norasandler.com/2017/11/29/Write-a-Compiler.html
V: Structure of a Compiler https://www.youtube.com/watch?v=RH02jcUiPI0
V: Phases of a Compiler https://www.youtube.com/watch?v=jE7f3sGLGVk
V: Compiler Design https://www.youtube.com/watch?v=OZSGjRSHYUk
V: Different Phases of Comp https://www.youtube.com/watch?v=TApMNhQPaCM
V: Phases of Compiler https://www.youtube.com/watch?v=r2BRNodqbgI
V: Parser and Lexer (Pt. 1) https://www.youtube.com/watch?v=eF9qWbuQLuw
  • semantic analysis / type checking
  • modern compiler structures (IR / SSA, optimization)
  • interpreters vs. JITs vs. AOTs vs. "transpilers"
  • executables and linkers
  • regular expressions?
  • regular languages / grammars / language structure / automata
  • terminology?

the c compilation process

  • translation units
  • preprocessing -> (the whole compilation process) -> object files -> linking
  • c compilation model is not in favor any more, don't like compiling all these files separately
  • ABIs and FFI
  • should maybe be in separate article

experts / consultants:

  • Bill
  • NeGate

The actual progression

  • Simple expression interpreter (parse and evaluate)
  • Classical compiler construction (lex -> parse -> output), semantic analysis / type checking
    • motivation: complex structures! recursion! etc.
    • many of these resources exist and cover different aspects of the process in different ways
  • Grammars and language structure
  • Types of output (interpreter vs. AOT vs. JIT, etc.)
    • We can probably find resources on specific ones of these
  • Modern phases (IR / SSA)
    • Mention WASM?
  • The terrors of the real world
    • Executables, linkers, and debug info
    • The C ABI and FFI
    • Register allocation
  • C is not the only language
    • LISP
    • Forth
    • This could be a whole topic maybe

Books

Webpages

From NeGate