Skip to content

Commit 12ee5b6

Browse files
authored
Merge pull request #171 from cmsc430/next
Next
2 parents 0712c7c + 7e11077 commit 12ee5b6

5 files changed

Lines changed: 129 additions & 116 deletions

File tree

www/assignments.scrbl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
@include-section{assignments/1.scrbl}
77
@include-section{assignments/2.scrbl}
8-
@;include-section{assignments/3.scrbl}
8+
@include-section{assignments/3.scrbl}
99
@;include-section{assignments/4.scrbl}
1010
@;include-section{assignments/5.scrbl}
1111
@;include-section{assignments/6.scrbl}

www/assignments/3.scrbl

Lines changed: 96 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -5,78 +5,54 @@
55
@(require "../../langs/con-plus/semantics.rkt")
66
@(require redex/pict)
77

8-
@bold{Due: @elem[#:style "strike"]{Friday, September 29, 11:59PM}
9-
Monday, October 2, 11:59PM}
8+
@bold{Part 1 Due: Wednesday, February 21, 11:59PM}
109

11-
The goal of this assignment is to extend the parser, interpreter, and
12-
compiler with some simple unary numeric and boolean operations and two
13-
forms of control flow expressions: @racket[cond]-expressions and
14-
@racket[case]-expressions.
10+
@bold{Part 2 Due: Wednesday, February 28, 11:59PM}
1511

1612

17-
You are given a file @tt{dupe-plus.zip} on ELMS with a starter
18-
compiler based on the @secref{Dupe} language we studied in class.
13+
The goal of this assignment is to extend the language developed in
14+
@secref{Dupe} with some simple unary numeric and boolean operations
15+
and two forms of control flow expressions: @racket[cond]-expressions
16+
and @racket[case]-expressions.
1917

18+
This assignment consists of two parts. Part 1 asks you to write a
19+
number of programs in the extended language. Part 2 asks you to
20+
implement the language.
2021

21-
You are tasked with extending the language in a number of
22-
ways:
22+
@section[#:tag-prefix "a3-" #:style 'unnumbered]{Part 1}
23+
24+
For this part of the assignment, you must write a number of programs
25+
in the Dupe+ language. These programs should be syntactically
26+
well-formed and @bold{produce a value} when evaluated, i.e. these should
27+
be programs that do not cause run-time errors.
28+
29+
This exercise will help you understand the features you will be
30+
implementing in the second part of the assignment and can be used to
31+
test your compiler. In fact, we will use the programs you write to
32+
run against a collection of existing Dupe+ compilers to see if they
33+
uncover any bugs. The more bugs you can uncover, the better.
34+
35+
The Dupe+ language extends Dupe in the follow ways:
2336

2437
@itemlist[
2538
@item{adding new primitive operations,}
2639
@item{adding @racket[cond], and}
2740
@item{adding @racket[case].}
2841
]
2942

30-
You may use any a86 instructions you'd like, however it is possible to
31-
complete the assignment using @racket[Cmp], @racket[Je], @racket[Jg],
32-
@racket[Jmp], @racket[Label], @racket[Mov], and @racket[Sub].
33-
34-
@section[#:tag-prefix "a3-" #:style 'unnumbered]{More primitives}
43+
@subsection[#:tag-prefix "a3-" #:style 'unnumbered]{Primitives}
3544

36-
Add the following forms of expression to the language:
45+
The following new primitves are included in Dupe+:
3746

3847
@itemlist[
3948
@item{@racket[(abs _e)]: compute the absolute value of @racket[_e],}
4049
@item{@racket[(- _e)]: flips the sign of @racket[_e], i.e. compute @math{0-@racket[_e]}, and}
4150
@item{@racket[(not _e)]: compute the logical negation of @racket[_e]; note that the negation of @emph{any} value other than @racket[#f] is @racket[#f] and the negation of @racket[#f] is @racket[#t].}
4251
]
4352

44-
There are many ways to implement these at the assembly level. You should try implementing
45-
these using the limited a86 instruction set.
46-
47-
To do this, you should:
48-
@itemlist[
49-
@item{Study @tt{ast.rkt} and the new forms of expression (i.e. new AST nodes)
50-
then update the comment at the top describing what the grammmar should look like.}
51-
52-
@item{Study @tt{parse.rkt} and add support for parsing these
53-
expressions. (See @secref[#:tag-prefixes '("a3-")]{parse} for guidance.)}
54-
55-
@item{Update @tt{interp-prim.rkt} and @tt{interp.rkt} to correctly interpret these expressions.}
56-
57-
@item{Make examples of these primitives and potential translations of them
58-
to assembly.}
59-
60-
@item{Update @tt{compile.rkt} to correctly compile these expressions.}
61-
62-
@item{Check your implementation by running the tests in @tt{test/all.rkt}.}
63-
]
64-
65-
@section[#:tag-prefix "a3-" #:style 'unnumbered]{Conditional Evaluation with Cond}
66-
67-
The Dupe language we studied included a simple form of performing
68-
conditional evaluation of sub-expressions:
69-
70-
@racketblock[
71-
(if _e0 _e1 _e2)
72-
]
53+
@subsection[#:tag-prefix "a3-" #:style 'unnumbered]{Conditional expressions}
7354

74-
However, in the original paper on Lisp,
75-
@link["http://jmc.stanford.edu/articles/recursive.html"]{@emph{Recursive
76-
Functions of Symbolic Expressions and Their Computation by Machine,
77-
Part I}}, John McCarthy introduced a generalization of @racket[if]
78-
called ``conditional expressions,'' which we could add to our
79-
language with the following syntax:
55+
The following new conditional form is included in Dupe+:
8056

8157
@racketblock[
8258
(cond [_e-p1 _e-a1]
@@ -99,59 +75,9 @@ does not evaluate to @racket[#f] is found, in which case, the corresponding expr
9975
@racket[cond] expression. If no such @racket[_e-pi] exists, the
10076
expression @racket[_e-an]'s value is the value of the @racket[cond].
10177

102-
@;{
103-
The formal semantics can be defined as:
104-
105-
@(define ((rewrite s) lws)
106-
(define lhs (list-ref lws 2))
107-
(define rhs (list-ref lws 3))
108-
(list "" lhs (string-append " " (symbol->string s) " ") rhs ""))
109-
110-
@(require (only-in racket add-between))
111-
@(define-syntax-rule (show-judgment name i j)
112-
(with-unquote-rewriter
113-
(lambda (lw)
114-
(build-lw (lw-e lw) (lw-line lw) (lw-line-span lw) (lw-column lw) (lw-column-span lw)))
115-
(with-compound-rewriters (['+ (rewrite '+)]
116-
['- (rewrite '–)]
117-
['= (rewrite '=)]
118-
['!= (rewrite '≠)])
119-
(apply centered
120-
(add-between
121-
(build-list (- j i)
122-
(λ (n) (begin (judgment-form-cases (list (+ n i)))
123-
(render-judgment-form name))))
124-
(hspace 4))))))
125-
126-
@(show-judgment 𝑪 0 1)
127-
@(show-judgment 𝑪 1 2)
128-
}
129-
130-
Your task is to extend Dupe with this (restricted) form of @racket[cond].
131-
132-
To do this, you should:
133-
134-
@itemlist[
135-
@item{Study @tt{ast.rkt} to add appropriate AST nodes.}
136-
@item{Extend @tt{parse.rkt} to parse such expressions. (See @secref[#:tag-prefixes '("a3-")]{parse} for guidance.)}
137-
@item{Update @tt{interp-prim.rkt} and @tt{interp.rkt} to correctly interpret @racket[cond] expressions.}
138-
139-
@item{Make examples of @racket[cond]-expressions and potential translations of them
140-
to assembly.}
141-
142-
@item{Update @tt{compile.rkt} to correctly compile @racket[cond]
143-
expressions based on your examples.}
144-
145-
@item{Check your implementation by running the tests in @tt{test/all.rkt}.}
146-
]
147-
148-
@section[#:tag-prefix "a3-" #:style 'unnumbered]{Dispatching Evaluation with Case}
149-
78+
@subsection[#:tag-prefix "a3-" #:style 'unnumbered]{Case expressions}
15079

151-
Racket has a mechanism for dispatching between a number of possible
152-
expressions based on a value, much like C's notion of a
153-
@tt{switch}-statement. This is the @racket[case]-expression, which we
154-
could add to our language with the following syntax:
80+
The following new case form is included in Dupe+:
15581

15682
@racketblock[
15783
(case _ev
@@ -160,6 +86,10 @@ could add to our language with the following syntax:
16086
[else _en])
16187
]
16288

89+
The @racket[case] expression form is a mechanism for dispatching
90+
between a number of possible expressions based on a value, much like
91+
C's notion of a @tt{switch}-statement.
92+
16393
The meaning of a @racket[case] expression is computed by evaluating
16494
the expression @racket[_ev] and then proceeding in order through each
16595
clause until one is found that has a datum @racket[_di] equal to
@@ -173,8 +103,65 @@ Note that each clause consists of a parenthesized list of
173103
@emph{datums}, which in the setting of Dupe means either integer or
174104
boolean literals.
175105

176-
Your task is to extend Dupe with this (restricted) form of @racket[case].
106+
107+
@section[#:tag-prefix "a3-" #:style 'unnumbered]{Part 2}
108+
109+
For this part of the assignment, you must extend the parser,
110+
interpreter, and compiler to implement Dupe+. You are given a file
111+
@tt{dupe-plus.zip} on ELMS with a starter compiler based on the
112+
@secref{Dupe} language we studied in class.
113+
114+
You may use any a86 instructions you'd like, however it is possible to
115+
complete the assignment using @racket[Cmp], @racket[Je], @racket[Jg],
116+
@racket[Jmp], @racket[Label], @racket[Mov], and @racket[Sub].
117+
118+
@subsection[#:tag-prefix "a3-" #:style 'unnumbered]{Implementing primitives}
119+
120+
Implement the primitives as described earlier.
121+
122+
There are many ways to implement these at the assembly level. You should try implementing
123+
these using the limited a86 instruction set.
177124

125+
To do this, you should:
126+
@itemlist[
127+
@item{Study @tt{ast.rkt} and the new forms of expression (i.e. new AST nodes)
128+
then update the comment at the top describing what the grammmar should look like.}
129+
130+
@item{Study @tt{parse.rkt} and add support for parsing these
131+
expressions. (See @secref[#:tag-prefixes '("a3-")]{parse} for guidance.)}
132+
133+
@item{Update @tt{interp-prim.rkt} and @tt{interp.rkt} to correctly interpret these expressions.}
134+
135+
@item{Make examples of these primitives and potential translations of them
136+
to assembly.}
137+
138+
@item{Update @tt{compile.rkt} to correctly compile these expressions.}
139+
140+
@item{Check your implementation by running the tests in @tt{test/all.rkt}.}
141+
]
142+
143+
@section[#:tag-prefix "a3-" #:style 'unnumbered]{Implementing cond}
144+
145+
Implement the @racket[cond] expression form as described earlier.
146+
To do this, you should:
147+
148+
@itemlist[
149+
@item{Study @tt{ast.rkt} to add appropriate AST nodes.}
150+
@item{Extend @tt{parse.rkt} to parse such expressions. (See @secref[#:tag-prefixes '("a3-")]{parse} for guidance.)}
151+
@item{Update @tt{interp-prim.rkt} and @tt{interp.rkt} to correctly interpret @racket[cond] expressions.}
152+
153+
@item{Make examples of @racket[cond]-expressions and potential translations of them
154+
to assembly.}
155+
156+
@item{Update @tt{compile.rkt} to correctly compile @racket[cond]
157+
expressions based on your examples.}
158+
159+
@item{Check your implementation by running the tests in @tt{test/all.rkt}.}
160+
]
161+
162+
@section[#:tag-prefix "a3-" #:style 'unnumbered]{Implementing case}
163+
164+
Implement the @racket[case] expression form as described earlier.
178165
To do this, you should:
179166

180167
@itemlist[
@@ -292,6 +279,8 @@ write additional test cases.
292279

293280
@section[#:tag-prefix "a3-" #:style 'unnumbered]{Submitting}
294281

295-
Submit a zip file containing your work to Gradescope. Use @tt{make
296-
submit.zip} from within the @tt{dupe-plus} directory to create a zip
297-
file with the proper structure.
282+
For part 1, submit to Gradescope a zip file containing well-formed
283+
Racket files that use the @tt{.rkt} file extension.
284+
285+
For part 2, use @tt{make} from within the @tt{dupe-plus} directory to
286+
create a zip file containing your work and submit it to Gradescope.

www/midterms.scrbl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
@title[#:style '(toc unnumbered)]{Midterms}
44

55
There will be two midterm examinations, which will be @bold{take-home}
6-
exams. Exams will be distributed at least 48 hours before the due
6+
exams. Exams will be distributed at least @midterm-hours hours before the due
77
date of the midterm.
88

99
@itemlist[

www/midterms/1.scrbl

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@
1010
Midterm 1 will be released at least @midterm-hours hours prior to
1111
its due date.
1212

13-
@;{
13+
@section{Practice}
14+
15+
There is a practice midterm from Summer 2023 available on ELMS as
16+
@tt{m1-summer-2023.zip}. You may submit to the Practice Midterm 1 -
17+
Summer 2023 assignment on Gradescope to get feedback on your solution.
18+
However during the real midterm, you will not get this level of
19+
feedback from the autograder.
20+
1421
@section{Instructions}
1522

1623
The midterm will be released as a zip file @tt{m1.zip} on ELMS.
@@ -22,14 +29,14 @@ midterm.
2229

2330
@section{Communications}
2431

25-
If you have questions about the exam, send a DM to ModMail on Discord.
26-
This will go to the entire course staff.
32+
If you have questions about the exam, send a @bold{private} message on
33+
Piazza.
2734

28-
Answers to common clarifying questions will be posted to the
29-
@tt{#midterm1} channel on Discord.
35+
Answers to common clarifying questions will be posted to
36+
Piazza.
3037

3138
If you have trouble reaching the course staff via Discord, email
32-
@tt{@prof-email}.
39+
@tt{@prof1-email}.
3340

3441
You may not communicate with anyone outside of the course staff about
3542
the midterm.
@@ -47,4 +54,4 @@ If you fail these tests, we will not be able to grade your submission.
4754
Passing these tests only means your submission is well-formed. Your
4855
actual grade will be computed after the deadline.
4956

50-
You are encouraged to check your own work.}
57+
You are encouraged to check your own work.

www/schedule.scrbl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,23 @@
4545
@itemlist[@item{@secref["Con"]}
4646
@item{@secref["Dupe"]}])
4747

48+
(list @wk{2/19}
49+
@elem{@seclink["Assignment 2"]{A3} P1}
50+
@itemlist[@item{@secref["Dodger"]}
51+
@item{@secref["Evildoer"]}]
52+
@secref["Extort"])
53+
54+
(list @wk{2/26}
55+
@elem{@seclink["Assignment 2"]{A3} P2}
56+
@secref{Fraud}
57+
@secref{Fraud})
58+
59+
(list @wk{3/4}
60+
""
61+
@secref{Hustle}
62+
@secref["Midterm_1"])
63+
64+
4865
#|
4966
(list @wk{9/25}
5067
@seclink["Assignment 3"]{A3}

0 commit comments

Comments
 (0)