MIRAGEA Graphical Sketching LanguageA Graphical Sketching LanguageColumbia UniversityCOMS W4115 Programming Languages and TranslatorsFall 2006Prof. Stephen EdwardsTeam Members:Abhilash I [email protected] Liao [email protected] Vasudevan [email protected] Zhang [email protected] Main Objective Develop a simple, elegant but powerful graphical language Motivation Provide C like syntax with Logo drawing features Features Easy to read, write and learn – beginners Educational purposes Teach and inspire programming beginners Teach most basic computer science concepts To draw Simple 2D graphs Fractals, Space filling curves: dragon curve, hilbert curve, koch curve, etc. Animations Handling image files and I/OMirage TutorialBasics Types int - 32 bit integer void - used for functions without return values String constants - For filenames, Eg. save “img.jpg” Control statements if-else, for, whileKeywords - 23 in totalif else while forreturn breakmain void int up down fwd bwd lft rgtcolor thick speed resetload save eraseon eraseoffGraphics Drawing Statements Graphics Motion fwd dist; bwd dist; lft degrees; rgt degrees; Simple Examplemain(){fwd 50;rgt 90;fwd 50;rgt 90;fwd 50;rgt 90;fwd 50;}More Graphics Pen State up; down; thick val; speed val; reset; eraseon; eraseoff; color <R, G, B>; Curves curve <angle, offset in percentage>; ColorfulBall.jpgImplementationInside Mirage Interpreter Walk only once All functions defined before handMirage Source codeInterpreterParserLexerWalkerSymbol TableExceptionPainterOutputControl flowmain(){int a=5, c=90, i=1;/* Define the shape of line: Half Cycle */ curve <90,0>;for(i=0; i<50; i=i+1){color <255-2*i,100+2*i,0>;thick i/3;rgt c;fwd a*i;}save "flower.jpg";}flower.jpgforfor_expr for_expr for_expr BodySave pointer to each of these and walk them as necessaryScopingo C likevoid main(){int a;{ int b;a=5;int c; /*Allowed*/b=5;}a = 6; /*OK*/b = 6; /*Error: b not visible*/}HstackHashtable{}Nxt_ptrHstackHashtable{}Nxt_ptrHstackHashtable{}Nxt_ptrHstackHashtable{}Nxt_ptrNew symbol table insertedFunctions Pass by value Return type – void or int RecursionHstackHashtable{}Nxt_ptrHstackHashtable{}Nxt_ptrPointer to the previous activation recordHstackHashtable{}Nxt_ptrFunction example /* dragon.mrg */ void dragon(int n, int a, int h) { if(n < 1) { fwd h; return; } dragon (n - 1, 90, h); rgt a; dragon (n - 1, -90, h); } main() { color <180, 0, 0>; dragon( 11, 90, 6); save "dragon.jpg"; }DEMOStatistics785Total27MirageMain.java121MirageApp.java156MirageDisplay.java19ActivationRecord.java91MirageFunction.java68Env.java37HStack.java110MirageWalker.g156MirageParserLexer.gNo. of linesFileConclusion Lessons LearnedQuestions GuaranteedAnswers are
View Full Document