EZGraphs - PowerPoint PPT Presentation

About This Presentation
Title:

EZGraphs

Description:

Provide a language that can be used to create charts and graphs, targeting those ... Non-cryptic and informative error messages make it easy to use and debug. ... – PowerPoint PPT presentation

Number of Views:30
Avg rating:3.0/5.0
Slides: 17
Provided by: edlirak
Category:
Tags: cryptic | ezgraphs

less

Transcript and Presenter's Notes

Title: EZGraphs


1
EZGraphs
  • A graphs and charts generating language

Vincent Dobrev vd2006_at_columbia.edu Edlira
Kumbarce ek2248_at_columbia.edu
COMS W4115 Programming Languages and
Translators Spring 2007
2
Introduction
  • Why graphs?
  • Graphs are used widely. They communicate
    information more easily and efficiently than
    words or tables.
  • Objective
  • Provide a language that can be used to create
    charts and graphs, targeting those with a little
    prior programming experience.

3
Features
  • User-Friendly Syntax
  • Very similar to C and Java. Intuitive keywords
    and internal function names. More organized than
    Ploticus.
  • Easy Debugging
  • Non-cryptic and informative error messages make
    it easy to use and debug. User given exact
    location of error with file name and line and
    column numbers.

4
Features (contd)
  • Portability
  • Based on Java, so it only depends on the
    presence of the Java Runtime Environment.
  • Data Types Operators
  • Supports boolean, integer, floating-point, and
    string data types, as well as multi-dimensional
    arrays.

5
Features (contd)
  • File Inclusion
  • Allows code reuse and modularity. More organized
    programs.
  • Control Flow Statements
  • Supports conditionals (if-then-else) and
    iterative statements (loops), which in turn
    enable user to create recursive functions.

6
Features (contd)
  • Pre-Defined Functions
  • Drawing point(), line(), polygon(), etc.
  • Transfromation translate(), scale(), shear()
    etc.
  • Data Acquiring data()
  • Math exp(), log(), pow(), sqrt(), etc.
  • Auxiliary strToInt(), strToFloat(), substring(),
    size(), etc.
  • Output print(), println() , save(), show()

7
Example 1 - Recursion
/ Sierpinski Triangle. / void main()
canvas(600, 600) scale(1, -1)
translate(0, -600) triangles(50, 50, 550,
50, 300, 550, 1) show() void
triangles(int x1, int y1, int x2, int y2,
int x3, int y3, int level) line(x1, y1, x2,
y2) line(x2, y2, x3, y3) line(x3, y3,
x1, y1) int xp1 (x2x1) / 2 int yp1
(y2y1) / 2 int xp2 (x3x2) / 2 int
yp2 (y3y2) / 2 int xp3 (x1x3) / 2
int yp3 (y1y3) / 2 if (level lt 8)
triangles(x1, y1, xp1, yp1, xp3, yp3,
level1) triangles(xp1, yp1, x2, y2,
xp2, yp2, level1) triangles(xp3, yp3,
xp2, yp2, x3, y3, level1)
8
Example 2 - A Pie Chart
/ A pie chart illustrating distribution of
income. / void main() int fields 7
/ Colors. / int c new
intfields3 c00 255 c01 50
c02 0 c10 0 c11 255
c12 0 ... c60 255
c61 255 c62 0 / Labels. /
string l new stringfields l0
"Savings" l1 "Insurance" ...
l6 "Housing" / Percentages. /
int p new intfields p0 9 p1
11 ... p6 21 ...
9
Example 2 - A Pie Chart (contd)
canvas(400,400) background(244,244,244)
string title "Income Distribution"
font("Arial", 0, 20) int width
width(title) text(title, 200 - width/2,
40) stroke(2) line(50,50,350,50)
translate(100,100) int start 0, end 0
for (int i 0 i lt fields i)
color(ci0,ci1,ci2) start
end end pi 360 / 100
fillArc(0,0,200,200,start,end)
show()
Output
10
Language Implementation
  • The source code is parsed and executed right away
    with no intermediate code.
  • Programs reside in .ezg files, with one file
    containing a main() function and any number of
    other .ezg files containing other functions.

11
Language Implementation (contd)
  • Three types of output
  • Text in the console
  • An image in a window on-screen
  • An image in a file
  • Exception handling mechanism catches, formats,
  • and prints out error messages for the user.
  • Examples
  • Error draw.ezg4810 expecting ID, found '
  • Error draw.ezg596 unexpected data type being
    assigned to array
  • Error recursion.ezg55 function fact(int)
    expected to return int
  • Error recursion.ezg716 variable g not declared

12
Architecture
13
Interpreter Structure
14
Type System
15
Type Conversions Operators
16
Type Conversions Operators (contd)
Write a Comment
User Comments (0)
About PowerShow.com