1 / 14

Implementation Design

Implementation Design. Interpreted Dynamic Types Reserved “Library” Distinct Statements Test Suite. Interpreter. Yeah! DruL is an interpreted language. Trying to write a compiler seemed like a waste of energy, since there isn't much concern about performance.

hien
Download Presentation

Implementation Design

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. Implementation Design • Interpreted • Dynamic • Types • Reserved “Library” • Distinct Statements • Test Suite

  2. Interpreter • Yeah! DruL is an interpreted language. • Trying to write a compiler seemed like a waste of energy, since there isn't much concern about performance. • Of course complex calculations are possible in DruL, however not an intended use of language. • The interpreter was named drul; makes sense.

  3. drul Input • 'drul' can work as no argument command in which it acts like an inline interpreter, accepting input from std in. • 'drul' can also take filename as an argument and interpret the contents of the file. • The extension for the file doesn't matter, as our platform is UNIX based, all 'drul' cares about is the code inside the file.

  4. drul output • 'drul' can produce output to the std out (may be useful for debugging purposes)‏ • 'drul' also outputs to the files, using a method named output. • MIDI , Text and pdf(Lily pond) are three output formats for the output files. • The above mentioned files are created if they don't exist, with the name specified by 'output' method.

  5. Dynamic Language • Dynamic everything! • Hence, no static checks. • Did mean to add the easy checks. • DruL types map very easily to Ocaml types. • Therefore they were reasonably easy to define. • Both types and scoping are dynamic.

  6. a = 345 ; print(a); a = pattern(“010101”); print(a); mapper a (c){ if(c.note( )){return pattern(“ ”);} else { return pattern(“0”);}} b = map(pattern(“010”)) a; Dynamic Types Demonstration

  7. type drul_t = Void | Int of int | Str of string | Bool of bool | Pattern of pattern | Clip of pattern array | Mapper of (string * string list * statement list)‏ | PatternAlias of pattern_alias | Beat of pattern_alias * int | Instruments of string list | InstrumentAssignment of string * pattern DruL Types

  8. Strict Syntax Tree • There is mutual recursion among maps, expressions and statements. • Above three are main part of the AST. • We do have distinct operator types for boolean, integer and comparison in AST, which are used by expressions. • We do tag expressions with an int 'lineno' , so we can give a line number to user with the errors in code.

  9. Keywords, Functions and Methods • Reasonably small set of keywords. • Very helpful built in functions. • Different methods for different DruL types. • Function and method names can be used as identifiers for variables, but it is advised to avoid it for it will cause confusion.

  10. Helper Functions • Lots of helpers. • Most useful when constructing the framework for maps. • Also used for updating symbol table and also for clips. • There are helpers for every functionality we implemented; effort to modularize the code.

  11. Statements? • Distinct types of statements • Perhaps because of restrictions on expressions. • Types: Expression, Assignment, Selection, Mapper definitions, return and (Instr Def?)‏ • Blocks are not statements in DruL.

  12. Test Suite • Testing software was written in python by Thierry Bertin-Mahieux. • Yes, we do use our own test program:)‏ • Wrote tests on the language feature that got implemented, on the way. • There are tests on parser as well. • Implemented feature; wrote test; saw it fail; fixed the code; NICE ALGORITHM:)‏

  13. Implementation Time line? • Started with AST ( accepting professor's advice)‏ • Got the scanner in parallel to the AST. • Finished(?) parser pretty quickly. • Had hello world ready; arithmetic and logic very soon after. • Another comment on similarity towards micro C :)‏

  14. Time Line continued... • After the basics, the work was done in parallel mostly. • Along the way there were several changes in the AST, Scanner and Parser. • Mapper was being worked on while functions and methods were added to the language. • In the end the clips and the file outputs were added to the language; And here we are....

More Related