Ezgraphs
This presentation is the property of its rightful owner.
Sponsored Links
1 / 16

EZGraphs PowerPoint PPT Presentation


  • 57 Views
  • Uploaded on
  • Presentation posted in: General

EZGraphs. Vincent [email protected] Edlira [email protected] A graphs and charts generating language. COMS W4115: Programming Languages and Translators Spring 2007. Introduction. Why graphs?

Download Presentation

EZGraphs

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Ezgraphs

EZGraphs

Vincent [email protected]

Edlira [email protected]

A graphs and charts generating language

COMS W4115: Programming Languages and Translators

Spring 2007


Introduction

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.


Ezgraphs

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.


Features cont d

Features (cont’d)

  • 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.


Features cont d1

Features(cont’d)

  • 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.


Features cont d2

Features(cont’d)

  • 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()


Example 1 recursion

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 = (x2+x1) / 2;

int yp1 = (y2+y1) / 2;

int xp2 = (x3+x2) / 2;

int yp2 = (y3+y2) / 2;

int xp3 = (x1+x3) / 2;

int yp3 = (y1+y3) / 2;

if (level < 8) {

triangles(x1, y1, xp1, yp1, xp3, yp3, level+1);

triangles(xp1, yp1, x2, y2, xp2, yp2, level+1);

triangles(xp3, yp3, xp2, yp2, x3, y3, level+1);

}

}


Example 2 a pie chart

Example 2 - A Pie Chart

/*

* A pie chart illustrating distribution of income.

*/

void main() {

int fields = 7;

/* Colors. */

int[][] c = new int[fields][3];

c[0][0] = 255; c[0][1] = 50; c[0][2] = 0;

c[1][0] = 0; c[1][1] = 255; c[1][2] = 0;

...

c[6][0] = 255; c[6][1] = 255; c[6][2] = 0;

/* Labels. */

string[] l = new string[fields];

l[0] = "Savings";

l[1] = "Insurance";

...

l[6] = "Housing";

/* Percentages. */

int[] p = new int[fields];

p[0] = 9;

p[1] = 11;

...

p[6] = 21;

...


Example 2 a pie chart cont d

Example 2 - A Pie Chart (cont’d)

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 < fields; i++) {

color(c[i][0],c[i][1],c[i][2]);

start += end;

end = p[i] * 360 / 100;

fillArc(0,0,200,200,start,end);

}

show();

}

Output:


Language implementation

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.


Language implementation cont d

Language Implementation (cont’d)

  • 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.ezg:48:10: expecting ID, found '=‘

    • Error: draw.ezg:59:6: unexpected data type being assigned to array

    • Error: recursion.ezg:5:5: function fact(int) expected to return int

    • Error: recursion.ezg:7:16: variable g not declared


  • Architecture

    Architecture


    Interpreter structure

    Interpreter Structure


    Type system

    Type System


    Ezgraphs

    Type Conversions & Operators


    Ezgraphs

    Type Conversions & Operators (cont’d)


  • Login