User Tools

Site Tools


cs330_f2016:labw

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:labw [2018/02/01 21:19]
morse
cs330_f2016:labw [2021/06/30 23:42] (current)
Line 1: Line 1:
-**This is a draft version of the assignment and may change until the due date of the preceding assignment. 
-** 
- 
 ====Objective:​==== ====Objective:​====
  
Line 9: Line 6:
 ====Pre-requisite:​==== ====Pre-requisite:​====
  
-For this lab, you should have Julia 0.6+ installed, the same as for the rudimentary interpreter. ​ You will need both the Lexer and Error modules.+For this lab, you should have Julia 1.installed, the same as for the rudimentary interpreter. ​ You will need both the Lexer and Error modules.
  
 ---- ----
Line 85: Line 82:
 (lambda x (+ x 1)) (lambda x (+ x 1))
 or or
-(with x 5 (+ x 1))+(with (x 5(+ x 1))
 </​code>​ </​code>​
  
Line 115: Line 112:
 **Remember to throw errors, not simply print error messages.** **Remember to throw errors, not simply print error messages.**
  
-Your parser and interpreter must detect errors and explicitly signal them by calling throw(LispError(Reason). We will consider an error raised internally by julia to be a bug in your code.+Your parser and interpreter must detect errors and explicitly signal them by calling throw(LispError(Reason). ​**We will consider an error raised internally by julia to be a bug in your code.**. Think how you'd feel as a programmer if an error in your source code caused your compiler to crash instead of telling you what was wrong.
  
 To include LispError put "using Error" after the module declaration of you code. Error is a module containing LispError. To include LispError put "using Error" after the module declaration of you code. Error is a module containing LispError.
- 
-For example, Julia signals a “divide by zero” error if you attempt to evaluate (/ 1 0). Since we use Julia'​s division function to implement division in OWL, you may be tempted to leave it to Julia to signal division by zero errors for you. However, you must signal the error yourself by explicitly testing for division by zero before calling Julia'​s division procedure. 
  
 ---- ----
Line 134: Line 129:
 abstract type AE end abstract type AE end
  
-type NumNode <: AE+struct ​NumNode <: AE
     n::Real     n::Real
 end end
  
-type BinopNode <: AE+struct ​BinopNode <: AE
     op::​Function     op::​Function
     lhs::AE     lhs::AE
Line 144: Line 139:
 end end
  
-type If0Node <: AE+struct ​If0Node <: AE
   condition::​AE   condition::​AE
   zero_branch::​AE   zero_branch::​AE
Line 150: Line 145:
 end end
  
-type WithNode <: AE+struct ​WithNode <: AE
   sym::Symbol   sym::Symbol
   binding_expr::​AE   binding_expr::​AE
Line 156: Line 151:
 end end
  
-type VarRefNode <: AE+struct ​VarRefNode <: AE
   sym::Symbol   sym::Symbol
 end end
  
-type FunDefNode <: AE+struct ​FunDefNode <: AE
   formal::​Symbol   formal::​Symbol
   fun_body::​AE   fun_body::​AE
 end end
  
-type FunAppNode <: AE+struct ​FunAppNode <: AE
   fun_expr::​AE   fun_expr::​AE
   arg_expr::​AE   arg_expr::​AE
Line 174: Line 169:
 abstract type Environment end abstract type Environment end
  
-type NumVal <: RetVal+struct ​NumVal <: RetVal
   n::Real   n::Real
 end end
  
-type ClosureVal <: RetVal+struct ​ClosureVal <: RetVal
   formal::​Symbol   formal::​Symbol
   body::AE   body::AE
Line 184: Line 179:
 end end
  
-type EmptyEnv <: Environment+struct ​EmptyEnv <: Environment
 end end
  
-type ExtendedEnv <: Environment+struct ​ExtendedEnv <: Environment
   sym::Symbol   sym::Symbol
   val::RetVal   val::RetVal
Line 204: Line 199:
  
 <code Julia> <code Julia>
-function parse(expr::​Array{Symbol or Real}+function parse(expr::​Any
-function calc(ast::OWL)+function calc(ast::AE)
 </​code>​ </​code>​
  
cs330_f2016/labw.1517519963.txt.gz · Last modified: 2021/06/30 23:40 (external edit)