|
1 | 1 | #lang scribble/manual |
2 | | -@(require "../defns.rkt") |
3 | | -@title[#:tag "Assignment 6" #:style 'unnumbered]{Assignment 6: List primitives and n-ary primitives} |
| 2 | +@(require "../defns.rkt" |
| 3 | + "../notes/ev.rkt") |
| 4 | +@title[#:tag "Assignment 6" #:style 'unnumbered]{Assignment 6: List and vector primitives} |
4 | 5 |
|
5 | 6 | @(require (for-label a86 (except-in racket ...))) |
6 | 7 |
|
| 8 | +@(require racket/port) |
| 9 | + |
7 | 10 | @bold{Due: @assign-deadline[6]} |
8 | 11 |
|
9 | | -Details of this assignment will be released later in the semester. |
| 12 | +@;{ All this to silence some Makefile output on Linux -- should probably be taken care of at the Makefile level } |
| 13 | +@(ev '(begin (define p (current-output-port)) |
| 14 | + (current-output-port (open-output-string)) |
| 15 | + (require hoax-plus) |
| 16 | + (current-output-port p))) |
| 17 | + |
| 18 | +The goal of this assignment is to gain proficiency with our |
| 19 | +representation of memory-allocated values by implementing a number of |
| 20 | +list and vector primitives. |
| 21 | + |
| 22 | +@section[#:tag-prefix "a6-" #:style 'unnumbered]{Overview} |
| 23 | + |
| 24 | +For this assignment, you are given a @tt{hoax-plus.zip} file on ELMS |
| 25 | +with a starter compiler similar to the @seclink["Hoax"]{Hoax} |
| 26 | +language we studied in class. |
| 27 | + |
| 28 | + |
| 29 | +@section[#:tag-prefix "a6-" #:style 'unnumbered]{Hoax+} |
| 30 | + |
| 31 | +The Hoax+ language extends the Hoax language we studied in class with four |
| 32 | +new unary primitives: |
| 33 | + |
| 34 | +@itemlist[ |
| 35 | +@item{@racket[length]: given a list, computes its length.} |
| 36 | +@item{@racket[reverse]: given a list, computes a list with elements in the reverse order of the given list.} |
| 37 | +@item{@racket[list->vector]: given a list, computes a vector with elements in the order of the given list.} |
| 38 | +@item{@racket[vector->list]: given a vector, computes a list with elements in the order of the given vector.} |
| 39 | +] |
| 40 | + |
| 41 | +Unlike past assignments, you do not need to bring forward in any |
| 42 | +features from earlier assignments. |
| 43 | + |
| 44 | +@section[#:tag-prefix "a6-" #:style 'unnumbered]{List and vector primitves} |
| 45 | + |
| 46 | + |
| 47 | +The new primitives have been added to the parser and the interpreter. |
| 48 | +The behavior of compiled primitives should be consistent with the |
| 49 | +interpreter: |
| 50 | + |
| 51 | +@ex[ |
| 52 | +(interp (parse '(length '()))) |
| 53 | +(interp (parse '(length (cons 1 (cons 2 '()))))) |
| 54 | +(interp (parse '(length #f))) |
| 55 | +(interp (parse '(reverse '()))) |
| 56 | +(interp (parse '(reverse (cons 1 (cons 2 '()))))) |
| 57 | +(interp (parse '(reverse #f))) |
| 58 | +(interp (parse '(list->vector '()))) |
| 59 | +(interp (parse '(list->vector (cons 1 (cons 2 '()))))) |
| 60 | +(interp (parse '(list->vector #f))) |
| 61 | +(interp (parse '(vector->list (make-vector 0 #t)))) |
| 62 | +(interp (parse '(vector->list (make-vector 2 #t)))) |
| 63 | +(interp (parse '(vector->list #f))) |
| 64 | +] |
| 65 | + |
| 66 | +The interpreter is consistent with Racket's own behavior, so if you're |
| 67 | +unsure about what your compiler should do, you can look to Racket (or |
| 68 | +the interpreter) for guidance: |
| 69 | + |
| 70 | +@ex[ |
| 71 | +(length '()) |
| 72 | +(length (cons 1 (cons 2 '()))) |
| 73 | +(eval:error (length #f)) |
| 74 | +(reverse '()) |
| 75 | +(reverse (cons 1 (cons 2 '()))) |
| 76 | +(eval:error (reverse #f)) |
| 77 | +(list->vector '()) |
| 78 | +(list->vector (cons 1 (cons 2 '()))) |
| 79 | +(eval:error (list->vector #f)) |
| 80 | +(vector->list (make-vector 0 #t)) |
| 81 | +(vector->list (make-vector 2 #t)) |
| 82 | +(eval:error (vector->list #f)) |
| 83 | +] |
| 84 | + |
| 85 | +@subsection[#:tag-prefix "a6-" #:style 'unnumbered]{Testing} |
| 86 | + |
| 87 | +A small number of test cases have been provided in |
| 88 | +@tt{test/test-runner.rkt}. There is function called @racket[test] |
| 89 | +that contains I/O-free test cases and another called @racket[test/io] |
| 90 | +that contains I/O tests. To run these tests, @tt{raco test |
| 91 | +test/interp.rkt} will test the interpreter and @tt{raco test |
| 92 | +test/compile.rkt} will test the compiler. You are encouraged to add |
| 93 | +your own tests. |
| 94 | + |
| 95 | +@section[#:tag-prefix "a6-" #:style 'unnumbered]{Submitting} |
| 96 | + |
| 97 | +To submit, use @tt{make} from within the @tt{hoax-plus} directory to |
| 98 | +create a zip file containing your work and submit it to Gradescope. |
0 commit comments