Pla
- Booleans
S d Pi
- Steps towards a Pico e
– Step 1: define syntax – Step 2: define a type che – Step 3: define an evaluat
Step 3: define an evaluat
– Step 4: define a compile
T l f ti
- Traversal functions
- Methodology
Introduction
an
i nvironment
ecker tor tor er
to ASF+SDF 1
Traversal Fu
- Many functions have the
traverse the tree recursiv traverse the tree recursiv something interesting at E l t th id
- Example: count the iden
- Using a recursive (induc
– # of equations is equal to
think about Cobol or Jav
– think about Cobol or Jav
- Traversal functions auto
Introduction
unctions (1)
e characteristic that they vely and only do vely and only do t a few nodes tifi i ntifiers in a program ctive) definition:
- number of syntax rules
va with hundreds of rules va with hundreds of rules
- mate recursion
to ASF+SDF 2
Traversal Fu
There are two important as functions: functions:
– the kind of traversal
- accumulate a value durin
- transform the tree during
h d f l
– the order of traversal
- top-down versus bottom-
- left-to-right versus right-
- break or continue after a
Introduction
unctions (2)
spects of traversal
ng traversal g traversal
- up
- to-left (we only have the first)
visit
to ASF+SDF 3
Top-down vers
Top-down 1 2 5 3 4 6 7
Introduction
sus Bottom-up
Bottom-up 7 3 6 1 2 4 5
to ASF+SDF 4