cs 603: programming language organization lecture 8 spring 2004 department of computer science...

9
CS 603: Programming Language Organization Lecture 8 Spring 2004 Department of Computer Science University of Alabama Joel Jones

Upload: lisa-johnston

Post on 29-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS 603: Programming Language Organization Lecture 8 Spring 2004 Department of Computer Science University of Alabama Joel Jones

CS 603: Programming Language Organization

Lecture 8

Spring 2004

Department of Computer Science

University of Alabama

Joel Jones

Page 2: CS 603: Programming Language Organization Lecture 8 Spring 2004 Department of Computer Science University of Alabama Joel Jones

©2004 Joel Jones

Outline

• Announcements

• Questions

• Impcore Interpreter

• Reading for next time

Page 3: CS 603: Programming Language Organization Lecture 8 Spring 2004 Department of Computer Science University of Alabama Joel Jones

©2004 Joel Jones

Colloquium

Wan HuangUniversity of Alabama

Intelligent Trust Evaluation and Self-Organizing Multi-Agent Community

http://cs.ua.edu/9Colloquium.abs/Wan.htm

Friday, January 3011 am, HO108

Page 4: CS 603: Programming Language Organization Lecture 8 Spring 2004 Department of Computer Science University of Alabama Joel Jones

©2004 Joel Jones

Impcore Interpreter:Evaluation

• Heart of the interpreter—topeval and eval

• Arguments follow form of operational semantics

Pair Up: • What was the form of the {downarrow} relation?

• What did it signify?

• Value eval(Exp *e, Valenv *globals, Funenv *functions, Valenv *formals)

Page 5: CS 603: Programming Language Organization Lecture 8 Spring 2004 Department of Computer Science University of Alabama Joel Jones

©2004 Joel Jones

Impcore Interpreter:Evaluation (cont.)

• Evaluation of tree structure– Dispatch on type of node at root– Recursively execute children– Execute tree

Pair Up:

• What field of the AST representation do we dispatch on?

• How do you dispatch on type in a non-OO language like C?

Page 6: CS 603: Programming Language Organization Lecture 8 Spring 2004 Department of Computer Science University of Alabama Joel Jones

©2004 Joel Jones

Impcore Interpreter:Evaluation (cont.)

• For each AST type, there may be multiple applicable judgments in the operational semantics– VAR has FORMALVAR and GLOBALVAR

Pair Up:

• Write the mappings from tags to judgment names for the rest of the Exp productions

Page 7: CS 603: Programming Language Organization Lecture 8 Spring 2004 Department of Computer Science University of Alabama Joel Jones

©2004 Joel Jones

Impcore Interpreter:Evaluation (cont.)

• The form of eval is then:

switch (e->typ) {

case TAG:

evaluate rhs if shared premise exists

chose and execute appropriate judgment

...

}

Page 8: CS 603: Programming Language Organization Lecture 8 Spring 2004 Department of Computer Science University of Alabama Joel Jones

©2004 Joel Jones

Impcore Interpreter:Evaluation (cont.)

• What is done in implementing each of the productions?

Page 9: CS 603: Programming Language Organization Lecture 8 Spring 2004 Department of Computer Science University of Alabama Joel Jones

©2004 Joel Jones

Reading & Questions for Next Class

• Chapter 3-3.7– You might also want to look at the online

version of the book “Structure and Interpretation of Computer Programs” at:http://mitpress.mit.edu/sicp/

• What most differentiates Scheme from C or C++?