[COURSE] Add NJU Compiler Course (#579)

This commit is contained in:
TekkenSteve 2024-03-31 16:26:19 +08:00 committed by GitHub
parent bc8acc6f6e
commit efb461bbc3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,33 @@
# NJU Compilers
## Descriptions
- Offered by: Nanjing University
- Prerequisite: Discrete Mathematics
- Programming Languages: Java
- Difficulty: 🌟🌟🌟
- Learning Hours: 80
The compiler principles course at Nanjing University utilizes the popular ANTLR (ANother Tool for Language Recognition) v4 programming language parsing and code generation tool to aid in teaching. This tool allows users to focus on designing lexical or syntactic analysis while ANTLR 4 generates repetitive template code. IDE plugins are also available, enabling real-time visualization of the parse tree for easier student comprehension.
ANTLR 4 is an LL parser generator, which, compared to LR and LALR parser generators, can handle a narrower scope of grammars. However, its generated parsers have the advantage of being easier to understand and use. Additionally, its support for "infinite lookahead" scanning improves handling of narrow grammar scopes.
The instructor delivers lectures on compiler design in a humorous and engaging manner, incorporating appropriate diagrams and real-life examples to maintain student interest. Particularly in this version of the course, the approach involves first practically completing small examples using ANTLR 4, followed by supplementing with theoretical knowledge. This allows students to approach theoretical aspects with specific questions in mind, enhancing memorability. Through the study of theoretical knowledge, the "mysterious veil" of the C language is gradually lifted.
The theoretical part follows the rhythm outlined in the "Dragon Book," covering topics such as lexical analysis, syntax analysis, semantic analysis, runtime environments, register allocation, code optimization, and generation.
The practical aspect is the highlight of this course, guiding students step by step to implement their own compiler from simple to complex.
The instructor is extremely generous, allowing even non-university students to access the Online Judge and participate in course discussions. The instructor also meticulously organizes study materials from previous years, making them easily accessible on the course website.
The instructor also openly shares the [Zulip](https://2024-compilers-at-software-nju.zulipchat.com/join/wxwq3fib56ltlff2mk6qyrz5/) address for the teaching group (if there are any changes, they can be found on the course website), meaning that students can ask questions and see the questions of other Nanjing University students studying the same material. These questions receive responses from teaching assistants and the instructor, eliminating the need to reiterate pitfalls or experiences, as students can exchange information on one platform with others studying the same content.
The biggest takeaway is that there is no longer a sense of difficulty or uncertainty in implementing a compiler. Upon completing the course, students have a preliminary and effective approach that enables them to face challenges confidently.
## Course Resources
- Course Website: <http://docs.compilers.cpl.icu/>
- Recordings: <https://space.bilibili.com/479141149/channel/collectiondetail?sid=2312309>
- Textbook: Compilers: Principles, Techniques and Tools (Dragon Book)
- Assignments: 10 written assignments + 8~10 programming labs

View File

@ -0,0 +1,39 @@
# NJU 编译原理
## 课程简介
- 所属大学:南京大学
- 先修要求:离散数学
- 编程语言Java
- 课程难度:🌟🌟🌟
- 预计学时80 小时
南京大学的编译原理课程,设计者选用了当下热门的 ANTLR ANother Tool for Language Recognition v4 编程语言解析生成工具辅助教学,能让使用者专心词法或者语法分析的设计,而让 ANTLR 4 来生成重复的模板代码。IDE 也有其插件,装上后,可以实现即时的可视化语法树,方便学生理解。
ANTLR 4 是 LL 解析器生成器,比起 LR 和 LALR 解析器生成器,它可处理语法的范围相对狭窄。但另一方面其生成的解析器有易于理解和使用的优势。此外,因为其支持“无限长的 token 超前扫描”,所以可处理语法范围狭窄的问题也得到了很好的改善。
老师通过适当的图解和生活例子,幽默风趣地讲述编译原理,让人听来不算乏闷。尤其是今年这版,采取先实际使用 ANTLR 4 完成一些小例子,再补足理论知识的方式。让人能带着问题去找到适配的理论,更让人印象深刻。通过理论知识的学习,逐渐揭开 C 语言的“神秘面纱”。
理论部分基本按照龙书节奏叙述。包括词法分析、语法分析、语义分析、运行时环境、寄存器分配、代码优化与生成等内容。
实践则是本课程的亮点,一步步的,由简单到复杂地实现一个属于自己的编译器。
教授本课的老师极为慷慨,校外学生同样能享受到 Online Judge 以及参与课程讨论,老师还极为细心地整理历年来的学习资料,在课程网站里十分容易找到。
老师还把教学班的 [Zulip](https://2024-compilers-at-software-nju.zulipchat.com/join/wxwq3fib56ltlff2mk6qyrz5/) 地址公开(若有变更,在课程网站也能找到),这意味着你有任何问题,都能在上面提问,同时你也能看到跟你一起学习的南大学生的问题,这些问题都会得到助教和老师的回答,所以我并不用再赘述踩了哪些坑或者经验,因为你能在一个平台上,和一帮正在学习相同内容的人,一起交流问题。
最大感受是,心里不再对实现一个编译器有畏难情绪,也不再无从下手,学完课程,会有一套初步的行之有效的思路,让我们面对挑战。
## 课程资源
- 课程网站:<http://docs.compilers.cpl.icu/>
- 课程视频:<https://space.bilibili.com/479141149/channel/collectiondetail?sid=2312309>
- 课程教材:龙书等
- 课程作业10 个书面作业 + 8 ~ 10 个编程作业带你实现一个编译器

View File

@ -214,6 +214,7 @@ nav:
- "CMU 15-799: Special Topics in Database Systems": "数据库系统/15799.md"
- 编译原理:
- "Stanford CS143: Compilers": "编译原理/CS143.md"
- "NJU 编译原理": "编译原理/NJU-Compilers.md"
- 编程语言设计与分析:
- "Stanford CS242: Programming Languages": "编程语言设计与分析/CS242.md"
- "NJU 软件分析": "编程语言设计与分析/NJU-SoftwareAnalysis.md"