From 30c74a965c29c25e329487a321bd83c3df0f5ae7 Mon Sep 17 00:00:00 2001 From: David Van Horn Date: Wed, 29 Oct 2025 10:12:26 -0400 Subject: [PATCH 01/13] Clean up zips target; add assignments to zips. --- www/Makefile | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/www/Makefile b/www/Makefile index cdcefa97..bb089dce 100644 --- a/www/Makefile +++ b/www/Makefile @@ -9,14 +9,24 @@ test: clean $(course): scribble zips + +langs = abscond blackmail con dupe dodger evildoer extort fraud hustle hoax iniquity iniquity-gc jig knock loot mug mountebank neerdowell outlaw +assigns = hoax-plus + zips: mkdir -p $(course)/code/ - cd `racket -e '(require pkg/lib) (display (path->string (pkg-directory "langs")))'` ; \ - tar -c `git ls-files a86 abscond blackmail con dupe dodger evildoer extort fraud hustle hoax iniquity iniquity-gc jig knock loot mug mountebank neerdowell outlaw` | \ - (cd ../www/main/code ; tar -x ; \ - for f in abscond blackmail con dupe dodger evildoer extort fraud hustle hoax iniquity iniquity-gc jig knock loot mug mountebank neerdowell outlaw ; do \ + (cd `racket -e '(require pkg/lib) (display (path->string (pkg-directory "langs")))'` ; \ + tar -c `git ls-files $(langs)`) | \ + (cd $(course)/code/ ; tar -x ; \ + for f in $(langs) ; do \ + zip $${f}.zip -r $${f}/ ; \ + done) + (cd `racket -e '(require pkg/lib) (display (path->string (pkg-directory "assignments")))'` ; \ + tar -c `git ls-files $(assigns)`) | \ + (cd $(course)/code/ ; tar -x ; \ + for f in $(assigns) ; do \ zip $${f}.zip -r $${f}/ ; \ - done ) + done) scribble: raco scribble --htmls \ From 72322ec615739f410767afd555a00191a0959a35 Mon Sep 17 00:00:00 2001 From: David Van Horn Date: Wed, 29 Oct 2025 10:12:48 -0400 Subject: [PATCH 02/13] Link to source code for Hoax+ assignment. --- www/assignments/6.scrbl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/www/assignments/6.scrbl b/www/assignments/6.scrbl index f82ed9a1..f9b50359 100644 --- a/www/assignments/6.scrbl +++ b/www/assignments/6.scrbl @@ -3,6 +3,8 @@ "../notes/ev.rkt") @title[#:tag "Assignment 6" #:style 'unnumbered]{Assignment 6: List and vector primitives} +@src-code["hoax-plus"] + @(require (for-label a86 (except-in racket ...))) @(require racket/port) From e80c0d12570271e83836122a0fd33331105fecb2 Mon Sep 17 00:00:00 2001 From: David Van Horn Date: Wed, 29 Oct 2025 10:16:37 -0400 Subject: [PATCH 03/13] Fix binding. --- www/assignments/6.scrbl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/assignments/6.scrbl b/www/assignments/6.scrbl index f9b50359..1746d04c 100644 --- a/www/assignments/6.scrbl +++ b/www/assignments/6.scrbl @@ -1,6 +1,7 @@ #lang scribble/manual @(require "../defns.rkt" - "../notes/ev.rkt") + "../notes/ev.rkt" + "../notes/utils.rkt") @title[#:tag "Assignment 6" #:style 'unnumbered]{Assignment 6: List and vector primitives} @src-code["hoax-plus"] From ce3bad2837920a6c34604a950e12dbca46f89c0c Mon Sep 17 00:00:00 2001 From: David Van Horn Date: Wed, 29 Oct 2025 15:49:21 -0400 Subject: [PATCH 04/13] Download slides for webpage. --- .github/workflows/push.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 43a0b11e..0ce013ca 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -41,6 +41,11 @@ jobs: # raco pkg install --auto www/ raco make www/main.scrbl make -C www main + - name: Download slides + run: | + gh api repos/cmsc430/slides/zipball/pdfs > pdfs.zip + mkdir -p www/main/slides + unzip -jq pdfs.zip '*.pdf' -d www/main/slides/ - name: Upload www for GitHub Pages uses: actions/upload-pages-artifact@v3 with: From 4b34e4d4123fdd1760c6d5ef1e07b031a3631cb6 Mon Sep 17 00:00:00 2001 From: David Van Horn Date: Wed, 29 Oct 2025 16:14:00 -0400 Subject: [PATCH 05/13] Put github token in env. --- .github/workflows/push.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 0ce013ca..53ef0906 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -6,6 +6,8 @@ name: Build and Deploy jobs: build: runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ github.token }} steps: - name: Set timezone uses: szenius/set-timezone@v2.0 From af6b46f1045fa2995532dbe887630a85d302a831 Mon Sep 17 00:00:00 2001 From: David Van Horn Date: Wed, 29 Oct 2025 16:26:16 -0400 Subject: [PATCH 06/13] Add link to slides on web page. --- www/main.scrbl | 1 + www/slides.scrbl | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 www/slides.scrbl diff --git a/www/main.scrbl b/www/main.scrbl index 722dc2b1..751ba0ec 100644 --- a/www/main.scrbl +++ b/www/main.scrbl @@ -59,6 +59,7 @@ staff using this @link[feedback]{form}. @include-section{texts.scrbl} @include-section{schedule.scrbl} @include-section{notes.scrbl} +@include-section{slides.scrbl} @include-section{assignments.scrbl} @include-section{midterms.scrbl} @include-section{project.scrbl} diff --git a/www/slides.scrbl b/www/slides.scrbl new file mode 100644 index 00000000..3e27f37e --- /dev/null +++ b/www/slides.scrbl @@ -0,0 +1,5 @@ +#lang scribble/base + +@title[#:style '(unnumbered)]{Slides} + +Slides are updated after every class: @link["slides/cmsc430-fall-2025.pdf"]{cmsc430-fall-2025.pdf} From 96829746f3eb82c6800e73b7419474f49f0ef601 Mon Sep 17 00:00:00 2001 From: David Van Horn Date: Wed, 29 Oct 2025 16:31:36 -0400 Subject: [PATCH 07/13] Fix link binding. --- www/slides.scrbl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/www/slides.scrbl b/www/slides.scrbl index 3e27f37e..4a7469ea 100644 --- a/www/slides.scrbl +++ b/www/slides.scrbl @@ -1,5 +1,6 @@ -#lang scribble/base +#lang scribble/manual @title[#:style '(unnumbered)]{Slides} -Slides are updated after every class: @link["slides/cmsc430-fall-2025.pdf"]{cmsc430-fall-2025.pdf} +Slides are updated after every class: +@link["slides/cmsc430-fall-2025.pdf"]{cmsc430-fall-2025.pdf} From 926fab738681a177896d3fab645a9e2a4b6671f3 Mon Sep 17 00:00:00 2001 From: David Van Horn Date: Wed, 29 Oct 2025 18:00:26 -0400 Subject: [PATCH 08/13] Try add repository_dispatch. --- .github/workflows/push.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 53ef0906..1c657d9d 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -1,7 +1,8 @@ +name: Build and Deploy on: - push - -name: Build and Deploy + - repository_dispatch: + types: [slides-updated] jobs: build: @@ -9,6 +10,13 @@ jobs: env: GH_TOKEN: ${{ github.token }} steps: + # Show payload only for repository_dispatch + - name: Show dispatch payload + if: ${{ github.event_name == 'repository_dispatch' }} + run: | + echo "Event type: ${{ github.event.action || 'N/A' }}" + echo "Client payload (JSON):" + echo '${{ toJson(github.event.client_payload) }}' - name: Set timezone uses: szenius/set-timezone@v2.0 with: From 6415a9941ee2ae3cee28ea01adeb09200cd852ea Mon Sep 17 00:00:00 2001 From: David Van Horn Date: Sat, 1 Nov 2025 13:09:45 -0400 Subject: [PATCH 09/13] Assignment 7. --- www/assignments/7.scrbl | 266 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 263 insertions(+), 3 deletions(-) diff --git a/www/assignments/7.scrbl b/www/assignments/7.scrbl index 0eb18c47..e2deffa5 100644 --- a/www/assignments/7.scrbl +++ b/www/assignments/7.scrbl @@ -1,9 +1,269 @@ #lang scribble/manual -@(require "../defns.rkt") -@title[#:tag "Assignment 7" #:style 'unnumbered]{Assignment 7: Binding sequentially, n-ary prmimitives} +@(require "../defns.rkt" + "../notes/ev.rkt") + +@title[#:tag "Assignment 7" #:style 'unnumbered]{Assignment 7: +Variable-arity and arity-overloaded functions} @(require (for-label a86 (except-in racket ...))) @bold{Due: @assign-deadline[7]} -Details of this assignment will be released later in the semester. +@(ev '(require iniquity-plus)) + +The goal of this assignment is to implement variable arity functions. + +@section[#:tag-prefix "a7-" #:style 'unnumbered]{Overview} + +For this assignment, you are given a @tt{iniquity-plus.zip} file on ELMS +with a starter compiler similar to the @seclink["Iniquity"]{Iniquity} +language we studied in class. + +@section[#:tag-prefix "a7-" #:style 'unnumbered #:tag "rest"]{Rest +arguments} + +Many languages including JavaScript, C, C++, Java, Ruby, Go, PHP, and +Racket provide facilities for defining functions that take a ``rest +argument'' which allows the function to be called with more arguments +than expected and these additional arguments will be bound to a single +value that collects all of these arguments. In Iniquity, as in +Racket, the obvious way of collecting these arguments into a single +value is to use a list. + +Here are some examples: + +@itemlist[ + +@item{@racket[(define (f . xs) ...)]: this function takes @emph{any} number +of arguments and binds @racket[xs] to a list containing all of them,} + +@item{@racket[(define (f x . xs) ...)]: this function takes @emph{at +least} one argument and binds @racket[x] to the first argument and +@racket[xs] to a list containing the rest. It's an error to call this function +with zero arguments.} + +@item{@racket[(define (f x y z . xs) ...)]: this function takes +@emph{at least} three arguments and binds @racket[x], @racket[y], and +@racket[z] to the first three arguments and @racket[xs] to a list +containing the rest. It's an error to call this function with 0, 1, +or 2 arguments.} +] + +Here are some examples in Racket to get a sense of the behavior: + +@ex[ +(define (f . xs) (list xs)) +(f) +(f 1) +(f 1 2) +(f 1 2 3) +(f 1 2 3 4) +(define (f x . xs) (list x xs)) +(eval:error (f)) +(f 1) +(f 1 2) +(f 1 2 3) +(f 1 2 3 4) +(define (f x y z . xs) (list x y z xs)) +(eval:error (f)) +(eval:error (f 1)) +(eval:error (f 1 2)) +(f 1 2 3) +(f 1 2 4) +] + +The code generated for a function call should not change: it should +pass all of the arguments on the stack along with information about +the number of arguments. + +The compilation of function definitions that use a rest argument +should generate code that checks that the given number of arguments is +acceptable and should generate code to pop all ``extra'' arguments off +the stack and construct a list which is then bound to the rest +parameter. + +It is worth remembering that arguments are pushed on the stack in such +a way that the last argument is the element most recently pushed on +the stack. This has the benefit of making it easy to pop off the +extra arguments and to construct a list with the elements in the +proper order. + +HINT: the function definition knows the number of ``required'' +arguments, i.e. the minimum number of arguments the function can be +called with---call this @math{m}---and the caller communicates how +many actual arguments have been supplied---call this @math{n}. The +compiler needs to generate a loop that pops @math{n-m} times, +constructing a list with with popped elements, and then finally pushes +this list in order to bind it to the rest parameter. + + +@section[#:tag-prefix "a7-" #:style 'unnumbered #:tag "case-lambda"]{Arity dispatch} + +Some languages such as Java, Haskell, and Racket make it possible to +overload a single function name with multiple definitions where the +dispatch between these different definitions is performed based on the +number (or kind) of arguments given at a function call. + +In Racket, this is accomplished with the @racket[case-lambda] form for +constructing multiple-arity functions. + +Here is an example: + +@ex[ +(define f + (case-lambda + [(x) "got one!"] + [(p q) "got two!"])) + +(f #t) +(f #t #f) +(eval:error (f #t #f 0)) +] + +This function can accept @emph{either} one or two arguments. If given +one argument, it evaluates the right-hand-side of the first clause +with @racket[x] bound to that argument. If given two arguments, it +evaluates the right-hand-side of the second clause with @racket[p] and +@racket[q] bound to the arguments. If given any other number of +arguments, it signals an error. + +A @racket[case-lambda] form can have any number of clauses (including +zero!) and the first clause for which the number of arguments is +acceptable is taken when the function is called. + +Note that @racket[case-lambda] can be combined with rest arguments too. +A clause that accepts any number of arguments is written by simply +listing a parameter name (no parentheses). A clause that accepts some +non-zero minimum number of parameters is written with a dotted +parameter list. + +For example: + +@ex[ +(define f + (case-lambda + [(x y z . r) (length r)] + [(x) "just one!"])) + +(f 1 2 3 4 5 6) +(f #t) +(eval:error (f)) +(eval:error (f 1 2))] + +This function takes three or more arguments @emph{or} one argument. Any +other number of arguments (i.e. zero or two) results in an error. + +@ex[ +(define f + (case-lambda + [(x y z) "three!"] + [xs (length xs)])) + +(f) +(f 1 2) +(f 1 2 3) +(f 1 2 3 4 5 6) +] + +This function takes any number of arguments, but when given three, it +produces @racket["three!"]; in all other cases it produces the number +of arguments. + +@section[#:tag-prefix "a7-" #:style 'unnumbered]{Representing the +syntax of function definitions} + +The @seclink["Iniquity"]{Iniquity} language has a single function +definition form: @racket[(define (_f _x ...) _e)] which is represented +with the following AST type: + +@#reader scribble/comment-reader +(racketblock +;; type Defn = (Defn Id (Listof Id) Expr) +(struct Defn (f xs e) #:prefab) +) + +Because there are three different forms of function definition in +Iniquity+, we use the following AST representation: + +@#reader scribble/comment-reader +(racketblock +;; type Defn = (Defn Id Fun) +(struct Defn (f fun) #:prefab) + +;; type Fun = (FunPlain [Listof Id] Expr) +;; | (FunRest [Listof Id] Id Expr) +;; | (FunCase [Listof FunCaseClause]) +;; type FunCaseClause = (FunPlain [Listof Id] Expr) +;; | (FunRest [Listof Id] Id Expr) +(struct FunPlain (xs e) #:prefab) +(struct FunRest (xs x e) #:prefab) +(struct FunCase (cs) #:prefab) +) + +What used to be represented as @racket[(Defn _f _xs _e)] is now +represented as @racket[(Defn _f (FunPlain _xs _e))]. + + +The parser already works for these new forms of function definitions. +Here are some examples of how function definitions are parsed, but you +are encouraged to try out more to get a better sense: + +@ex[ +(parse-define '(define (f x) x)) +(parse-define '(define (f . xs) xs)) +(parse-define '(define (f x y z . q) q)) +(parse-define + '(define f + (case-lambda + [(x y) 2] + [(z) 1] + [(a b c . d) "3+"] + [q "other"]))) +] + +@section[#:tag-prefix "a7-" #:style 'unnumbered]{Starter code} + +The compiler code given to you is just an implementation of Iniquity, +but updated to parse the new forms of function definitions and +re-organized slightly to match the new AST representation. + +The interpreter code given to you works on the full Iniquity+ +language, so you do not need to update @racket[interp.rkt] and can use +the interpreter to guide your implementation of the compiler. + +@ex[ +(interp + (parse '(define (f x) x) + '(f 1))) +(interp + (parse '(define (f . x) x) + '(f 1))) +(interp + (parse '(define (f . x) x) + '(f))) +(interp + (parse '(define (f . x) x) + '(f 1 2 3 4 5))) +(interp + (parse '(define f + (case-lambda + [(x y) 2] + [(z) 1] + [(a b c . d) "3+"] + [q "other"])) + '(cons (f 7) + (cons (f 3 4) + (cons (f) + (cons (f 7 8 9 10 11) + '())))))) +] + + +Thus, you should only need to modify @racket[compile.rkt]. + +A small number of test cases are given as usual. + +@section[#:tag-prefix "a7-" #:style 'unnumbered]{Submitting} + +To submit, use @tt{make} from within the @tt{iniquity-plus} directory +to create a zip file containing your work and submit it to Gradescope. From 8a9b13127fd8917825c5254f19af25485f67c6d1 Mon Sep 17 00:00:00 2001 From: David Van Horn Date: Sun, 2 Nov 2025 08:38:15 -0500 Subject: [PATCH 10/13] Try to get CI to work again. --- .github/workflows/push.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 1c657d9d..f1c3377e 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -1,8 +1,8 @@ name: Build and Deploy on: - push - - repository_dispatch: - types: [slides-updated] +# - repository_dispatch: +# types: [slides-updated] jobs: build: @@ -11,12 +11,12 @@ jobs: GH_TOKEN: ${{ github.token }} steps: # Show payload only for repository_dispatch - - name: Show dispatch payload - if: ${{ github.event_name == 'repository_dispatch' }} - run: | - echo "Event type: ${{ github.event.action || 'N/A' }}" - echo "Client payload (JSON):" - echo '${{ toJson(github.event.client_payload) }}' +# - name: Show dispatch payload +# if: ${{ github.event_name == 'repository_dispatch' }} +# run: | +# echo "Event type: ${{ github.event.action || 'N/A' }}" +# echo "Client payload (JSON):" +# echo '${{ toJson(github.event.client_payload) }}' - name: Set timezone uses: szenius/set-timezone@v2.0 with: From 42bee6927e64aa48019d1699a89306c94d84a81f Mon Sep 17 00:00:00 2001 From: David Van Horn Date: Thu, 20 Nov 2025 13:24:39 -0500 Subject: [PATCH 11/13] Assignment 8. --- www/assignments.scrbl | 2 +- www/assignments/8.scrbl | 120 +++++++++++++++++++++++++++++++++++++++- www/defns.rkt | 4 +- 3 files changed, 120 insertions(+), 6 deletions(-) diff --git a/www/assignments.scrbl b/www/assignments.scrbl index 8f6f5246..c8bb4f05 100644 --- a/www/assignments.scrbl +++ b/www/assignments.scrbl @@ -11,7 +11,7 @@ @include-section{assignments/6.scrbl} @include-section{assignments/7.scrbl} @include-section{assignments/8.scrbl} -@include-section{assignments/9.scrbl} +@;include-section{assignments/9.scrbl} @;include-section{assignments/10.scrbl} diff --git a/www/assignments/8.scrbl b/www/assignments/8.scrbl index 5755b31f..27aaf18e 100644 --- a/www/assignments/8.scrbl +++ b/www/assignments/8.scrbl @@ -1,9 +1,123 @@ #lang scribble/manual @(require "../defns.rkt") -@title[#:tag "Assignment 8" #:style 'unnumbered]{Assignment 8: Functions with default arguments} +@title[#:tag "Assignment 8" #:style 'unnumbered]{Assignment 8: Patterns} + +@(require (for-label (except-in racket ...))) +@(require "../notes/ev.rkt" + "../notes/utils.rkt") -@(require (for-label a86 (except-in racket ...))) @bold{Due: @assign-deadline[8]} -Details of this assignment will be released later in the semester. +The goal of this assignment is to extend a compiler with new pattern +matching forms for matching lists, vectors, and predicates. + +You are given a file @tt{knock-plus.zip} on ELMS with a starter +compiler similar to the @seclink["Knock"]{Knock} language we studied +in class. You are tasked with: + +@itemlist[ + +@item{implementing the @tt{list} pattern,} + +@item{implementing the @tt{vector} pattern, and} + +@item{implementing the @tt{?} pattern.} +] + +The following files have already been updated for you @bold{and should +not be changed by you}: + +@itemlist[ @item{@tt{ast.rkt}} + @item{@tt{parse.rkt}} + @item{@tt{interp.rkt}} + @item{@tt{interp-prim.rkt}} + @item{@tt{compile-op.rkt}} +] + +So you will only need to modify: +@itemlist[ +@item{@tt{compile.rkt}} +] +to correctly implement the new features. These features are described below. + +As a convenience, two new n-ary primitives have been added (and fully +implemented): @racket[list] and @racket[vector]. The @racket[list] +primitive takes any number of arguments and produces a list containing +the arguments as elements; the @racket[vector] primitive does the +same, but constructs a vector. + +@ex[ +(list) +(list 1 2 3) +(list 1 #t #\c) +(vector) +(vector 1 2 3) +(vector 1 #t #\c)] + +These are not directly useful in implementing the patterns above, but +do make it easier to write examples and tests. + +@section[#:tag-prefix "a5-" #:style 'unnumbered #:tag "list"]{List patterns} + +The @racket[(list _p1 ... _pn)] pattern matches a list of elements. The +pattern matches a list with as many elements as there are patterns +@racket[_p1] through @racket[_pn] and each element must match the +respective pattern. + + +@ex[ +(match (list) + [(list) #t] + [_ #f]) +(match (list 1 2 3) + [(list x y z) x]) +(match (list (list 1) (list 2)) + [(list (list x) (list 2)) x]) +] + +@section[#:tag-prefix "a5-" #:style 'unnumbered #:tag "vector"]{Vector patterns} + +The @racket[(vector _p1 ... _pn)] pattern matches a vector of elements. The +pattern matches a vector with as many elements as there are patterns +@racket[_p1] through @racket[_pn] and each element must match the +respective pattern. + + +@ex[ +(match (vector) + [(vector) #t] + [_ #f]) +(match (vector 1 2 3) + [(vector x y z) x]) +(match (vector (vector 1) (vector 2)) + [(vector (vector x) (vector 2)) x]) +] + +@section[#:tag-prefix "a5-" #:style 'unnumbered #:tag "vector"]{Predicate patterns} + +The @racket[(? _f)] pattern matches any value for which the predicate +@racket[_f] returns a true value (any value other than @racket[#f]) +when applied to the value being matched. In Knock+, @racket[_f] must be +the name of a user defined function. + +@ex[ +(define (is-eight? x) (= x 8)) +(define (id x) x) + +(match 8 + [(? is-eight?) #t] + [_ #f]) +(match (vector 1 2 3) + [(and (? id) x) x]) +(match 16 + [(? is-eight?) #t] + [_ #f]) +] + + +@section[#:tag-prefix "a5-" #:style 'unnumbered]{Submitting} + +Submit a zip file containing your work to Gradescope. Use @tt{make +submit.zip} from within the @tt{knock-plus} directory to create a zip +file with the proper structure. diff --git a/www/defns.rkt b/www/defns.rkt index c8786986..2cd72f08 100644 --- a/www/defns.rkt +++ b/www/defns.rkt @@ -61,8 +61,8 @@ "Thursday, October 23, 11:59PM" "Tuesday, November 4, 11:59PM" "Tuesday, November 11, 11:59PM" - "Thursday, November 20, 11:59PM" - "Thursday, December 4, 11:59PM") + "Thursday, December 4, 11:59PM" + #;"Thursday, December 4, 11:59PM") (sub1 i))) (define office-hours From 54c8d4a0841a673e4c56c59ded0b11cf6675389e Mon Sep 17 00:00:00 2001 From: David Van Horn Date: Fri, 21 Nov 2025 11:52:34 -0500 Subject: [PATCH 12/13] Touch up assignment. --- www/assignments/8.scrbl | 8 ++++---- www/defns.rkt | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/www/assignments/8.scrbl b/www/assignments/8.scrbl index 27aaf18e..6b8e77b4 100644 --- a/www/assignments/8.scrbl +++ b/www/assignments/8.scrbl @@ -58,7 +58,7 @@ same, but constructs a vector. These are not directly useful in implementing the patterns above, but do make it easier to write examples and tests. -@section[#:tag-prefix "a5-" #:style 'unnumbered #:tag "list"]{List patterns} +@section[#:tag-prefix "a8-" #:style 'unnumbered #:tag "list"]{List patterns} The @racket[(list _p1 ... _pn)] pattern matches a list of elements. The pattern matches a list with as many elements as there are patterns @@ -76,7 +76,7 @@ respective pattern. [(list (list x) (list 2)) x]) ] -@section[#:tag-prefix "a5-" #:style 'unnumbered #:tag "vector"]{Vector patterns} +@section[#:tag-prefix "a8-" #:style 'unnumbered #:tag "vector"]{Vector patterns} The @racket[(vector _p1 ... _pn)] pattern matches a vector of elements. The pattern matches a vector with as many elements as there are patterns @@ -94,7 +94,7 @@ respective pattern. [(vector (vector x) (vector 2)) x]) ] -@section[#:tag-prefix "a5-" #:style 'unnumbered #:tag "vector"]{Predicate patterns} +@section[#:tag-prefix "a8-" #:style 'unnumbered #:tag "vector"]{Predicate patterns} The @racket[(? _f)] pattern matches any value for which the predicate @racket[_f] returns a true value (any value other than @racket[#f]) @@ -116,7 +116,7 @@ the name of a user defined function. ] -@section[#:tag-prefix "a5-" #:style 'unnumbered]{Submitting} +@section[#:tag-prefix "a8-" #:style 'unnumbered]{Submitting} Submit a zip file containing your work to Gradescope. Use @tt{make submit.zip} from within the @tt{knock-plus} directory to create a zip diff --git a/www/defns.rkt b/www/defns.rkt index 2cd72f08..f4ffa82c 100644 --- a/www/defns.rkt +++ b/www/defns.rkt @@ -61,7 +61,7 @@ "Thursday, October 23, 11:59PM" "Tuesday, November 4, 11:59PM" "Tuesday, November 11, 11:59PM" - "Thursday, December 4, 11:59PM" + "Tuesday, December 9, 11:59PM" #;"Thursday, December 4, 11:59PM") (sub1 i))) From e4fbc47be0d1c69053b7078eb9d961be3cc2ba62 Mon Sep 17 00:00:00 2001 From: David Van Horn Date: Fri, 21 Nov 2025 12:06:51 -0500 Subject: [PATCH 13/13] Examples of parsing patterns. --- www/assignments/8.scrbl | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/www/assignments/8.scrbl b/www/assignments/8.scrbl index 6b8e77b4..8f733d11 100644 --- a/www/assignments/8.scrbl +++ b/www/assignments/8.scrbl @@ -6,9 +6,10 @@ @(require "../notes/ev.rkt" "../notes/utils.rkt") - @bold{Due: @assign-deadline[8]} +@(ev '(require knock-plus)) + The goal of this assignment is to extend a compiler with new pattern matching forms for matching lists, vectors, and predicates. @@ -115,6 +116,30 @@ the name of a user defined function. [_ #f]) ] +@section[#:tag-prefix "a8-" #:style 'unnumbered]{Representing the syntax of patterns} + +The AST of patterns is extended as follows: + +@#reader scribble/comment-reader +(racketblock +;; type Pat = ... +;; | (List [Listof Pat]) +;; | (Vect [Listof Pat]) +;; | (Pred Id) +) + +The parser includes a @racket[parse-pattern] function that parses a +single pattern: + +@ex[ +(parse-pattern 'x) +(parse-pattern '(cons x y)) +(parse-pattern '(list x y z)) +(parse-pattern '(vector x y z)) +(parse-pattern '(? f?)) +] + + @section[#:tag-prefix "a8-" #:style 'unnumbered]{Submitting}