Introduction
1.
1.Introduction
1.1.
Exercises for Section 1.1
1.2.
Exercises for Section 1.3
1.3.
Exercises for Section 1.6
2.
2.A Simple Syntax-Directed Translator
2.1.
Exercises for Section 2.2
2.2.
Exercises for Section 2.3
2.3.
Exercises for Section 2.4
2.4.
Exercises for Section 2.6
2.5.
Exercises for Section 2.8
2.6.
Key Point
3.
3.Lexical Analysis
3.1.
Exercises for Section 3.1
3.2.
Exercises for Section 3.3
3.3.
Exercises for Section 3.4
3.4.
Exercises for Section 3.5
3.5.
Exercises for Section 3.6
3.6.
Exercises for Section 3.7
3.7.
Exercises for Section 3.8
3.8.
Exercises for Section 3.9
3.9.
Key Point
4.
4.Syntax Analysis
4.1.
Exercises for Section 4.2
4.2.
Exercises for Section 4.3
4.3.
Exercises for Section 4.4
4.4.
Exercises for Section 4.5
4.5.
Exercises for Section 4.6
4.6.
Exercises for Section 4.7
4.7.
Key Point
5.
5.Syntax-Directed Translation
5.1.
Exercises for Section 5.1
5.2.
Exercises for Section 5.2
5.3.
Exercises for Section 5.3
5.4.
Exercises for Section 5.4
5.5.
Exercises for Section 5.5
6.
6.Intermediate-Code Generation
6.1.
Exercises for Section 6.1
6.2.
Exercises for Section 6.2
6.3.
Exercises for Section 6.3
6.4.
Exercises for Section 6.4
6.5.
Exercises for Section 6.5
6.6.
Exercises for Section 6.6
6.7.
Exercises for Section 6.7
7.
7.Run-Time Environments
7.1.
Exercises for Section 7.2
7.2.
Exercises for Section 7.3
7.3.
Exercises for Section 7.4
7.4.
Exercises for Section 7.5
7.5.
Exercises for Section 7.6
7.6.
Exercises for Section 7.7
8.
8.Code Generation
8.1.
Exercises for Section 8.2
8.2.
Exercises for Section 8.3
8.3.
Exercises for Section 8.4
8.4.
Exercises for Section 8.5
9.
12.InterProcedural Analysis
9.1.
Exercises for Section 12.3
9.2.
Exercises for Section 12.3
Published with GitBook
A
A
Serif
Sans
White
Sepia
Night
Share on Twitter
Share on Google
Share on Facebook
Share on Weibo
Share on Instapaper
Compilers Principles, Techniques, & Tools (purple dragon book) second edition exercise answers
6.1 节的练习
为下面的表达式构造 DAG
((x+y)-((x+y)*(x-y)))+((x+y)*(x-y))
解答
为下列表达式构造 DAG,且指出他们每个子表达式的值编码。假定 + 是左结合的。
a+b+(a+b)
a+b+a+b
a+a+(a+a+a+(a+a+a+a))
解答
a+b+(a+b)
1
id
a
2
id
b
3
+
1
2
4
+
3
3
a+b+a+b
1
id
a
2
id
b
3
+
1
2
4
+
3
1
5
+
4
2
a+a+(a+a+a+(a+a+a+a))
1
id
a
2
+
1
1
3
+
2
1
4
+
3
1
5
+
3
4
6
+
2
5