Skip to content

# 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 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/lists/2312309
- Textbook: Compilers: Principles, Techniques and Tools (Dragon Book)
- Assignments: 10 written assignments + 8~10 programming labs

2025-07-28