Interpreter for ZOOMI Andrew Deren Initial Presentation SE

  • Slides: 18
Download presentation
Interpreter for ZOOM-I Andrew Deren Initial Presentation - SE 690 5/30/03 http: //www. adersoftware.

Interpreter for ZOOM-I Andrew Deren Initial Presentation - SE 690 5/30/03 http: //www. adersoftware. com/se 690/

What is ZOOM? n n n ZOOM is a set of tools and notation

What is ZOOM? n n n ZOOM is a set of tools and notation specifications used for development of large scale Object-Oriented systems. ZOOM stands for Z-based Object Oriented Modeling The ZOOM Project is supervised by Dr. Jia

Part of Zoom n n There are 3 parts of ZOOM: ZOOM-D – design

Part of Zoom n n There are 3 parts of ZOOM: ZOOM-D – design notation ¡ n ZOOM-S – specification notation ¡ n Formal notation to specify design models: object design models and user interface design. Formal notation to describe the use cases with formally specified preconditions and postconditions. ZOOM-I – implementation language ¡ ¡ ¡ Can be any object-oriented language: Java, C++, etc Currently work is done on extending Java. Language will be extended with zoom specific features, but parts of the software system can be developed in target language.

What is Interpreter? n n An interpreter is a program that accepts any program

What is Interpreter? n n An interpreter is a program that accepts any program (the source program) expressed in a particular language (the source language), and runs that source program immediately. The interpreter does not translate the source program into object code prior to execution.

Why Write Interpreter? n n Easier to test programs, no need to recompile. Can

Why Write Interpreter? n n Easier to test programs, no need to recompile. Can test fragments of code. Changes to design of ZOOM language are easier to test in interpreter. Some features of ZOOM might be hard to translate to java code directly. Interpreters are much easier to implement than compilers.

Programming Language Lifecycle Model Can be implemented as Interpreter to test language features

Programming Language Lifecycle Model Can be implemented as Interpreter to test language features

Features different from Java n n n Enumerations Const Type definitions Generics Language support

Features different from Java n n n Enumerations Const Type definitions Generics Language support for Sets/Lists/Relations Foreach statement

Enumerations n n enum States { AL, CA, IL, NY, MA}; Better type-safety than

Enumerations n n enum States { AL, CA, IL, NY, MA}; Better type-safety than int or String. Can only use valid values and is enforced by compiler at compile time.

Const & Type definitions n const int PI = 3. 141592653 n Nicer syntax

Const & Type definitions n const int PI = 3. 141592653 n Nicer syntax for: static final int PI = 3. 141592653 n typedef Small. Int = 0. . 100 typedef Course. Set = {Course} n

Generics n class Hashtable<Key, Value> n Provides type safety for collections and other types

Generics n class Hashtable<Key, Value> n Provides type safety for collections and other types No longer casts needed to cast back to object n

Sets/Lists n n n n Build in support for list and set construction list

Sets/Lists n n n n Build in support for list and set construction list = [1. . 10] // list with 10 elements 1 to 10 list = [1, 2, 3, 4] list = [int x: x > 0 & x < 5 @ x * 2] Similar syntax for set creation, but uses { instead of [ Build in operators for list and set operations: Union, intersection, cardinality, membership tests, etc. boolean in. List = x in list;

Foreach n New addition to the language n foreach (Type x in Expression) n

Foreach n New addition to the language n foreach (Type x in Expression) n Expression must result in typesafe iterator.

Interpreter Features n n n Integrated into zoom IDE Syntax highlight and other nice

Interpreter Features n n n Integrated into zoom IDE Syntax highlight and other nice editor features Run zoom code directly from IDE with statement step through, variable evaluation, etc.

Interpreter Architecture n n 1. Program text is fetched to ZOOM Parser which builds

Interpreter Architecture n n 1. Program text is fetched to ZOOM Parser which builds AST nodes. 2. AST nodes are transformed into language elements (Statements, Expressions, etc) 3. Type checker checks type validity of the program. 4. Interpreter walks AST evaluating statements and expressions.

Interpreter Architecture n n n Operates on AST elements (expressions, statements, etc) Val. Interpreter

Interpreter Architecture n n n Operates on AST elements (expressions, statements, etc) Val. Interpreter runtime system holds all data in objects derived from Val int Each Val type knows how int to interact with other Val int types and supports all operators that can be performed by that type Val. Set Val. List Val. String . . . x = 3; // creates Val. Int y = 4; // created Val. Int z = x + y; // calls x. operator_plus(y)

Status n n Currently interpreter can be used in command line mode, or as

Status n n Currently interpreter can be used in command line mode, or as swing application. Most operators, expressions and statements are functional for primitive types, sets and lists, but no objectoriented features yet.

References n n David A. Watt & Deryck F. Brown. Programming Language Processors in

References n n David A. Watt & Deryck F. Brown. Programming Language Processors in Java. Prentice Hall, 2000. Alfred V. Aho, Ravi Sethi, Jeffrey D. Ullman. Compilers: Principles, Techniques and Tools. Addison-Wesley, 1988. Ravi Sethi. Programming Languages, Concepts & Constructs. Addison-Wesley, 1996 Randy M. Kaplan. Constructing Language Processors for Little Languages. John Wiley & Sons, Inc. , 1994

Questions? n

Questions? n