Lecturer: Jason Jen-Yen Chen
Office: B313 Eng. Building 5
Email: jasonjychen@gmail
Office Hour: TBA
Course Description:
A compiler automatically translates source code (in a high-level programming language) to target
code (in a low-level assembly language for a computer architecture). Without it, there would have
been no way to build large-scale software quick enough to meet customer’s needs. This module
introduces the major components of a compiler covering scanner, parser, including top-down and
bottom-up parsers, abstract syntax tree (AST) generator, intermediate code generator, intermediate
code optimizer, and target code (assembly code) generator. In addition, runtime storage
management will be covered. Most of all, students will learn to develop a practical compiler that
transforms a Java-like language called “myLang” to ARM assembly code.
Learning Objectives:
To understand the major components of a compiler through a simple example compiler.
To understand the theory of scanning tokens from source code, namely, regular expression,
non-deterministic finite automata (NFA), deterministic finite automata (DFA), and the
subset construction algorithm to transform a NFA to a DFA.
To specify the syntax of a programming language using context-free grammar (CFG),
including terminal, non-terminal, production rules, left-most or right-most derivation,
sentential form, and so on.
To understand the theory of parsing, including first set, follow set, top-down parsing, and
bottom-up parsing that includes LR(0), simple LR(1), LR(1), and LALR(1) methods.
To understand abstract syntax tree (AST) that serves as the central data structure for
compiler construction, which uses an array to implement a tree with 3 pointers: left-most
child (LMC), right-sibling (RS) and parent (P).
To understand the theory of bottom-up rewriting system (BURS) that recursively transforms
an AST to target code of register machine architecture.
To understand the runtime support of memory storage management provided by compiler.
Learning Outcomes
Recognize terminology, and describe the features of the components of a compiler. Create
regular expression to identify tokens. Transform a regular expression to NFA, then to DFA.
Design a scanner for the DFA.
Explain context-free grammar (CFG) including production rule, start symbol, derivation,
left-most or right-most derivation, parse tree and so on. Explain constructs of a
programming language such as identifier, factor, term, expression, statement, and so on.
Explain parsing issues such as first set, follow set, top-down parsing and 4 methods of
bottom-up parsing. Design a top-down parser.
Design the data structure for abstract syntax tree (AST). Explain how to use BURS to
transform AST to target code.
Grading Policy:
Mid-Term Exam 30%
Final Exam
40% (4 Labs, 10% each)
Bonus points: 1. Class attendance (1 point each class)
2. Office hour visit (1 to 3 points, depending on your question)
Note that the bonus points intend to help hard-working students pass this course. Thus, no
bonus will be given beyond the passing grade of 60.
Learning Materials & Resources
Crafting a Compiler, Fischer, Cytron, and LeBlanc, Pearson 2010.
ISBN: 978-0-13-801785-9
Reference book:
Modern Compiler Design, Grune, Bal, Jacobs and Langendoen, Wiley 2000.
Access web site for online class notes.