EMDL Extended Motion Description Language. EMDL vs. MDL.

Slides:



Advertisements
Similar presentations
Chapter 11 Introduction to Programming in C
Advertisements

CPSC 388 – Compiler Design and Construction
Introduction To Compilers And Phase 1 Inside a compiler. Inside a C-- compiler. The compilation process. Example C-- code. Extended Backus-Naur.
SYSTEM PROGRAMMING & SYSTEM ADMINISTRATION
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 7: User-Defined Functions II.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 7: User-Defined Functions II.
Chapter 7: User-Defined Functions II
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 7: User-Defined Functions II.
Chapter 7: User-Defined Functions II Instructor: Mohammad Mojaddam.
CPSC Compiler Tutorial 9 Review of Compiler.
WPSM Programming Language A simple language that transform simple data structure into complex xML format Wai Y. Wong Peter Chen Seema Gupta Miqdad Mohammed.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
1 CSC241: Object Oriented Programming Lecture No 07.
CSC 8310 Programming Languages Meeting 2 September 2/3, 2014.
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
Operator Precedence First the contents of all parentheses are evaluated beginning with the innermost set of parenthesis. Second all multiplications, divisions,
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
1 Programming Languages Tevfik Koşar Lecture - II January 19 th, 2006.
C Functions Programmer-defined functions – Functions written by the programmer to define specific tasks. Functions are invoked by a function call. The.
Chapter 06 (Part I) Functions and an Introduction to Recursion.
History of C 1950 – FORTRAN (Formula Translator) 1959 – COBOL (Common Business Oriented Language) 1971 – Pascal Between Ada.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition, Fifth Edition Chapter 7: User-Defined Functions II.
Introduction to Programming Using C Modularity. 2 Contents Modularity Functions Preprocessor Comments Global variables.
/* Documentations */ Pre process / Linking statements Global declarations; main( ) { Local Declarations; Program statements / Executable statements; }
Oct 15, 2007Sprenkle - CS1111 Objectives Creating your own functions.
Tuc Goodwin  Object and Component-Oriented Programming  Classes in C#  Scope and Accessibility  Methods and Properties  Nested.
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
Algorithms  Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved X1 Chapter 3 Control Statements.
CPS 506 Comparative Programming Languages Syntax Specification.
Introduction to Lexical Analysis and the Flex Tool. © Allan C. Milne Abertay University v
CS536 Semantic Analysis Introduction with Emphasis on Name Analysis 1.
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
1 Chapter Four Creating and Using Classes. 2 Objectives Learn about class concepts How to create a class from which objects can be instantiated Learn.
Muhammad Idrees, Lecturer University of Lahore 1 Top-Down Parsing Top down parsing can be viewed as an attempt to find a leftmost derivation for an input.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Introduction to Object-Oriented Programming Lesson 2.
User-Defined Functions II TK1914: C++ Programming.
Functions Math library functions Function definition Function invocation Argument passing Scope of an variable Programming 1 DCT 1033.
Functions  A Function is a self contained block of one or more statements or a sub program which is designed for a particular task is called functions.
Programming Fundamentals. Topics to be covered Today Recursion Inline Functions Scope and Storage Class A simple class Constructor Destructor.
Classes, Interfaces and Packages
C H A P T E R T W O Linking Syntax And Semantics Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
More yacc. What is yacc – Tool to produce a parser given a grammar – YACC (Yet Another Compiler Compiler) is a program designed to compile a LALR(1) grammar.
SEQUENTIAL AND OBJECT ORIENTED PROGRAMMING Arrays.
Department of Electronic & Electrical Engineering Statements Blocks{} Semicolons ; Variables Names keywords Scope.
Overview of Compilation Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Principles Lecture 2.
Programming Fundamentals Enumerations and Functions.
Presentation By :- Nikhil R. Anande ( ) Electronic & Communication Engineering. 3 nd Year / 5 th Semester FACULTY GUIDE : RAHIUL PATEL SIR MICROCONTROLLER.
Defining Data Types in C++ Part 2: classes. Quick review of OOP Object: combination of: –data structures (describe object attributes) –functions (describe.
©2004 Joel Jones 1 CS 403: Programming Languages Lecture 3 Fall 2004 Department of Computer Science University of Alabama Joel Jones.
Introduction to Classes and Objects CS-2303, C-Term C++ Program Structure Typical C++ Programs consist of:– main –A function main –One or more classes.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
Chapter 7: User-Defined Functions II
Java Primer 1: Types, Classes and Operators
Algorithms Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Chapter 5 Classes.
Introduction to C Topics Compilation Using the gcc Compiler
Chapter 3 Control Statements Lecturer: Mrs Rohani Hassan
Lecture 15 (Notes by P. N. Hilfinger and R. Bodik)
Chapter 7: User-Defined Functions II
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
Defining Classes and Methods
Defining Classes and Methods
Classes and Objects Systems Programming.
C++ Object Oriented 1.
Presentation transcript:

eMDL Extended Motion Description Language

EMDL vs. MDL

MDL classic Syntax: –line x1, y1, z1, x2, y2, z2 –Box x, y, z, dx, dy, dz –sphere x, y, z, r –move x, y, z [knob]

EMDL –Simple –Object Oriented –Robust –Supports Animation

Sample Syntax # delcare filename filename sample_syntax; # fucntion definiitions function ears { sphere2=sphere1; sphere3=sphere1; sphere2.r=sphere1.r/2; sphere3.r=sphere1.r/2; save; } function moveout { move sphere3 ; sphere2.y=sphere2.y-50; save; } #more function definitions function moveback { sphere3.y=sphere3.y-50; sphere2.y=sphere2.y+50; save; } function movesideways { sphere3.x=sphere3.x-50; sphere2.x=sphere2.x+50; save; } function moveup { sphere3.y=sphere3.y-50; sphere2.y=sphere2.y-50; save; }

Sample Syntax (2) # main body set sphere1 as sphere ; set sphere2 as sphere ; set sphere3 as sphere ; hide sphere2; hide sphere3; save; funct ears; repeat {funct moveout;}; repeat {funct moveback;}; repeat {funct movesideways;}; repeat {funct moveup;};

Output

Structure of eMDL Filename Specification Function Declarations Variable Declarations Main Body

Filename Specification Allows users to chose the filename for all MDL files that will be output Must be the first line of the eMDL script Optional : if not included, then the program will default to outputting tmp.mdl files.

Filename Specification (2) Example : filename mdlTest; Will result in all outputted MDL files named mdlTest.mdl is enumerated based on how many times the save function was called in the code.

Function Declarations If you want to create any functions, they must be declared and defined in the second section. eMDL supports macro style functions with no parameters Every function must have a unique identifier.

Function Declarations (2) Function declarations consist of the keyword “function” followed by the identifying name The function body is enclosed in curly braces and can contain of any combination of pre or user defined functions, assignments, or repeat clauses.

Function Declarations (3) Example : function move50 { repeat { move sphere1 ; move box2 ; save; }

Variable Declarations Must occur between the function declarations and the main body All variables have a global scope. Each variable must have its own unique identifier. Five types of variables.

Variable Types Integer set as integer Box set as box Line set as line Sphere set as sphere Torus set as torus

Main Body This is where the actual graphic manipulations occur Any variable declared previously can be changed and moved

Main Body (2) Users may: –Utilize assignment statements –Call predefined functions –Call user defined functions –Create repeat blocks –Remove a variable –Save the current state to an MDL file

Details of our Compiler

Lexer – splits code into tokens. Parser – creates an AST. TreeWalker – generates mdl Code mdlParser – mdl Parser generates gif images. (compiled in C)

How We Implemented Our Compiler

emdlLexer Lexer splits emdl code into tokens. Some common tokens are: –INT –ID, which can be variable names and function names.

emdlParser Parser makes an Abstract Syntax Tree out of the stream of tokens that the Lexer outputs. –Syntax is checked here. –The AST is designed and created here in the most efficient way for static semantic analysis to take place.

emdlTreeWalker TreeWalker performs the static semantic analysis, as well as the code generation. A linked list is created to hold all global variables. The object in linked list knows what type of object the variable is, and all of its parameters.

emdlTreeWalker A copy of the AST is made before we walk through the function declarations. This is to facilitate function calls. Each function call creates a copy of the this tree and call a treeWalker function on this tree. Since our functions act like macros, the function body is just a sequential continuation of our code.

mdlParser mdlParser is a binary executable that is compiled in C. It asks the user for the names of an mdl file, and the name of the image file to be created. It then outputs an image file for the given mdl file.

Comparison between emdl and mdl One of the main reasons for the creation of this language was to extend mdl so that we could make the coding tighter and cleaner. For the demo you had seen earlier, one emdl file created 9 separate mdl files, which created 9 separate image files.

Comparison between eMDL and mdl Now if we had wanted to run the same animation, but with the two outside spheres being farther away from the interior sphere, I would only need to change on line in emdl. But to do the same change in mdl would require us to modify all 9 of the mdl files that created this animation.

Testing Tested during and after development.

During Development Ran two test files when each new functionality was implemented. –One that ought to work –One that ought not and give errors Didn’t always include all possible formations of newly implemented statements.

After Development Created suite of test cases –Tested all legal formations of statements. –Tested for what we predicted to be common syntactic and semantic mistakes.

Lessons Learned Compilers are harder to make than you might think. Perpetual debugging and error- checking, since errors can and did crop up in the simplest functions.