Compiler Principles
- Level
- Undergraduate
- Status
- Under development
Note: this course is still being designed and calibrated; the page content is for reference and does not represent the final teaching version.
Syllabus
Course Overview
Compiler Principles is organized around a working compiler, from lexing, parsing, semantic analysis, IR, optimization, to code generation. The compiler is treated as a common foundation for programming languages, static analysis, runtimes, and security checks.
This is a foundation for program analysis, software security, and formal tooling.
Prerequisites
- Discrete mathematics, data structures, and systems programming.
- Familiarity with at least one typed or scripting language.
- Ability to read recursive algorithms and basic formal-language material.
Learning Outcomes
- Implement lexing, parsing, and semantic checks.
- Design an intermediate representation and basic optimizations.
- Generate executable or interpretable target code.
- Understand types, scope, control flow, and data flow.
- Apply compiler techniques to static checks and security tools.
Course Format
- Two meetings per week: one for core concepts and one for labs, paper discussion, or project review.
- The course proceeds over 16 weeks, each with a checkable assignment, lab, or project milestone.
- Reproducibility is required: code, configuration, data, lab logs, and reports must be reviewable by staff or peers.
Weekly Plan
Language design and compiler structure
Define the course language and test framework.
Language design and compiler structure: lab and review
Define the course language and test framework. Complete the paired lab, record issues, and explain design tradeoffs in class review.
Lexing and regular languages
Implement a lexer and source-location errors.
Lexing and regular languages: lab and review
Implement a lexer and source-location errors. Complete the paired lab, record issues, and explain design tradeoffs in class review.
Parsing and ASTs
Implement a parser and emit ASTs.
Parsing and ASTs: lab and review
Implement a parser and emit ASTs. Complete the paired lab, record issues, and explain design tradeoffs in class review.
Scope, types, and semantic analysis
Complete symbol tables and type checking.
Scope, types, and semantic analysis: lab and review
Complete symbol tables and type checking. Complete the paired lab, record issues, and explain design tradeoffs in class review.
IR, control flow, and data flow
Generate IR and control-flow graphs.
IR, control flow, and data flow: lab and review
Generate IR and control-flow graphs. Complete the paired lab, record issues, and explain design tradeoffs in class review.
Optimization and analysis
Implement constant propagation or dead-code elimination.
Optimization and analysis: lab and review
Implement constant propagation or dead-code elimination. Complete the paired lab, record issues, and explain design tradeoffs in class review.
Code generation and runtime
Generate target code or a bytecode interpreter.
Code generation and runtime: lab and review
Generate target code or a bytecode interpreter. Complete the paired lab, record issues, and explain design tradeoffs in class review.
Compiler extensions and security checks
Add a language feature or static security check.
Compiler extensions and security checks: lab and review
Add a language feature or static security check. Complete the paired lab, record issues, and explain design tradeoffs in class review.
Assessment
Concept questions, reading responses, design tasks, and small programming or lab exercises.
Compiler milestones, test suites, and a final extension.
Participation in discussions, demos, code or paper reviews, and peer feedback.
Submit reproducible artifacts, a technical report, and a demo explaining methods, results, limitations, and future work.
Course Project
Students build a small compiler in stages and add a final extension such as a type feature, optimization, interpreter, diagnostics, or security lint.
Policies
- AI tools are allowed, but generated code, lab notes, and design suggestions must be reviewed by the student and disclosed in the report.
- Students may not submit code, proofs, configuration, or experimental results they cannot explain; each member must defend their own design, tests, and tradeoffs.
- Late work affects iteration grades, but the course values reproducible, auditable, and maintainable results over last-minute accumulation.
Reference Courses
International
- CMU15-411/611 Compiler Design
- CornellCS 4120/4121: Introduction to Compilers
- ETH Zurich252-0210-00L Compiler Design
- Georgia TechCS 4240: Compilers and Interpreters
- MIT6.035: Computer Language Engineering
- PrincetonCOS 320: Compiling Techniques
- StanfordCS 143: Compilers
- UC BerkeleyCS 164: Programming Languages and Compilers
- University of WashingtonCSE 401: Introduction to Compiler Construction