[Compiler] 프로그래밍언어론 정리
Undergraduate lectures

[Compiler] 프로그래밍언어론 정리

본 글은 필자가 2021년도 2학기에 프로그래밍언어론 수업을 듣고 퀴즈 준비차 작성한 글입니다.

Whole System

From Source code,

  1. Parser ( -> Parse Tree)
    1. Lexical Analyzer ( -> Tokens)
    2. Syntatic Analyzer ( ->Parse Tree)
      • Chomsky Hierarchy 중 Context Free Grammar
  2. Compiler (->Assembly lanugage)
    1. Semantic Analyzer
      • Semantics: Variables, Polymorphism, Scope
    2. Compiler vs.  Interpreter
    3. Etc.
      • Dynamic Compilation(JIT Compilation)
      • Virtual Machine
      • Interpretive Compiler
  3. Assembler ( -> Object file/ Machine's binary format)
  4. Linker ( -> Executable file)
    1. Static Linking / Dynamic Linking
    2. Delayed Linking: Loadtime Dynamic Linking / Run-time Dynamic Linking
  5. Loader (-> Running program in memory)
    1. Variable Binding
    2. Allocation of Activation Record
      • Activation Record: on Function, Activation record variable
      • Static Allocation
      • Dynamic Allocation: Stack, Heap
      • Problem: How can the inner function know the most recent activation for outer function
        • Nesting Link, Displays, Lambda linking
    3. Parameter Passing
      • Parameter type: Formal, Actual / Positional, Named Parameter
      • Parameter Passing: Passing by value/result/value-result // reference // macro expansion / name / need

Language System

  1. gcc, IDE(통합환경)
  2. Intepreter / Compiler / Intepretive Compiler
  3. Virtual Machine (JVM)
  4. Profiling
  5. Dynamic Compilation (JIT)

Context Free Grammar

  • elements of CFG: Token, Non-terminal, Start symbol, Production rule
  • Normal Form: EBNF, BNF

Semantics

1. Variables

  • Type: Primitive type & Constructed type
  • Rules
    • Scope rules: regulate the visibility of the identifier
    • Type rules: regulate the expected types of arguments and returned value for the operations of a language
  • Type annotation / Checking
  • Equivalence

2. Polymorphism

: functions with extra flexibility

  • Ad hoc Polymorphism
    • Overloading
    • Parameter Coerion
  • Universal Polymorphism
    • Subtype Polymorphism
    • Parametric Polymorphism

3. Scope

  • Scope annotation & inference
    • Static Scoping
    • Dynamic Scoping

Memory

1. Stack

  • Activation record
    • Activation of function: Return address, link to  
    • Activation-specific variable