1 / 19

MDraw Graphics Manipulation Language

MDraw Graphics Manipulation Language. Huimin Sun(hs2740) Dongxiang Yan(dy2224) Jingyu Shi (js4151 ) COMS 4115 Columbia University August 16, 2013. Introduction. 1. A C-like language designed specially for drawing graphics 2. Built-in types: Point, Line, Ellipse, Curve and others

iliana
Download Presentation

MDraw Graphics Manipulation Language

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MDrawGraphics Manipulation Language Huimin Sun(hs2740) Dongxiang Yan(dy2224) Jingyu Shi (js4151) COMS 4115 Columbia University August 16, 2013

  2. Introduction • 1. A C-like language designed specially for drawing graphics • 2. Built-in types: Point, Line, Ellipse, Curve and others • 3. Mdraw is easy to learn and to use • Functionality: • 1. Basic calculation, basic control flow • 2. Drawing graphics using point, line, ellipse, and curve

  3. Tutorial Examples • How to manipulate these built-in types and functions: • Point p1; • p1 = Mpoint( x, y ); /* 2 parameter as the coordinate of the point*/ • Line l1; • l1 = Mline(x1, y1, x2, y2); /* the coordinates of the 2 end point*/ • Curve c1; • c1 = Mcurve(x, y, w, h, angst, angExt); • /*parameters as location, size, angular extents*/ • Ellipse e1; e1 = Mellipse( x, y, w, h ); e1.draw(); p1.draw(); c1.draw();

  4. Tutorial Examples This is a .mdraw file. In basic() , it covers the basic Functionalities. paint() is a drawing function. This file draws a pottery. void basic(){ if(1<2){ print “This is the start!”; } } void paint(){ Ellipse e1; inti; for(i=0; i<20;i=i+1){ e1 = MEllipse(100-5*i, 100+10*i, 100+10*i, 30+5*i); e1.draw(); } Ellipse e2; for (i=0;i<20;i=i+1){ e2 = MEllipse(5+5*i, 290+i*10, 290-10*i,125-5*i); e2.draw(); } }

  5. Examples

  6. Implementation • Project Management • Architecture

  7. Project Management • Scrum methodology • 6 weeks • Milestones • 3 questions

  8. Project Timeline

  9. Architecture

  10. Architecture • Scanner • The scanner is used to tokenize the input source code by using lexical analysis. • Comments, whitespace and other unnecessary tokens will be waived. • If any, Illegal characters will fail the program. • Ocamllex

  11. Architecture • Parser • From the stream of tokens output from the scanner, the parser generates the AST (abstract syntax tree). • Ocamlyacc • Translate • The translate is designed to do semantic checking • The semantic check evaluates the type of a statement. • Exceptions will be thrown.

  12. Architecture • Java Generator • Compile.ml • Translate a program in AST form into a java program. Throw an exception if something is wrong, e.g., a reference to an unknown variable or function

  13. Test • Scanner • Ast

  14. Test • void basic(){ • print (2+3); • }

  15. Scanner VOID ID: basic LEFT_PAREN RIGHT_PAREN LEFT_BRACE PRINT LEFT_PAREN INTLITERAL: 2 PLUS INTLITERAL: 3 RIGHT_PAREN SEMICOLON RIGHT_BRACE

  16. AST PROGRAM:[LIST:[CONSTRUCT_FUNCDEF:[FUNCDECL:[FUNTYPE[TYPE_VOID],FUNNAME[basic],LIST:[],LIST:[STMT_BLOCK:[LIST:[STMT_PRINT:[EXPR_BINOP:[EXPR_LITERAL:[LITERAL_INT:[2]],ADD,EXPR_LITERAL:[LITERAL_INT:[3]]]]]]]]]]]

  17. Test • Print • If • For • While • Arithmetic • Gcd • Fib • Point • Line • Curve • Ellipse

  18. While Test • void basic(){ • inti; • i=10; • while(i>0){print i; i=i-1;} • } Result: 10 9 8 7 6 5 4 3 2 1

  19. Gcd Test • intgcd(int a, int b) { • while (a != b) { • if (a > b) a = a - b; • else b = b - a; • } • return a; • } • void basic() • { • print(gcd(2,14)); • print(gcd(3,15)); • print(gcd(99,121)); • } Result: 2 3 11

More Related