stage null language
play

Stage (Null) Language James Lin, Alex Liu, Daniel Maxson, Andre - PowerPoint PPT Presentation

Stage (Null) Language James Lin, Alex Liu, Daniel Maxson, Andre Paiva Motivation START You see a kitten on the street. Take it home Leave it At home, the kitten But it looks so lonely! there mews with hunger. Feed it milk Ignore it


  1. Stage (Null) Language James Lin, Alex Liu, Daniel Maxson, Andre Paiva

  2. Motivation START You see a kitten on the street. Take it home Leave it At home, the kitten But it looks so lonely! there mews with hunger. Feed it milk Ignore it You monster! You can’t do that! It purrs with satisfaction.

  3. SNL is… ● imperative ● dynamically typed ● garbage collected but not… ● free-form ● object-oriented

  4. SNL has… ● int, float, bool, string, and list types ● stages and a next keyword ● functions (called “recipes”) but not… ● pointers ● objects or structs ● for/while loops

  5. Example: GCD start main: x is do gcd to 5, 10 do show to x done constants library recipes stage, variable, and user-defined recipe names assignment recipe application stage and recipe keywords

  6. Example: GCD recipe gcd to x, y: loop: start begin: if x > y if x != y (x is x - y) (next loop) else else (y is y - x) (return x) next begin done done done

  7. Implementation Scanner Parser .snl file AST Analyzer SAST .java Codegen files

  8. Scanning and Parsing ● Standard ocamllex and ocamlyacc ● Challenges: ○ Whitespace whitespace everywhere! ○ Creating an unambiguous grammar for a language that looks ambiguous if y > 15.9 if y > 15.9 (y is y + 7 VS. z is z - 53.8) (y is y + 7 else (local x is false) z is z - 53.8)

  9. Java Generation ● Walk SAST and convert each element to a string that is written to a Java file ● Challenges ○ Compiling from a dynamically-typed language to a statically-typed language ○ Modularizing Java generation and Java files ● No IR used, but instead SNLObject, a class that acts as an abstraction of type in our language

  10. Tests ● Exhaustive regression testing suite ● Interactive testing script ○ Allows for assurance of quality for each compiler component ● Specific tests for each stage of the compiler ● Over 50 tests for final compiled code ○ Run compiled Java code and compare with expected output ● Prevented many subtle errors in the generation of Java code

  11. Conclusion SNL is a simple language designed to teach programming (and we tested this!). Lessons learned: ● Use github! ● OCaml is actually AMAZING! ● Use regression testing! ● Pair program! ● Unresolved: To procrastinate or not?

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend