MIRAGE A Graphical Sketching Language Columbia University COMS W4115 Programming Languages and Translators Fall 2006 Prof Stephen Edwards Team Members Abhilash I ai2160 columbia edu Ming Liao ml2288 columbia edu Nalini Vasudevan nv2144 columbia edu Peili Zhang pz2128 columbia edu Introduction Main Objective Motivation Develop a simple elegant but powerful graphical language Provide C like syntax with Logo drawing features Features Easy to read write and learn beginners Educational purposes To draw Teach and inspire programming beginners Teach most basic computer science concepts Simple 2D graphs Fractals Space filling curves dragon curve hilbert curve koch curve etc Animations Handling image files and I O Mirage Tutorial Basics 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 while Keywords 23 in total if return main up lft color load else break void down rgt thick save while for int fwd bwd speed eraseon reset eraseoff Graphics Drawing Statements Graphics Motion fwd dist bwd dist lft degrees rgt degrees Simple Example main 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 ColorfulBall jpg curve angle offset in percentage Implementation Inside Mirage Interpreter Walk only once Mirage Source code Output All functions defined before hand Lexer Painter Parser Interpreter Walker Symbol Table Exception Control flow main 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 flower jpg save flower jpg Save pointer to each of these and walk them as necessary for for expr for expr for expr Body Scoping o C like void main int a int b a 5 int c Allowed b 5 a 6 OK b 6 Error b not visible New symbol table inserted Hstack Hashtable Nxt ptr Hstack Hashtable Nxt ptr Hstack Hashtable Nxt ptr Hstack Hashtable Nxt ptr Functions Pass by value Return type void or int Recursion Hstack Hstack Hstack Hashtable Hashtable Hashtable Nxt ptr Nxt ptr Nxt ptr Pointer to the previous activation record Function 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 DEMO Statistics File No of lines MirageParserLexer g 156 MirageWalker g 110 HStack java 37 Env java 68 MirageFunction java 91 ActivationRecord java 19 MirageDisplay java 156 MirageApp java 121 MirageMain java 27 Total 785 Conclusion Lessons Learned Questions Guaranteed Answers are not
View Full Document
Unlocking...