User Tools

Site Tools


cs330_f2016:laby

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:laby [2018/09/17 23:12]
morse
cs330_f2016:laby [2021/06/30 23:42] (current)
Line 9: Line 9:
  
 You will need to download and install [[https://​julialang.org|Julia]] for this lab. You will need to download and install [[https://​julialang.org|Julia]] for this lab.
-Note: if you are using Ubuntu, be careful using the ''​apt''​ version of Julia (it may be too old!). ​ **You should use Julia 1.0 or later.**.+Note: if you are using Ubuntu, be careful using the ''​apt''​ version of Julia (it may be too old!). ​ **You should use Julia 1.0 or later.**
  
 Note that the code required for this lab is available on LearningSuite,​ in the "​Content"​ section, under the "​Interpreters"​ subsection, on the page titled "Base Interpreter"​. ​ You will need the following files: Note that the code required for this lab is available on LearningSuite,​ in the "​Content"​ section, under the "​Interpreters"​ subsection, on the page titled "Base Interpreter"​. ​ You will need the following files:
Line 18: Line 18:
 You should not modify the ''​Lexer.jl''​ or ''​Error.jl'',​ and these will stay the same for all of the interpreter assignments. You should not modify the ''​Lexer.jl''​ or ''​Error.jl'',​ and these will stay the same for all of the interpreter assignments.
  
-After playing with it to make sure it's working and you have everything set up correctly, make a copy of ''​CI0.jl''​ and name it ''​RudInt.jl''​ (short for "​Rudimentary Interpreter",​ or this assignment).+After playing with it to make sure it's working and you have everything set up correctly, make a copy of ''​CI0.jl''​ and name it ''​RudInt.jl''​ (short for "​Rudimentary Interpreter",​ or this assignment). You should then edit ''​RudInt.jl''​ using the provided CI0 interpreter as a base.  Remember to change the name of the module defined within the file to ''​RudInt''​ as well.
  
 For code development,​ you may wish to use any of the following: For code development,​ you may wish to use any of the following:
   * The [[http://​junolab.org|Juno]] IDE built on [[https://​atom.io|Atom]],​   * The [[http://​junolab.org|Juno]] IDE built on [[https://​atom.io|Atom]],​
-  * The [[https://​github.com/​JuliaLang/​IJulia.jl|IJulia]] plugin for Jupyter,+  * The [[https://​github.com/​JuliaLang/​IJulia.jl|IJulia]] plugin for [[https://​jupyter-notebook.readthedocs.io/​en/​stable/​|Jupyter]],
   * Your preferred text editor (look to see if it has Julia extensions) and command-line invocation of your programs, or   * Your preferred text editor (look to see if it has Julia extensions) and command-line invocation of your programs, or
   * Another IDE of your choice.   * Another IDE of your choice.
Line 37: Line 37:
 Remember that you will use multiple dispatch to implement different "​versions"​ of ''​parse''​ and ''​calc'',​ based on the input type. Remember that you will use multiple dispatch to implement different "​versions"​ of ''​parse''​ and ''​calc'',​ based on the input type.
  
-An important difference between the code that you will implement for this lab, and the code we went through in class, is that your code should properly abstract multiple binary AST nodes into a single class we'll call ''​BinOp''​.+An important difference between the code that you will implement for this lab, and the code we went through in class, is that your code should properly abstract multiple binary AST nodes into a single class we'll call ''​BinopNode''​.
  
-Please name your module RudInt.+Please name your module RudInt ​and submit just the one file.
  
 ===Operator Table === ===Operator Table ===
  
-Define a data-structure to contain a mapping from operator symbols to the functions that actually implement that symbol.+Define a data structure to contain a mapping from operator symbols to the functions that actually implement that symbol. ​  
 +These functions can be either built-in ones or ones that you write, so long as you preserve the semantic meaning of the operation. 
 For example: For example:
  
Line 49: Line 51:
 Dict(:+ => +) Dict(:+ => +)
 </​code>​ </​code>​
 +
 +For operations that do not require any further semantic checking, you should map to the corresponding built-in function.
  
 ===Parser=== ===Parser===
Line 85: Line 89:
 abstract type AE end abstract type AE end
  
-type Num <: AE+struct NumNode ​<: AE
  n::Real  n::Real
 end end
  
-type Binop <: AE+struct BinopNode ​<: AE
  op::​Function  op::​Function
  lhs::AE  lhs::AE
Line 146: Line 150:
 Note that the ''​-''​ operator has two distinct usages: as a binary operation (the "​minus"​ operation) and as a unary operation ("​negation"​). ​ You should create a distinct class to handle unary operations. Note that the ''​-''​ operator has two distinct usages: as a binary operation (the "​minus"​ operation) and as a unary operation ("​negation"​). ​ You should create a distinct class to handle unary operations.
  
-If you change a module, it can sometimes be tricky to convince Julia to reload it and not use the previously compiled and cached version. ​ I **strongly** recommend using the [[https://​github.com/​timholy/​Revise.jl|''​Revise''​module and loading it before you load the rest of your code.  If it's working as designed, it should automatically reload any subsequently loaded modules if the corresponding source code file changes. ​ (If you have not already installed the ''​Revise''​ package, use [[https://​docs.julialang.org/​en/​v1/​stdlib/​Pkg/#​Getting-Started-1|Julia'​s package manager]] to install it.)+If you change a module, it can sometimes be tricky to convince Julia to reload it and not use the previously compiled and cached version. ​ I **strongly** recommend using the ''​[[https://​github.com/​timholy/​Revise.jl|Revise]]''​ module and loading it before you load the rest of your code.  If it's working as designed, it should automatically reload any subsequently loaded modules if the corresponding source code file changes. ​ (If you have not already installed the ''​Revise''​ package, use [[https://​docs.julialang.org/​en/​v1/​stdlib/​Pkg/#​Getting-Started-1|Julia'​s package manager]] to install it.)
  
 <code julia> <code julia>
-using Revise+using Revise ​# make sure to load before the others
 using Error using Error
 using Lexer using Lexer
Line 156: Line 160:
  
 In order for your code to work with the solo-grader you will need to do following: In order for your code to work with the solo-grader you will need to do following:
-  -Name your module RudInt+  -Name your module ​''​RudInt''​.
-  -Make sure the function stored in your binop are native Julia functions.+
   -Make sure the ''​julia''​ binary is in your executable path (like you did for ''​racket''​ previously)   -Make sure the ''​julia''​ binary is in your executable path (like you did for ''​racket''​ previously)
-  -Make sure the path for the Error and Lexer files are on you Julia path. To do this you can call ''​JULIA_LOAD_PATH=PATH python ....''​ or you can add ''​push!(LOAD_PATH,​pwd())''​ into your ''​.juliarc''​ file. +  -Make sure the path for the Error and Lexer files are on you Julia path. To do this you can add ''​push!(LOAD_PATH,​pwd())''​ into your ''​~/.julia/​config/​startup.jl''​ file, then just make sure to run the autograder from the same directory in which you have RudInt, Lexer, and Error
-  -Inside your module have the lines ''​using Error''​ and ''​using Lexer''​.+  -Inside your module have the lines ''​using Error''​ and ''​using Lexer''​.  (These should already be in the base code we give you to start with.) 
 + 
 +====Change Log==== 
 +Changes since first given this semester: 
 +  * Replaced "​type..."​ with "​struct..."​ in the abstract syntax definitions to be compatible with Julia 1.0 
 +  * Changed "​Num"​ to "​NumNode"​ and "​Binop"​ to "​BinopNode"​ to be consistent with the in-class interpreters and the given base code in CI0. 
 +  * Tweaked the Hints to be compatible with Julia 1.0, especially changing .juliarc to startup.jl. 
 +  * Changed the autograders accordingly.
cs330_f2016/laby.1537225973.txt.gz · Last modified: 2021/06/30 23:40 (external edit)