Docsity

Evaluation Methods - Compiler Construction - Lecture Slides, Slides of Compiler Construction

Partial preview of the text

Download Evaluation Methods - Compiler Construction - Lecture Slides and more Slides Compiler Construction in PDF only on Docsity!

Compiler

Construction

Lecture 32

2

Number

Sign List

Bit

1

List

List

Bit

Bit^1

0

Parse tree for –

4

Number

Sign

List

Bit

1

val: -

List

List

Bit

Bit 1

0

Inherited Attributes

pos: 0 val: 5

pos: 0 val: 1

pos: 1 val: 4

pos: 1 val: 0

pos: 2 val: 4

pos: 2 val: 4

neg: true

5

Number

Sign

List

Bit

1

val: -

List

List

Bit

Bit 1

0

Synthesized Attributes

pos: 0 val: 5

pos: 0 val: 1

pos: 1 val: 4

pos: 1 val: 0

pos: 2 val: 4

pos: 2 val: 4

neg: true

7

Number

Sign

List

Bit

1

val: -

List

List

Bit

Bit 1

0

peel away parse tree

pos: 0 val: 5

pos: 0 val: 1

pos: 1 val: 4

pos: 1 val: 0

pos: 2 val: 4

pos: 2 val: 4

neg: true

8

1

val: -

1

0

dependence graph

pos: 0 val: 5

pos: 0 val: 1

pos: 1 val: 4

pos: 1 val: 0

pos: 2 val: 4

pos: 2 val: 4

neg: true

10

Evaluation Methods

Dynamic methods

 Build the parse tree

 Build the dependence graph

 Topological sort the graph

 Define attributes in topological

order

11

Evaluation Methods

Dynamic methods

 Build the parse tree

 Build the dependence graph

 Topological sort the graph

 Define attributes in topological

order

13

Evaluation Methods

Dynamic methods

 Build the parse tree

 Build the dependence graph

 Topological sort the graph

 Define attributes in topological

order

14

Evaluation Methods

Dynamic methods

 Build the parse tree

 Build the dependence graph

 Topological sort the graph

 Define attributes in topological

order

16

Evaluation Methods

Oblivious (passes, dataflow)

 Ignore rules and parse tree

 Pick a convenient order (at

design time) and use it

17

Problems

Attribute grammars have

not achieved widespread

use due to a myraid of

problems

19

Problems

 non-local computation

 traversing parse tree

 storage management for

short-lived attributes

 lack of high-quality

inexpensive tools

20

Problems

 non-local computation

 traversing parse tree

 storage management for

short-lived attributes

 lack of high-quality

inexpensive tools