The Mid-Term Exam of Compiler
The Mid-Term Exam of Compiler
(Closed Book)
(2020-2021 Academic Year 1st Semester)
课程号 Course Number: 311126030 课程名称 Course Title: Compiler Construction Principles and Practice
任课教师 Lecturer: 考试时间 Time Period:
学生姓名 Name: 学号 Student ID: 成绩 Total Mark:
考 生 承 诺
Student Commitment
我已认真阅读并知晓《四川大学考场规则》和《四川大学本科学生考试违纪作弊处分规定(修
订)》,郑重承诺:
I have read and comprehended the “Regulations of Sichuan University on Examinations”. I give my
commitments as follows:
1、已按要求将考试禁止携带的文具用品或与考试有关的物品放置在指定地点;
1. I have put prohibited stationary and exam-related items at designated area as required.
2、不带手机进入考场;
2. I have not brought cell phone to the examination room.
3、考试期间遵守以上两项规定,若有违规行为,同意按照有关条款接受处理。
3. During the examination, I will comply with the above two provisions. If there is any violation, I
agree to accept the punishments in accordance with the relevant provisions.
考生签名:
Signature:
Part I Answer Questions (30 points, 5 points for each)
2. Use Thompson's construction to convert the following regular expressions into NFAs
respectively. (4 points for each)
a) a|ab
b) a(a|b)*
c) (aa|b)*a
3. Convert the following NFA into an equivalent DFA using the subset construction, and
provide detailed steps. (10 points)
Part V Programming
(10 points)
1. Translate the following DFA into pseudocode using a doubly nested case statement
inside a loop, where the first case statement tests the current state and the nested second
level tests the input character.
a
a [other]
1 2 3