INF5110 – Compiler Construction
Semantic analysis Spring 2016
1 / 60
INF5110 Compiler Construction Semantic analysis Spring 2016 1 / - - PowerPoint PPT Presentation
INF5110 Compiler Construction Semantic analysis Spring 2016 1 / 60 Outline 1. Semantic analysis Intro Attribute grammars Rest 2 / 60 Outline 1. Semantic analysis Intro Attribute grammars Rest 3 / 60 Overview over the chapter a a
1 / 60
2 / 60
3 / 60
aSlides originally from Birger Møller-Pedersen
4 / 60
5 / 60
6 / 60
7 / 60
8 / 60
aUnless some fancy behind-the-scence type conversions are done by the
1For fundamental reasons (cf. also Rice’s theorem). Note that
9 / 60
10 / 60
11 / 60
12 / 60
13 / 60
2attributes in AG’s: static, obviously. 14 / 60
3stated earlier: values of syntactic entities are generally dynamic attributes
15 / 60
atop-down calculation will not be needed for the simple expression evaluation
16 / 60
17 / 60
18 / 60
19 / 60
20 / 60
5different symbols may share same attribute with the same name. Those
21 / 60
22 / 60
23 / 60
24 / 60
25 / 60
26 / 60
6apart from immediate cross-generation. 27 / 60
28 / 60
29 / 60
30 / 60
31 / 60
32 / 60
33 / 60
34 / 60
35 / 60
aalternatively: grammar describing nice and cleans ASTs for an underlying,
36 / 60
37 / 60
38 / 60
39 / 60
7There are thus 2 different values. We don’t mean “the attribute dtype has
40 / 60
8Actually, it’s conceptually better not to think of it as “the attribute dtype”,
41 / 60
42 / 60
43 / 60
44 / 60
45 / 60
46 / 60
47 / 60
9it’s not a tree. It may have more than one “root” (like a forest). Also:
48 / 60
10On the other hand: needs to be one only once. 49 / 60
11base-char .base (synthesized) considered different from num .base
50 / 60
12acyclicity checking for a given dependence graph: not so hard (e.g., using
51 / 60
52 / 60
13reasonable, if AST. For parse-tree, the attribution of types must deal with
53 / 60
54 / 60
55 / 60
56 / 60