User Tools

Site Tools


cs330_f2016:labpaint

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
cs330_f2016:labpaint [2017/10/11 22:21]
corey [Deliverable:]
cs330_f2016:labpaint [2021/06/30 23:42] (current)
Line 6: Line 6:
 ====Pre-requisite:​==== ====Pre-requisite:​====
  
-For this lab, you should have Julia 0.installed, the same as for the rudimentary interpreter. ​ You will need both the Lexer and Error modules, and you will need your code from the Extended Interpreter.+For this lab, you should ​again have Julia 1.installed, the same as for the rudimentary interpreter. ​ You will need both the Lexer and Error modules, and you will need your code from the Extended Interpreter.
  
 ---- ----
Line 17: Line 17:
 Your module should be able to do everything that your simple interpreter could do and everything that your extended interpreter can do.  However, you will use program analysis to both eliminate ''​With''​ nodes, and to add two new simple features. Your module should be able to do everything that your simple interpreter could do and everything that your extended interpreter can do.  However, you will use program analysis to both eliminate ''​With''​ nodes, and to add two new simple features.
  
-The ''​CI6.jl''​ module is available ​on Dropbox.+The ''​CI4.jl''​ module is available ​in the Content section in Learning Suite.
  
 Please name your module TransInt. Please name your module TransInt.
Line 33: Line 33:
  
 Each is discussed in more detail in the following sections. Each is discussed in more detail in the following sections.
 +
 +Note that we do not expect you to nor want you to implement short-circuiting of if0 nodes or pre-calculation of arithmetic expressions. Only do the syntactic de-sugaring as described here.
  
 The grammar for our new language is the following: The grammar for our new language is the following:
  
 <code BNF> <code BNF>
-<OWL> ::= number +<AE> ::= number 
-          | (+ <OWL> <OWL> <OWL>​*) ​  # at least two parameters, possibly infinity. ​ note extra star! +          | (+ <AE> <AE> <AE>​*) ​  # at least two parameters, possibly infinity. ​ note extra star! 
-          | (- <OWL> <OWL>) +          | (- <AE> <AE>) 
-          | (* <OWL> <OWL>) +          | (* <AE> <AE>) 
-          | (/ <OWL> <OWL>) +          | (/ <AE> <AE>) 
-          | (mod <OWL> <OWL>) +          | (mod <AE> <AE>) 
-          | (collatz <OWL>) +          | (collatz <AE>) 
-          | (- <OWL>)      ​+          | (- <AE>)      ​
           | id           | id
-          | (if0 <OWL> <OWL> <OWL>) +          | (if0 <AE> <AE> <AE>) 
-          | (with ( (id <OWL>)* ) <OWL>) +          | (with ( (id <AE>)* ) <AE>) 
-          | (lambda (id*) <OWL>) +          | (lambda (id*) <AE>) 
-          | (and <OWL> <OWL> <OWL>​*) ​ # new operation '​and'​ +          | (and <AE> <AE> <AE>​*) ​ # new operation '​and'​ 
-          | (<OWL> <OWL>​*) ​        +          | (<AE> <AE>​*) ​        
 </​code>​ </​code>​
  
Line 74: Line 76:
 </​code>​ </​code>​
  
-Your code should make a similar transformation for multiple-identifier ''​with''​ expressions to applying multiple-parameter ''​lambda''​ expressions.+Your code should make a similar transformation for multiple-identifier ''​with''​ expressions to applying multiple-parameter ''​lambda''​ expressions. ​For example,
  
-No changes to the grammar are necessary to support this change, and therefore, no changes to your parser from the Extended Interpreter are necessary to implement this under-the-hood syntactic rewrite. The transformation should happen in the ''​analyze''​ function.+<code lisp> 
 +(with ((x 5) (y 6)) (+ x y)) 
 +</​code>​ 
 + 
 +becomes 
 + 
 +<code lisp> 
 +((lambda (x y) (+ x y)) 5 6) 
 +</​code>​ 
 + 
 +No changes to the grammar are necessary to support this change, and therefore, no changes to your parser from the Extended Interpreter are necessary to implement this under-the-hood syntactic rewrite. ​**The transformation should happen in the ''​analyze''​ function.**
  
 **Part 2: Addition operation with arbitrary number of parameters** **Part 2: Addition operation with arbitrary number of parameters**
Line 123: Line 135:
  
 Note that this is a new construct in our grammar, so you will need to create a new AST node type (call it ''​And''​) and parse it appropriately. ​ However, because it is being implemented in terms of ''​if0''​ calls, you will not need to modify your ''​calc''​ function to support it. The transformation from the ''​And''​ node to the ''​if0''​ nodes should happen in the ''​analyze''​ function. Note that this is a new construct in our grammar, so you will need to create a new AST node type (call it ''​And''​) and parse it appropriately. ​ However, because it is being implemented in terms of ''​if0''​ calls, you will not need to modify your ''​calc''​ function to support it. The transformation from the ''​And''​ node to the ''​if0''​ nodes should happen in the ''​analyze''​ function.
- 
cs330_f2016/labpaint.1507760492.txt.gz · Last modified: 2021/06/30 23:40 (external edit)