Skip to main content

007 · Stanford CS143 — 迷你编译器

项目 内容
学校 Stanford University
课程 Stanford CS143 Compilers
方向 编译器 / Compilers
语言 Python
难度 硬核 / Advanced
预计耗时 6–12 天 / 6–12 days

为什么收录

CS143 是把自动机、数据结构与系统串起来的综合大作业。本项目实现完整的前端→后端流水线(词法→语法→AST→代码生成→执行),让学生看清每一环如何衔接。

CS143 ties together automata theory, data structures, and systems. Our mini-compiler keeps the full front-end→back-end pipeline.

English: A compiler is the ultimate “build something that builds something” project — exceptionally rewarding for students who want to understand how programs really work.

实测结果

  • 词法 67 token,代码生成 34 指令(真实输出)
  • 综合程序输出 [25, 0, 1, 2, 1];阶乘 5! = 120
  • 词法/语法错误正确抛出;开发中修复 3 个真实 bug(分号/token 类型/赋值符),详见 05

七章解析

题目解读 · 设计思路 · 逐步实现 · 正确性与复杂度 · 调试与测试 · 踩坑清单 · 延伸练习

源码与测试

题目目录 · 参考实现 · 测试