EMDL Extended Motion Description Language. EMDL vs. MDL.

40
eMDL Extended Motion Description Language
  • date post

    22-Dec-2015
  • Category

    Documents

  • view

    233
  • download

    0

Transcript of EMDL Extended Motion Description Language. EMDL vs. MDL.

Page 1: EMDL Extended Motion Description Language. EMDL vs. MDL.

eMDL

Extended Motion Description Language

Page 2: EMDL Extended Motion Description Language. EMDL vs. MDL.

EMDL vs. MDL

Page 3: 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]

Page 4: EMDL Extended Motion Description Language. EMDL vs. MDL.

EMDL

– Simple– Object Oriented– Robust– Supports Animation

Page 5: EMDL Extended Motion Description Language. EMDL vs. MDL.

Sample Syntax# delcare filenamefilename 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 <0,50,0>; 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;}

Page 6: EMDL Extended Motion Description Language. EMDL vs. MDL.

Sample Syntax (2)# main body

set sphere1 as sphere <150,150,150,50>;

set sphere2 as sphere <100,100,100,100>;

set sphere3 as sphere <100,100,100,100>;

hide sphere2;hide sphere3;save; funct ears;repeat <2>{funct moveout;};repeat <2>{funct moveback;};repeat <2>{funct movesideways;};repeat <2>{funct moveup;};

Page 7: EMDL Extended Motion Description Language. EMDL vs. MDL.

Output

Page 8: EMDL Extended Motion Description Language. EMDL vs. MDL.

Output

Page 9: EMDL Extended Motion Description Language. EMDL vs. MDL.

Output

Page 10: EMDL Extended Motion Description Language. EMDL vs. MDL.

Output

Page 11: EMDL Extended Motion Description Language. EMDL vs. MDL.

Output

Page 12: EMDL Extended Motion Description Language. EMDL vs. MDL.

Output

Page 13: EMDL Extended Motion Description Language. EMDL vs. MDL.

Output

Page 14: EMDL Extended Motion Description Language. EMDL vs. MDL.

Output

Page 15: EMDL Extended Motion Description Language. EMDL vs. MDL.

Output

Page 16: EMDL Extended Motion Description Language. EMDL vs. MDL.

Output

Page 17: EMDL Extended Motion Description Language. EMDL vs. MDL.

Structure of eMDL

• Filename Specification• Function Declarations• Variable Declarations• Main Body

Page 18: EMDL Extended Motion Description Language. EMDL vs. MDL.

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.

Page 19: EMDL Extended Motion Description Language. EMDL vs. MDL.

Filename Specification (2)

• Example :filename mdlTest;

• Will result in all outputted MDL files named mdlTest<number>.mdl

• <number> is enumerated based on how many times the save function was called in the code.

Page 20: EMDL Extended Motion Description Language. EMDL vs. MDL.

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.

Page 21: EMDL Extended Motion Description Language. EMDL vs. MDL.

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.

Page 22: EMDL Extended Motion Description Language. EMDL vs. MDL.

Function Declarations (3)

• Example :function move50 {

repeat <3> { move sphere1 <0, 50, 0>; move box2 <0, -50, 0>;

save; }

}

Page 23: EMDL Extended Motion Description Language. EMDL vs. MDL.

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.

Page 24: EMDL Extended Motion Description Language. EMDL vs. MDL.

Variable Types

• Integerset <name> as integer <value>

• Boxset <name> as box <x, y, z, dx, dy, dz>

• Lineset <name> as line <x, y, z, x2, y2, z2>

• Sphereset <name> as sphere <x, y, z, r>

• Torusset <name> as torus <x, y, z, r, R>

Page 25: EMDL Extended Motion Description Language. EMDL vs. MDL.

Main Body

• This is where the actual graphic manipulations occur

• Any variable declared previously can be changed and moved

Page 26: EMDL Extended Motion Description Language. EMDL vs. MDL.

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

Page 27: EMDL Extended Motion Description Language. EMDL vs. MDL.

Details of our Compiler

Page 28: EMDL Extended Motion Description Language. EMDL vs. MDL.

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)

Page 29: EMDL Extended Motion Description Language. EMDL vs. MDL.

How We Implemented Our Compiler

Page 30: EMDL Extended Motion Description Language. EMDL vs. MDL.

emdlLexer

• Lexer splits emdl code into tokens.• Some common tokens are:

– INT– ID, which can be variable names and

function names.

Page 31: EMDL Extended Motion Description Language. EMDL vs. MDL.

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.

Page 32: EMDL Extended Motion Description Language. EMDL vs. MDL.

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.

Page 33: EMDL Extended Motion Description Language. EMDL vs. MDL.

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.

Page 34: EMDL Extended Motion Description Language. EMDL vs. MDL.

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.

Page 35: EMDL Extended Motion Description Language. EMDL vs. MDL.

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.

Page 36: EMDL Extended Motion Description Language. EMDL vs. MDL.

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.

Page 37: EMDL Extended Motion Description Language. EMDL vs. MDL.

Testing

• Tested during and after development.

Page 38: EMDL Extended Motion Description Language. EMDL vs. MDL.

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.

Page 39: EMDL Extended Motion Description Language. EMDL vs. MDL.

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.

Page 40: EMDL Extended Motion Description Language. EMDL vs. MDL.

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.