CS 603: Programming Language Organization Lecture 3 Spring 2002 Department of Computer Science University of Alabama Joel Jones.

Slides:



Advertisements
Similar presentations
Overloading Having more than one method with the same name is known as overloading. Overloading is legal in Java as long as each version takes different.
Advertisements

1 Programming Languages (CS 550) Mini Language Interpreter Jeremy R. Johnson.
Compiler construction in4020 – lecture 10 Koen Langendoen Delft University of Technology The Netherlands.
Chapter 8. Operator Overloading Operator overloading gives the opportunity to redefine C++ Operator overloading refers to redefine C++ operators such.
Abstract Syntax Mooly Sagiv html:// 1.
1 Lecture-2 CSIT-120 Spring 2001 Revision of Lecture-1 Introducing Computer Architecture The FOUR Main Elements Fetch-Execute Cycle A Look Under the Hood.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Code Generation Mooly Sagiv html:// Chapter 4.
Objects and Classes First Programming Concepts. 14/10/2004Lecture 1a: Introduction 2 Fundamental Concepts object class method parameter data type.
CS150 Introduction to Computer Science 1
1 Lecture-2 CS-120 Fall 2000 Revision of Lecture-1 Introducing Computer Architecture The FOUR Main Elements Fetch-Execute Cycle A Look Under the Hood.
1 10/9/06CS150 Introduction to Computer Science 1 for Loops.
Chapter 11-12, Appendix D C Programs Higher Level languages Compilers C programming Converting C to Machine Code C Compiler for LC-3.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
Distribution of Marks Internal Sessional Evaluation Assignments – 10 Quizzes – 10 Class Participation Attendence – 5 Mid – Term Test – 25 External Evaluation.
Programming in Java; Instructor:Moorthy Introduction, Objects, Classes, Libraries1 Programming in Java Introduction.
OOP Languages: Java vs C++
High-Level Programming Languages: C++
CS 403: Programming Languages Lecture 2 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
Computing with C# and the.NET Framework Chapter 1 An Introduction to Computing with C# ©2003, 2011 Art Gittleman.
Lecture 10 : Introduction to Java Virtual Machine
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
CS 403: Programming Languages Lecture 6 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
COP2800 – Computer Programming Using JAVA University of Florida Department of CISE Spring 2013 Lecture 10 – Programming with Java Datatypes Type Casting.
CS 603: Programming Language Organization Lecture 7 Spring 2003 Department of Computer Science University of Alabama Joel Jones.
CS 603: Programming Language Organization Lecture 10 Spring 2004 Department of Computer Science University of Alabama Joel Jones.
Run-Time Storage Organization Compiler Design Lecture (03/23/98) Computer Science Rensselaer Polytechnic.
CS 614: Theory and Construction of Compilers Lecture 7 Fall 2002 Department of Computer Science University of Alabama Joel Jones.
CS 614: Theory and Construction of Compilers Lecture 8 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
CS 614: Theory and Construction of Compilers Lecture 9 Fall 2002 Department of Computer Science University of Alabama Joel Jones.
1 ENERGY 211 / CME 211 Lecture 6 October 3, 2008.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 19: Environments.
CS 614: Theory and Construction of Compilers Lecture 7 Fall 2003 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.
11/10/2016CS150 Introduction to Computer Science 1 Last Time  We covered “for” loops.
CS 152: Programming Language Paradigms March 19 Class Meeting Department of Computer Science San Jose State University Spring 2014 Instructor: Ron Mak.
CS 603: Programming Language Organization Lecture 9 Spring 2003 Department of Computer Science University of Alabama Joel Jones.
CS 614: Theory and Construction of Compilers Lecture 15 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
CS 614: Theory and Construction of Compilers Lecture 5 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
1 Programming Languages (CS 550) Lecture 2 Summary Mini Language Interpreter Jeremy R. Johnson.
Language Implementation Overview John Keyser Spring 2016.
CS 603: Programming Language Organization Lecture 1 Spring 2003 Department of Computer Science University of Alabama Joel Jones.
CS 614: Theory and Construction of Compilers Lecture 8 Fall 2002 Department of Computer Science University of Alabama Joel Jones.
CS 403: Programming Languages Lecture 20 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
CS 603: Programming Language Organization Lecture 6 Spring 2003 Department of Computer Science University of Alabama Joel Jones.
©2004 Joel Jones 1 CS 403: Programming Languages Lecture 3 Fall 2004 Department of Computer Science University of Alabama Joel Jones.
CCSA 221 Programming in C CHAPTER 3 COMPILING AND RUNNING YOUR FIRST PROGRAM 1 ALHANOUF ALAMR.
Repetition Statements
Chapter 2 Writing Simple Programs
Web Database Programming Using PHP
Principles of programming languages 10: Object oriented languages
Chapter 5- Assembling , Linking, and Executing Programs
PROGRAMMING LANGUAGES
Web Database Programming Using PHP
Internet and Java Foundations, Programming and Practice
CS 614: Theory and Construction of Compilers
CS 153: Concepts of Compiler Design November 30 Class Meeting
CS 603: Programming Language Organization
Introduction to the C Language
Mini Language Interpreter Programming Languages (CS 550)
CS-0401 INTERMEDIATE PROGRAMMING USING JAVA
The Metacircular Evaluator
CSE401 Introduction to Compiler Construction
CS150 Introduction to Computer Science 1
Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract, Computer,
CS148 Introduction to Programming II
CS149D Elements of Computer Science
CS148 Introduction to Programming II
Presentation transcript:

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

