source: liacs/cvp/assignments/lecture2.txt@ 61

Last change on this file since 61 was 2, checked in by Rick van der Zwet, 15 years ago

Initial import of data of old repository ('data') worth keeping (e.g. tracking
means of URL access statistics)

File size: 2.0 KB
Line 
1# Rick van der Zwet
2# StudentID: 0433373
3# $Id: lecture2.txt 248 2007-10-04 19:37:40Z rick $
4
5All quotes are based on the 7th edition of Concepts of programming
6languages from Robert W. Sebesta, cause the 8th edition has not come in
7yet
8
9*** Chapter 3 Review Questions ***
10
112)
12Q: Who are language descriptions for?
13A: "One of the problems ... about a language" pg. 124 sect. 3.1
14
153)
16Q: Describe the operation of a general language generator
17A: "A language generator ... it is pushed" pg. 126 sect. 3.2.2
18
196)
20Q: Define a left recursive grammar rule.
21A: "In this derivation ... leftmost drivations" pg 130
22 Example: <stmt> => <stmt> , <id>
23 | <id>
24 <id> => A | B | C
25
268)
27Q: Distinguish between static and dynamic semantics.
28A: "Static semantics is .. at compile time" pg. 142 sec. 3.4.1
29
309)
31Q: What purpose do predicates service in an attribute grammer?
32A: "Predicates functions, which .. with grammar rules." pg. 142. sec. 3.4.2
33
3410)
35Q: What is the difference between a synthensized and an inherited
36 attribute?
37A: "Synthesized attributes are ... across a tree" pg. 143 sect. 3.4.3
38
3913)
40Q: What is the problem with using a software pure interpreter for
41 operation semantics?
42A: "First, the copmlexities ... configured computer." pg. 149
43
44*** Chapter 3 Problem Set ***
4519) Compute the weakest precondition for each of the following
46 assignment statements and postconditions:
47
4819a)
49Q: a = 2 * (b - 1) - 1 {a > 0}
50A: 2 * (b - 1) - 1 > 0
51A b > 1.5
52
5319b)
54Q: b = (c + 10) / 3 {b > 6}
55A: (c + 10) / 3 > 6
56 c > 8
57
5819c)
59Q: a = a + 2 * b - 1 {a > 1}
60A: a + 2 * b - 1 > 1
61 b > 0.5a + 1
62
6319d)
64Q: x = 2 * y + x - 1 {x > 11}
65A: 2 * y + x - 1 > 11
66 y > 6 - 0.5x
67
6820) Compute the weakest precondition for each of the following
69 assignment statements and postconditions:
70
7120a)
72Q: a = 2 * b + 1;
73 b = a - 3
74 {b < 0}
75A: a - 3 < 0
76 {a < 3}
77 2 * b + 1 < 3
78 {b < 1}
79
8020b)
81Q: a = 3 * (2 * b + a);
82 b = 3 * a - 1
83 {b > 5}
84A: 3 * a - 1 > 5
85 {a > 2}
86 6 * 3b + 3a > 2
87 18b + 3a > 2
88 18b > 2 - 3a
Note: See TracBrowser for help on using the repository browser.