presentation1

Download Report

Transcript presentation1

Interpreter for ZOOM-I
Andrew Deren
Initial Presentation - SE690
5/30/03
http://www.adersoftware.com/se690/
What is ZOOM?



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


There are 3 parts of ZOOM:
ZOOM-D – design notation


ZOOM-S – specification notation


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?


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?




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
Features different from Java






Enumerations
Const
Type definitions
Generics
Language support for
Sets/Lists/Relations
Foreach statement
Enumerations


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

const int PI = 3.141592653

Nicer syntax for: static final int PI =
3.141592653

typedef SmallInt = 0 .. 100
typedef CourseSet = {Course}

Generics

class Hashtable<Key, Value>

Provides type safety for collections
and other types
No longer casts needed to cast back to
object

Sets/Lists

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 inList = x in list;
Foreach

New addition to the language

foreach (Type x in Expression)

Expression must result in typesafe
iterator.
Interpreter Features



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
Source Code

Text
Parser

AST Nodes
AST Builder

ZOOM Module

Interpreter
Output
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



Operates on AST
elements (expressions,
statements, etc)
ValInt
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
ValSet
ValList
ValString
...
x = 3;
// creates ValInt
y = 4;
// created ValInt
z = x + y;
// calls x.operator_plus(y)
Status


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




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?
