Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 614: Theory and Construction of Compilers

Similar presentations


Presentation on theme: "CS 614: Theory and Construction of Compilers"— Presentation transcript:

1 CS 614: Theory and Construction of Compilers
Lecture 11 Fall 2002 Department of Computer Science University of Alabama Joel Jones

2 Overview Action routines in Java Cup Abstract Syntax Trees
Readings for Next Time ©2002 Joel Jones

3 Action Routines in Java Cup
Associated with productions Return Symbol Symbol contains token type and value Syntactically assign to RESULT with type of value ©2002 Joel Jones

4 Abstract Syntax Trees Clean Interface between parser and later phases of compiler Conveys phrase structure with all parsing issues resolved ©2002 Joel Jones

5 Concrete Syntax Vs. Abstract Syntax
Stm -> Stm ; Stm Stm -> id := Exp Stm -> print ( ExpList ) Exp -> id Exp -> num Exp -> Exp Binop Exp Exp -> (Stm, Exp) ExpList -> Exp, ExpList ExpList -> Exp BinOp -> + | - | * | / S -> S ; S S -> id := E S -> print L E -> id E -> num E -> E B E E -> S , E L -> L -> L E B -> + | - | * | / ©2002 Joel Jones

6 Representing Tree Data Structures in Java
A tree is described by one or more abstract classes, corresponding to a symbol in the grammar Each abstract class is extended by one or more subclasses, one for each gramar rule For each nontrivial symbol on rhs, thereis a field in the corresponding class Each class has a constructor that initializes all fields and is thereafter immutable ©2002 Joel Jones

7 Readings for Next Time Chapter 4 through and including section 4.6
©2002 Joel Jones


Download ppt "CS 614: Theory and Construction of Compilers"

Similar presentations


Ads by Google