©2001 Joel Jones Outline Questions Interpreter Basics Reading for next time

©2001 Joel Jones Questions Any questions on chapter 1 language?

©2001 Joel Jones Interpreters Input: program text (or some intermediate form) Execution: runs program without producing machine code

©2001 Joel Jones Common Features of Language Processsors Readers –convert external representation into internal representation –Also called lexers/parsers Environments –mapping from names to values

©2001 Joel Jones Common Features of “Kamin” Interpreters (via Budd) Readers— class Reader Environments— class Environment Expressions— class Expression and its subclasses Read-eval-print loop—in main()

©2001 Joel Jones Read-eval-print Loop (figure 1.1) Initialization of data structures Then: while(true) { read expression if “quit” then break (and exit interpreter) evaluate expression print expression }

©2001 Joel Jones Reader (figure 1.2, 1.3, 1.4) Superclass with some general functions –e.g. printPrimaryPrompt, skipSpaces, etc. Subclassed (potentially) for every language –virtual Expression * readExpression(); Public interface just a single function: –Expression * promptAndRead()

©2001 Joel Jones Environment (figures 1.5, 1.6, 1.7) Several public methods –Constructor: Environment(ListNode *, ListNode *, Environment *); –Testing: virtual Environment * isEnvironment(); –Accessing: Expression * lookup(Symbol *); void add(Symbol *, Expression *); void set(Symbol *, Expression *); –Memory Management: virtual void free(); class Env : public Expr

©2001 Joel Jones Environment (figure 1.6, 1.7) Uses parallel lists –nameit—list of Symbols –valueit—list of Expressions

©2001 Joel Jones Expressions (figure 1.8) Superclass at top of extensive hierarchy –Expression Integer Symbol List Function –DefineStatement »IfStatement »… »BinaryFunction »UserFunction

©2001 Joel Jones Expression (figures 1.9–1.11) To determine specific subclass –uses isFoo functions e.g. isInteger(), isSymbol(), etc. To evaluate a function –virtual void eval(Expr &, Environment *, Environment) Expr uses “smart pointers” for memory management –overload “=“ –reference counting

©2001 Joel Jones IntegerExpression Constructor takes int Overloads isInteger() to return the current object Pair Up: Write IntegerExpression * isInteger();

©2001 Joel Jones Reading & Questions for Next Class Rest of Interpreter Handout