An Interpreter for Zoom Language - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

An Interpreter for Zoom Language

Description:

... { white, red, yellow, green, blue, brown, black }; Color.name ... Randy M. Kaplan. Constructing Language Processors for Little Languages. John Wiley & Sons, Inc. ... – PowerPoint PPT presentation

Number of Views:69
Avg rating:3.0/5.0
Slides: 14
Provided by: andrew136
Category:

less

Transcript and Presenter's Notes

Title: An Interpreter for Zoom Language


1
An Interpreter for Zoom Language
  • Andrew Deren
  • Sam Chen
  • Lizhang Qin
  • Hongming Liu

2
4 modes of execution
  • Command line
  • Can execute jzoom files containing execute or
    eval statements
  • Zoom console
  • - expression evaluation and loading from file
  • GUI interface
  • - interactive zoom program evaluation
  • Programming API
  • - used by other zoom tools to execute zoom
    programs or fragments of programs

3
Execute Eval Statements
  • execute eval
  • import declaration
  • enum declaration
  • typedef declaration
  • statements

4
Execute Entire Program
  • Can execute entire program.
  • Looks for class with public static void
    Main(String args) just like java

5
Collection Classes
  • Supports all syntax for collection classes
  • Set, List, OrderedSet, Relation, Bag, Map
  • Build in operators and construction of Set and
    List
  • List list int x x 5 x
  • int listsize list
  • boolean hasit 36 in list
  • Set set 1 .. 10
  • int second set1
  • Tuple a (1, One, Jeden, Odin)
  • int first a.first

6
(No Transcript)
7
Extended Types Operations
  • Can use enum and typedef
  • Built in functions head, tail, front, last,
    toChar
  • Special interaction functions print, println,
    prompt, alert, confirm
  • Built in all Math functions and constants (do not
    have to use Math.method())

8
Native Types
  • Supports all java native types and operations on
    those types
  • Can instantiate and call methods on java library
    types. Have to specify full package name. Ex
  • java.util.Hashtable ht new java.util.Hashtable(
    )
  • Java interaction done through reflection and all
    types are automatically converted from java
    representation to interpreter representation.

9
Enumerations
  • Enumerations work differently from java 1.5
  • enum Color white, red, yellow, green, blue,
    brown, black
  • Color.name() "Color"
  • Color.first() Color.white
  • Color.last() Color.black
  • Color.count() 7
  • Color0 Color.white
  • Color2 Color.yellow
  • Color2.name "yellow"
  • Color.white.ord 0
  • Color.yellow.name yellow

10
Architecture
  • Does not use virtual machine for interpretation
  • Operates directly on AST (Abstract Syntax Tree)
    nodes
  • Not designed for speed, but for extensibility and
    flexibility

11
Interpreter API
  • Other zoom tools can use interpreter using
    interpreter API
  • Can execute fragments of code (statements,
    expressions or methods)
  • Can persist interpreter state between executions
  • Currently animator tool uses interpreter API
  • Easy to extend and add built in types, functions,
    constants or other functionality.

12
(No Transcript)
13
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.
  • O.G. Kakde. Algorithms for Compiler Design.
    Charles Rivera Media, 2003.
  • Keith D. Cooper Linda Torczon. Engineering a
    Compiler. Morgan Kaufmann, 2004.
Write a Comment
User Comments (0)
About PowerShow.com