From 5f1ef531432b3824633278c0957f98af7cd872bf Mon Sep 17 00:00:00 2001 From: David Van Horn Date: Mon, 28 Aug 2023 15:00:59 -0400 Subject: [PATCH 1/9] Updates for Fall 2023. --- www/defns.rkt | 52 +++++++++++++++++++++++++++------------- www/main.scrbl | 16 +++++++++---- www/midterms/1.scrbl | 3 ++- www/midterms/2.scrbl | 2 ++ www/project.scrbl | 5 ++++ www/schedule.scrbl | 57 +++++++++++++++++++++++++++++++++++++++++++- www/syllabus.scrbl | 45 +++++++++++++++++----------------- 7 files changed, 135 insertions(+), 45 deletions(-) diff --git a/www/defns.rkt b/www/defns.rkt index 06cb1672..3f45faba 100644 --- a/www/defns.rkt +++ b/www/defns.rkt @@ -2,39 +2,57 @@ (provide (all-defined-out)) (require scribble/core scribble/html-properties scribble/manual) -(define prof (link "https://www.cs.umd.edu/~dvanhorn/" "David Van Horn")) -(define prof-pronouns "he/him") -(define prof-email "dvanhorn@cs.umd.edu") -(define prof-initials "DVH") +(define prof1 (link "https://jmct.cc" "José Manuel Calderón Trilla")) +(define prof1-pronouns "he/him") +(define prof1-email "jmct@cs.umd.edu") +(define prof1-initials "JMCT") -(define semester "summer") +(define prof2 (link "https://www.cs.umd.edu/~dvanhorn/" "David Van Horn")) +(define prof2-pronouns "he/him") +(define prof2-email "dvanhorn@cs.umd.edu") +(define prof2-initials "DVH") + +(define semester "fall") (define year "2023") (define courseno "CMSC 430") -(define lecture-dates "May 30 -- July 7, 2023") +(define lecture-dates "" #;"May 30 -- July 7, 2023") (define IRB "IRB") (define AVW "AVW") (define KEY "KEY") -(define m1-date "June 14") -(define m2-date "June 29") +(define m1-date "TBD") +(define m2-date "TBD") (define midterm-hours "24") ; for summer -(define final-date "July 7") -(define elms-url "https://umd.instructure.com/courses/1345891/") +(define final-date "TBD") +(define elms-url "TBD") -(define racket-version "8.7") +(define racket-version "8.10") (define staff - (list (list "William Wegand" "wwegand@terpmail.umd.edu" "3:00-4:00PM MTWThF") - (list "Pierce Darragh" "pdarragh@umd.edu" "10:30-11:30AM MTWTh") + (list #;(list "William Wegand" "wwegand@terpmail.umd.edu" "3:00-4:00PM MTWThF") + (list "Pierce Darragh" "pdarragh@umd.edu" "TBD") + (list "Fuxiao Liu" "fl3es@umd.edu" "TBD") + (list "Vivian Chen" "vchen8@terpmail.umd.edu" "TBD") + (list "Ian Morrill" "imorrill@terpmail.umd.edu" "TBD") + (list "Matthew Schneider" "mgl@umd.edu" "TBD") + (list "Rhea Jajodia" "rjajodia@terpmail.umd.edu" "TBD") + (list "Syed Zaidi" "szaidi@umd.edu" "TBD") + (list "William Wegand" "wfweg@verizon.net" "TBD") + (list "Wilson Smith" "smith@umd.edu" "TBD") + (list "Yuhwan Lee" "ylee9251@terpmail.umd.edu" "TBD") )) -(define lecture-schedule "Weekdays, 12:30pm - 1:50pm") -(define classroom (link "https://umd.zoom.us/j/99876119693?pwd=d0h3aWRML2dka3dzbElVSHdMeVBEZz09" "Zoom")) +(define lecture-schedule1 "MW, 2:00-3:15pm") +(define lecture-schedule2 "MW, 3:30-4:45pm") + +(define classroom1 "BRB 1101") +(define classroom2 "IRB 0318") -(define discord "https://discord.gg/Me7XFYC8") -(define gradescope "https://www.gradescope.com/courses/533338") +(define discord "TBD") +(define piazza "TBD") +(define gradescope "TBD") diff --git a/www/main.scrbl b/www/main.scrbl index 35445b48..442b44ff 100644 --- a/www/main.scrbl +++ b/www/main.scrbl @@ -21,9 +21,16 @@ @emph{@string-titlecase[semester], @year} -@emph{Lectures: @lecture-schedule, @classroom} +@emph{Sections:} +@itemlist[ +@item{0101: @lecture-schedule2, @classroom2 + +@emph{Professor}: @prof2} + +@item{0201: @lecture-schedule1, @classroom1 + +@emph{Professor}: @prof1}] -@emph{Professor: @prof (@prof-pronouns)} CMSC 430 is an introduction to compilers. Its major goal is to arm students with the ability to design, implement, and extend a @@ -35,10 +42,11 @@ implement several related languages. #:row-properties '(bottom-border ()) (list* (list @bold{Staff} 'cont 'cont) (list @bold{Name} @elem{@bold{E-mail}} @elem{@bold{Hours}}) - (list prof prof-email "By appt.") + (list prof1 prof1-email "TBD") + (list prof2 prof2-email "TBD") staff)] -@bold{Communications:} @link[@elms-url]{ELMS}, @link[@discord]{Discord} +@bold{Communications:} @link[@elms-url]{ELMS}, @link[@piazza]{Piazza} @bold{Assumptions:} This course assumes you know the material in CMSC 330 and CMSC 216. In particular, you need to know how to program in a functional diff --git a/www/midterms/1.scrbl b/www/midterms/1.scrbl index 1de96f45..e72491d3 100644 --- a/www/midterms/1.scrbl +++ b/www/midterms/1.scrbl @@ -10,6 +10,7 @@ Midterm 1 will be released at least @midterm-hours hours prior to its due date. +@;{ @section{Instructions} The midterm will be released as a zip file @tt{m1.zip} on ELMS. @@ -46,4 +47,4 @@ If you fail these tests, we will not be able to grade your submission. Passing these tests only means your submission is well-formed. Your actual grade will be computed after the deadline. -You are encouraged to check your own work. \ No newline at end of file +You are encouraged to check your own work.} \ No newline at end of file diff --git a/www/midterms/2.scrbl b/www/midterms/2.scrbl index f464a3f5..6d3f5788 100644 --- a/www/midterms/2.scrbl +++ b/www/midterms/2.scrbl @@ -12,6 +12,7 @@ Midterm 2 will be released at least @midterm-hours hours prior to its due date. +@;{ @section{Instructions} The midterm will be released as a zip file @tt{m2.zip} on ELMS. @@ -40,3 +41,4 @@ You should submit your work as a single zip file of this directory on Gradescope. Unlike past assignments, Gradescope will not provide feedback on the correctness of your solutions so you are encouraged to check your own work. +} \ No newline at end of file diff --git a/www/project.scrbl b/www/project.scrbl index 5c5e9220..fce2d36f 100644 --- a/www/project.scrbl +++ b/www/project.scrbl @@ -9,6 +9,10 @@ The final assessment for this course consists of an individually completed project. +Details to be released later in the semester. + +@;{ + Final deliverables are due on the last day of class, July 7. @elem[#:style "strike"]{There are several projects to choose from, @@ -656,3 +660,4 @@ The @tt{} should be @tt{iniquity}, @tt{loot}, etc. and should be the same as the directory that contains the implementation. +} \ No newline at end of file diff --git a/www/schedule.scrbl b/www/schedule.scrbl index c87e0350..e3ec50d7 100644 --- a/www/schedule.scrbl +++ b/www/schedule.scrbl @@ -14,6 +14,61 @@ @(define (day s) @elem[s]) +@tabular[#:style 'boxed + #:sep @hspace[1] + #:row-properties '(bottom-border) + (list (list @bold{Week} @bold{Due} @bold{Monday} @bold{Wednesday}) + (list @wk{8/28} + "" + @secref["Intro"] + @elem{@secref["OCaml to Racket"]}) + + + (list @wk{9/4} + @seclink["Assignment 1"]{A1} + @elem{Labor day (no lecture)} + @elem{@secref["OCaml to Racket"], cont.}) + + (list @wk{9/11} + @seclink["Assignment 2"]{A2} + @elem{@secref["a86"]} + @elem{@secref["Abscond"]}) + + (list @wk{9/18} + "" + @itemlist[@item{@secref["Blackmail"]} @item{@secref["Con"]}] + @itemlist[@item{@secref["Dupe"]} @item{@secref{Dodger}}]) + + (list @wk{9/25} + "" + @secref["Evildoer"] + @secref["Extort"]) + + (list @wk{10/2} + "" + @secref["Fraud"] + @secref["Hustle"]) + + (list @wk{10/9} + "" + @secref["Hoax"] + "") + + (list @wk{10/16} + "" + "" + "") + + (list @wk{10/23} "" "" "") + (list @wk{10/30} "" "" "") + (list @wk{11/6} "" "" "") + (list @wk{11/13} "" "" "") + (list @wk{11/20} "" "" "Thanksgiving break (no lecture)") + (list @wk{11/27} "" "" "") + (list @wk{12/4} "" "" "") + (list @wk{12/11} "" "" "") +)] +@;{ @tabular[#:style 'boxed #:sep @hspace[1] #:row-properties '(bottom-border) @@ -49,6 +104,6 @@ (list @day{7/7} "Slack" @secref{Project}) ) ] - +} @bold{Final project assessment: @|final-date|.} diff --git a/www/syllabus.scrbl b/www/syllabus.scrbl index 8e936517..03a95589 100644 --- a/www/syllabus.scrbl +++ b/www/syllabus.scrbl @@ -24,11 +24,11 @@ @bold{Term:} @string-titlecase[semester], @year -@bold{Professor:} @prof (@prof-pronouns) +@bold{Professors:} @prof1 (@prof1-pronouns), @prof2 (@prof2-pronouns) -@bold{Email:} @prof-email +@bold{Email:} @prof1-email, @prof2-email -@bold{Office Hours:} By appointment. Send email or Discord DM to set +@bold{Office Hours:} By appointment. Send email or ELMS message to set up. @bold{Prerequisite:} a grade of C or better in CMSC330; and permission @@ -36,11 +36,13 @@ of department; or CMSC graduate student. @bold{Credits:} 3. -@bold{Lecture dates:} @lecture-dates +@;{@bold{Lecture dates:} @lecture-dates} -@bold{Lecture Times:} @lecture-schedule +@bold{Lectures:} +@itemlist[ +@item{0101: @lecture-schedule2, @classroom2} +@item{0201: @lecture-schedule1, @classroom1}] -@bold{Classroom:} @classroom @bold{Course Description:} @courseno is an introduction to compilers. Its major goal is to arm students with the ability to design, @@ -54,8 +56,8 @@ OCaml from CMSC 330, and, to a lesser extent, imperative programming in C and Assembly as covered in CMSC 216. -@bold{Course Structure:} The course will consist of synchronous -@bold{zoom} lectures, which will be recorded and available on ELMS +@bold{Course Structure:} The course will consist of +in-person lectures, which will be recorded and available on ELMS immediately after each lecture. There are two midterms, a final project, which counts as the final assessment for the class, several assignments, and several quizes and surveys. Midterms are take-home @@ -107,11 +109,12 @@ and we ask you to do the same for all of your fellow Terps. @bold{Communication with Instructor:} -Email: If you need to reach out and communicate with @prof, please -email at @|prof-email|. Please DO NOT email questions that are easily -found in the syllabus or on ELMS (i.e. When is this assignment due? -How much is it worth? etc.) but please DO reach out about personal, -academic, and intellectual concerns/questions. +Email: If you need to reach out and communicate with @prof1 or @prof2, +please email at @|prof1-email| or @|prof2-email|. Please DO NOT email +questions that are easily found in the syllabus or on ELMS (i.e. When +is this assignment due? How much is it worth? etc.) but please DO +reach out about personal, academic, and intellectual +concerns/questions. ELMS: IMPORTANT announcements will be sent via ELMS messaging. You must make sure that your email & announcement notifications (including @@ -147,9 +150,7 @@ hindered by the learning environment. @section{Office Hours} -Office hours will be held on @link[@discord]{this discord -server}. Make sure that your 'nickname' is set to something appropriate for -class. +Office hours will be held online and in-person. Details TBD. @;{Please make sure that you fill out @link["https://docs.google.com/spreadsheets/d/1sDCpekBHIGjVSuGDsabPb74wZ5nHA_sTLvIPOzTUQ4k/edit?usp=sharing"]{ @@ -162,7 +163,7 @@ up repeatedly, the staff can make an announcement that addresses the concern for the entire class. Lastly, it helps the course staff keep an eye on what topics might need more attention.} -The discord server is there for you to organize as a class, ask questions of +@;{The discord server is there for you to organize as a class, ask questions of each other, and to get help from staff. Its main purpose is as a vehicle for office hours. That said, feel free to use the discord for discussion. I (@prof-initials) will check periodically, but if you would like to ask a question directly to @@ -172,7 +173,7 @@ communication. There is a channel '#course-discussion' that is meant for discussion/questions/help regarding the material of the course, make sure that you keep that channel free from noise so that other students and course staff -can easily see what issues are being brought up. +can easily see what issues are being brought up.} @section{Topics} @@ -305,7 +306,7 @@ will be provided during office hours. Office hours for the instructional staff will be posted on the course web page. Additional assistance will provided via discussion on -@link[@discord]{Discord}. You may use this forum to ask general +@link[@piazza]{Piazza}. You may use this forum to ask general questions of interest to the class as a whole, e.g., administrative issues or problem set clarification questions. The course staff will monitor it on a daily basis, but do not expect immediate answers to @@ -313,15 +314,15 @@ questions. Please do not post publicly any information that would violate the university academic integrity policy (e.g., problem set code). -Discord allows students to send private questions that are only +@;{Discord allows students to send private questions that are only visible to instructors. Please use this feature if you wish to ask -specific questions concerning your assignment solutions. +specific questions concerning your assignment solutions.} Personal e-mail to TAs should be reserved for issues that cannot be handled by the above methods. Important announcements will be made in class or on the class web -page, and via Discord. +page, and via Piazza. @section{Excused Absences} From b77760a269e96c9fc34306f651981ad2895a2dd5 Mon Sep 17 00:00:00 2001 From: David Van Horn Date: Mon, 28 Aug 2023 16:59:01 -0400 Subject: [PATCH 2/9] Update push target in Makefile. --- www/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/Makefile b/www/Makefile index b396413d..edd4b170 100644 --- a/www/Makefile +++ b/www/Makefile @@ -32,7 +32,7 @@ scribble: $(course).scrbl push: - rsync -rvzp main/ dvanhorn@junkfood.cs.umd.edu:/fs/www/class/summer2023/cmsc430/ + rsync -rvzp main/ dvanhorn@junkfood.cs.umd.edu:/fs/www/class/fall2023/cmsc430/ clean: rm -rf $(course) From dae2a3dae5328fda49aead6acccd80591b236488 Mon Sep 17 00:00:00 2001 From: David Van Horn Date: Mon, 28 Aug 2023 16:59:11 -0400 Subject: [PATCH 3/9] Remove assignments for now. --- www/assignments.scrbl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/www/assignments.scrbl b/www/assignments.scrbl index f491b014..4ad05e98 100644 --- a/www/assignments.scrbl +++ b/www/assignments.scrbl @@ -4,11 +4,11 @@ @local-table-of-contents[#:style 'immediate-only] @include-section{assignments/1.scrbl} -@include-section{assignments/2.scrbl} -@include-section{assignments/3.scrbl} -@include-section{assignments/4.scrbl} -@include-section{assignments/5.scrbl} -@include-section{assignments/6.scrbl} +@;include-section{assignments/2.scrbl} +@;include-section{assignments/3.scrbl} +@;include-section{assignments/4.scrbl} +@;include-section{assignments/5.scrbl} +@;include-section{assignments/6.scrbl} @;;include-section{assignments/7.scrbl} @;{assignment 8: quote in general, and quasiquote} From 1da903967b0fa237529b585eb4e0ee610ef594ad Mon Sep 17 00:00:00 2001 From: David Van Horn Date: Tue, 29 Aug 2023 15:35:16 -0400 Subject: [PATCH 4/9] URLs and midterm dates. --- www/defns.rkt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/www/defns.rkt b/www/defns.rkt index 3f45faba..dc6525b0 100644 --- a/www/defns.rkt +++ b/www/defns.rkt @@ -23,11 +23,11 @@ (define KEY "KEY") -(define m1-date "TBD") -(define m2-date "TBD") +(define m1-date "Oct 11") +(define m2-date "Nov 20") (define midterm-hours "24") ; for summer (define final-date "TBD") -(define elms-url "TBD") +(define elms-url "https://umd.instructure.com/courses/1350066") (define racket-version "8.10") @@ -53,6 +53,6 @@ (define classroom1 "BRB 1101") (define classroom2 "IRB 0318") -(define discord "TBD") -(define piazza "TBD") -(define gradescope "TBD") +;(define discord "TBD") +(define piazza "https://piazza.com/class/llwlfinnxr63c0/") +(define gradescope "https://www.gradescope.com/courses/593113") From 83e5c078031d7c60af6908433829933751a14a21 Mon Sep 17 00:00:00 2001 From: David Van Horn Date: Tue, 29 Aug 2023 15:48:01 -0400 Subject: [PATCH 5/9] Midterms on schedule. --- www/schedule.scrbl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/schedule.scrbl b/www/schedule.scrbl index e3ec50d7..cff82eb8 100644 --- a/www/schedule.scrbl +++ b/www/schedule.scrbl @@ -52,7 +52,7 @@ (list @wk{10/9} "" @secref["Hoax"] - "") + @secref["Midterm_1"]) (list @wk{10/16} "" @@ -63,7 +63,7 @@ (list @wk{10/30} "" "" "") (list @wk{11/6} "" "" "") (list @wk{11/13} "" "" "") - (list @wk{11/20} "" "" "Thanksgiving break (no lecture)") + (list @wk{11/20} "" @secref["Midterm_2"] "Thanksgiving break (no lecture)") (list @wk{11/27} "" "" "") (list @wk{12/4} "" "" "") (list @wk{12/11} "" "" "") From 5e589c66b3099c3796690c615a650a61bf525606 Mon Sep 17 00:00:00 2001 From: David Van Horn Date: Mon, 18 Sep 2023 14:39:35 -0400 Subject: [PATCH 6/9] Office hour schedule. --- www/main.scrbl | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/www/main.scrbl b/www/main.scrbl index 442b44ff..3cea810a 100644 --- a/www/main.scrbl +++ b/www/main.scrbl @@ -40,12 +40,31 @@ implement several related languages. @tabular[#:style 'boxed #:row-properties '(bottom-border ()) - (list* (list @bold{Staff} 'cont 'cont) - (list @bold{Name} @elem{@bold{E-mail}} @elem{@bold{Hours}}) - (list prof1 prof1-email "TBD") - (list prof2 prof2-email "TBD") + (list* (list @bold{Staff} 'cont) + (list @bold{Name} @elem{@bold{E-mail}}) + (list prof1 prof1-email) + (list prof2 prof2-email) staff)] +@bold{Office hours:} AVW 4140 + +@tabular[#:style 'boxed + #:row-properties '(bottom-border ()) + (list (list @bold{Time} @bold{Monday} @bold{Tuesday} @bold{Wednesday} @bold{Thursday} @bold{Friday}) + (list "9 AM" "William" 'cont "William" 'cont 'cont) + (list "10 AM" "William" 'cont "Ian, William" 'cont 'cont) + (list "11 AM" 'cont "Pierce" "Ian" 'cont "Pierce") + (list "12 PM" "Dalton, Fuxiao" "Pierce" "Dalton" 'cont "Pierce") + (list "1 PM" "Dalton, Fuxiao, Ian, Wilson" 'cont "Matthew, Wilson" "Fuxiao" "Wilson") + (list "2 PM" "Ian, Wilson" "Pierce" "Matthew" "Fuxiao, Pierce" 'cont) + (list "3 PM" "Matthew, Yuhwan" "Pierce" "Matthew, Yuhwan" "Pierce" "Vivian") + (list "4 PM" "Yuhwan" 'cont "Yuhwan, Dalton" 'cont 'cont) + (list "5 PM" 'cont "Vivian" 'cont "Vivian" 'cont) + (list "6 PM" 'cont 'cont 'cont "Vivian" 'cont))] + + + + @bold{Communications:} @link[@elms-url]{ELMS}, @link[@piazza]{Piazza} @bold{Assumptions:} This course assumes you know the material in CMSC 330 and @@ -59,7 +78,7 @@ change. Any substantive change will be accompanied with an announcement to the class via ELMS. @bold{Feedback:} We welcome anonymous feedback on the course and its -staff using this @link["https://docs.google.com/forms/d/e/1FAIpQLSdUNNY5Vun42xATeByf_V9JLce1hbDZuCd0Qj_YJo4z_e5vcA/viewform?usp=sf_link"]{form}. +staff using this @link[feedback]{form}. @include-section{syllabus.scrbl} @include-section{texts.scrbl} From df7fe03125e6983836736df00eba0e9709dd0346 Mon Sep 17 00:00:00 2001 From: David Van Horn Date: Mon, 18 Sep 2023 14:48:26 -0400 Subject: [PATCH 7/9] Un-Ziggy Abscond and Blackmail. --- langs/abscond/ast.rkt | 6 ++++++ langs/abscond/compile-stdin.rkt | 13 +++++++++++++ langs/abscond/compile.rkt | 19 +++++++++++++++++++ langs/abscond/interp-stdin.rkt | 12 ++++++++++++ langs/abscond/interp.rkt | 10 ++++++++++ langs/abscond/main.rkt | 13 +++++++++++++ langs/abscond/parse.rkt | 9 +++++++++ langs/abscond/run-stdin.rkt | 12 ++++++++++++ langs/abscond/run.rkt | 8 ++++++++ langs/abscond/test/compile.rkt | 8 ++++++++ langs/abscond/test/interp.rkt | 7 +++++++ langs/abscond/test/test-runner.rkt | 10 ++++++++++ langs/blackmail/ast.rkt | 11 +++++++++++ langs/blackmail/compile-ops.rkt | 13 +++++++++++++ langs/blackmail/compile-stdin.rkt | 13 +++++++++++++ langs/blackmail/compile.rkt | 26 ++++++++++++++++++++++++++ langs/blackmail/interp-prim.rkt | 9 +++++++++ langs/blackmail/interp-stdin.rkt | 12 ++++++++++++ langs/blackmail/interp.rkt | 13 +++++++++++++ langs/blackmail/main.rkt | 13 +++++++++++++ langs/blackmail/parse.rkt | 14 ++++++++++++++ langs/blackmail/run-stdin.rkt | 12 ++++++++++++ langs/blackmail/run.rkt | 8 ++++++++ langs/blackmail/test/compile.rkt | 8 ++++++++ langs/blackmail/test/interp.rkt | 7 +++++++ langs/blackmail/test/test-runner.rkt | 14 ++++++++++++++ langs/installer.rkt | 2 +- 27 files changed, 301 insertions(+), 1 deletion(-) create mode 100644 langs/abscond/ast.rkt create mode 100644 langs/abscond/compile-stdin.rkt create mode 100644 langs/abscond/compile.rkt create mode 100644 langs/abscond/interp-stdin.rkt create mode 100644 langs/abscond/interp.rkt create mode 100644 langs/abscond/main.rkt create mode 100644 langs/abscond/parse.rkt create mode 100644 langs/abscond/run-stdin.rkt create mode 100644 langs/abscond/run.rkt create mode 100644 langs/abscond/test/compile.rkt create mode 100644 langs/abscond/test/interp.rkt create mode 100644 langs/abscond/test/test-runner.rkt create mode 100644 langs/blackmail/ast.rkt create mode 100644 langs/blackmail/compile-ops.rkt create mode 100644 langs/blackmail/compile-stdin.rkt create mode 100644 langs/blackmail/compile.rkt create mode 100644 langs/blackmail/interp-prim.rkt create mode 100644 langs/blackmail/interp-stdin.rkt create mode 100644 langs/blackmail/interp.rkt create mode 100644 langs/blackmail/main.rkt create mode 100644 langs/blackmail/parse.rkt create mode 100644 langs/blackmail/run-stdin.rkt create mode 100644 langs/blackmail/run.rkt create mode 100644 langs/blackmail/test/compile.rkt create mode 100644 langs/blackmail/test/interp.rkt create mode 100644 langs/blackmail/test/test-runner.rkt diff --git a/langs/abscond/ast.rkt b/langs/abscond/ast.rkt new file mode 100644 index 00000000..7e3cda7a --- /dev/null +++ b/langs/abscond/ast.rkt @@ -0,0 +1,6 @@ +#lang racket +(provide Lit) + +;; type Expr = (Lit Integer) + +(struct Lit (i) #:prefab) diff --git a/langs/abscond/compile-stdin.rkt b/langs/abscond/compile-stdin.rkt new file mode 100644 index 00000000..532ee0eb --- /dev/null +++ b/langs/abscond/compile-stdin.rkt @@ -0,0 +1,13 @@ +#lang racket +(provide main) +(require "parse.rkt") +(require "compile.rkt") +(require a86/printer) + +;; -> Void +;; Compile contents of stdin, +;; emit asm code on stdout +(define (main) + (read-line) ; ignore #lang racket line + (asm-display (compile (parse (read))))) + diff --git a/langs/abscond/compile.rkt b/langs/abscond/compile.rkt new file mode 100644 index 00000000..b3212737 --- /dev/null +++ b/langs/abscond/compile.rkt @@ -0,0 +1,19 @@ +#lang racket +(provide (all-defined-out)) +(require "ast.rkt") +(require a86/ast) + +(define rax 'rax) + +;; Expr -> Asm +(define (compile e) + (prog (Global 'entry) + (Label 'entry) + (compile-e e) + (Ret))) + +;; Expr -> Asm +(define (compile-e e) + (match e + [(Lit i) (seq (Mov rax i))])) + diff --git a/langs/abscond/interp-stdin.rkt b/langs/abscond/interp-stdin.rkt new file mode 100644 index 00000000..ce4885f7 --- /dev/null +++ b/langs/abscond/interp-stdin.rkt @@ -0,0 +1,12 @@ +#lang racket +(provide main) +(require "parse.rkt") +(require "interp.rkt") + +;; -> Void +;; Parse and interpret contents of stdin, +;; print result on stdout +(define (main) + (read-line) ; ignore #lang racket line + (println (interp (parse (read))))) + diff --git a/langs/abscond/interp.rkt b/langs/abscond/interp.rkt new file mode 100644 index 00000000..c4b71b31 --- /dev/null +++ b/langs/abscond/interp.rkt @@ -0,0 +1,10 @@ +#lang racket +(provide interp) +(require "ast.rkt") + +;; Expr -> Integer +(define (interp e) + (match e + [(Lit i) i])) + + diff --git a/langs/abscond/main.rkt b/langs/abscond/main.rkt new file mode 100644 index 00000000..e0e38924 --- /dev/null +++ b/langs/abscond/main.rkt @@ -0,0 +1,13 @@ +#lang racket +(require "ast.rkt") +(require "parse.rkt") +(require "interp.rkt") +(require "compile.rkt") +(require "run.rkt") +(provide (all-from-out "ast.rkt")) +(provide (all-from-out "parse.rkt")) +(provide (all-from-out "interp.rkt")) +(provide (all-from-out "compile.rkt")) +(provide (all-from-out "run.rkt")) + + diff --git a/langs/abscond/parse.rkt b/langs/abscond/parse.rkt new file mode 100644 index 00000000..fb1b6198 --- /dev/null +++ b/langs/abscond/parse.rkt @@ -0,0 +1,9 @@ +#lang racket +(provide parse) +(require "ast.rkt") + +;; S-Expr -> Expr +(define (parse s) + (match s + [(? exact-integer?) (Lit s)] + [_ (error "Parse error")])) diff --git a/langs/abscond/run-stdin.rkt b/langs/abscond/run-stdin.rkt new file mode 100644 index 00000000..16cf99e0 --- /dev/null +++ b/langs/abscond/run-stdin.rkt @@ -0,0 +1,12 @@ +#lang racket +(provide main) +(require "parse.rkt") +(require "compile.rkt") +(require "run.rkt") + +;; -> Void +;; Compile contents of stdin and use asm-interp to run +(define (main) + (read-line) ; ignore #lang racket line + (run (compile (parse (read))))) + diff --git a/langs/abscond/run.rkt b/langs/abscond/run.rkt new file mode 100644 index 00000000..1191f553 --- /dev/null +++ b/langs/abscond/run.rkt @@ -0,0 +1,8 @@ +#lang racket +(require a86/interp) +(provide run) + +;; Asm -> Integer +(define (run is) + (asm-interp is)) + diff --git a/langs/abscond/test/compile.rkt b/langs/abscond/test/compile.rkt new file mode 100644 index 00000000..560e6f59 --- /dev/null +++ b/langs/abscond/test/compile.rkt @@ -0,0 +1,8 @@ +#lang racket +(require "../compile.rkt") +(require "../parse.rkt") +(require "../run.rkt") +(require "test-runner.rkt") + +(test (λ (e) (run (compile (parse e))))) + diff --git a/langs/abscond/test/interp.rkt b/langs/abscond/test/interp.rkt new file mode 100644 index 00000000..41aa8c04 --- /dev/null +++ b/langs/abscond/test/interp.rkt @@ -0,0 +1,7 @@ +#lang racket +(require "../interp.rkt") +(require "../parse.rkt") +(require "test-runner.rkt") + +(test (λ (e) (interp (parse e)))) + diff --git a/langs/abscond/test/test-runner.rkt b/langs/abscond/test/test-runner.rkt new file mode 100644 index 00000000..829c996f --- /dev/null +++ b/langs/abscond/test/test-runner.rkt @@ -0,0 +1,10 @@ +#lang racket +(provide test) +(require rackunit) + +(define (test run) + (begin ;; Abscond + (check-equal? (run 7) 7) + (check-equal? (run -8) -8))) + + diff --git a/langs/blackmail/ast.rkt b/langs/blackmail/ast.rkt new file mode 100644 index 00000000..c882e675 --- /dev/null +++ b/langs/blackmail/ast.rkt @@ -0,0 +1,11 @@ +#lang racket +(provide Lit Prim1) + +;; type Expr = (Lit Integer) +;; | (Prim1 Op1 Expr) + +;; type Op1 = 'add1 | 'sub1 + +(struct Lit (i) #:prefab) +(struct Prim1 (p e) #:prefab) + diff --git a/langs/blackmail/compile-ops.rkt b/langs/blackmail/compile-ops.rkt new file mode 100644 index 00000000..8f6bd44c --- /dev/null +++ b/langs/blackmail/compile-ops.rkt @@ -0,0 +1,13 @@ +#lang racket +(provide compile-op1) +(require "ast.rkt") +(require a86/ast) + +(define rax 'rax) + +;; Op1 -> Asm +(define (compile-op1 p) + (match p + ['add1 (Add rax 1)] + ['sub1 (Sub rax 1)])) + diff --git a/langs/blackmail/compile-stdin.rkt b/langs/blackmail/compile-stdin.rkt new file mode 100644 index 00000000..532ee0eb --- /dev/null +++ b/langs/blackmail/compile-stdin.rkt @@ -0,0 +1,13 @@ +#lang racket +(provide main) +(require "parse.rkt") +(require "compile.rkt") +(require a86/printer) + +;; -> Void +;; Compile contents of stdin, +;; emit asm code on stdout +(define (main) + (read-line) ; ignore #lang racket line + (asm-display (compile (parse (read))))) + diff --git a/langs/blackmail/compile.rkt b/langs/blackmail/compile.rkt new file mode 100644 index 00000000..24e9ee1a --- /dev/null +++ b/langs/blackmail/compile.rkt @@ -0,0 +1,26 @@ +#lang racket +(provide (all-defined-out)) +(require "ast.rkt") +(require "compile-ops.rkt") +(require a86/ast) + +(define rax 'rax) + +;; Expr -> Asm +(define (compile e) + (prog (Global 'entry) + (Label 'entry) + (compile-e e) + (Ret))) + +;; Expr -> Asm +(define (compile-e e) + (match e + [(Lit i) (seq (Mov rax i))] + [(Prim1 p e) (compile-prim1 p e)])) + +;; Op1 Expr -> Asm +(define (compile-prim1 p e) + (seq (compile-e e) + (compile-op1 p))) + diff --git a/langs/blackmail/interp-prim.rkt b/langs/blackmail/interp-prim.rkt new file mode 100644 index 00000000..2d3b7ffb --- /dev/null +++ b/langs/blackmail/interp-prim.rkt @@ -0,0 +1,9 @@ +#lang racket +(provide interp-prim1) + +;; Op1 Integer -> Integer +(define (interp-prim1 op i) + (match op + ['add1 (add1 i)] + ['sub1 (sub1 i)])) + diff --git a/langs/blackmail/interp-stdin.rkt b/langs/blackmail/interp-stdin.rkt new file mode 100644 index 00000000..ce4885f7 --- /dev/null +++ b/langs/blackmail/interp-stdin.rkt @@ -0,0 +1,12 @@ +#lang racket +(provide main) +(require "parse.rkt") +(require "interp.rkt") + +;; -> Void +;; Parse and interpret contents of stdin, +;; print result on stdout +(define (main) + (read-line) ; ignore #lang racket line + (println (interp (parse (read))))) + diff --git a/langs/blackmail/interp.rkt b/langs/blackmail/interp.rkt new file mode 100644 index 00000000..58d2fe6e --- /dev/null +++ b/langs/blackmail/interp.rkt @@ -0,0 +1,13 @@ +#lang racket +(provide interp) +(require "ast.rkt") +(require "interp-prim.rkt") + +;; Expr -> Integer +(define (interp e) + (match e + [(Lit i) i] + [(Prim1 p e) + (interp-prim1 p (interp e))])) + + diff --git a/langs/blackmail/main.rkt b/langs/blackmail/main.rkt new file mode 100644 index 00000000..e0e38924 --- /dev/null +++ b/langs/blackmail/main.rkt @@ -0,0 +1,13 @@ +#lang racket +(require "ast.rkt") +(require "parse.rkt") +(require "interp.rkt") +(require "compile.rkt") +(require "run.rkt") +(provide (all-from-out "ast.rkt")) +(provide (all-from-out "parse.rkt")) +(provide (all-from-out "interp.rkt")) +(provide (all-from-out "compile.rkt")) +(provide (all-from-out "run.rkt")) + + diff --git a/langs/blackmail/parse.rkt b/langs/blackmail/parse.rkt new file mode 100644 index 00000000..0147dc46 --- /dev/null +++ b/langs/blackmail/parse.rkt @@ -0,0 +1,14 @@ +#lang racket +(provide parse) +(require "ast.rkt") + +;; S-Expr -> Expr +(define (parse s) + (match s + [(? exact-integer?) (Lit s)] + [(list (? op1? o) e) (Prim1 o (parse e))] + [_ (error "Parse error")])) + +(define (op1? x) + (memq x '(add1 sub1))) + diff --git a/langs/blackmail/run-stdin.rkt b/langs/blackmail/run-stdin.rkt new file mode 100644 index 00000000..16cf99e0 --- /dev/null +++ b/langs/blackmail/run-stdin.rkt @@ -0,0 +1,12 @@ +#lang racket +(provide main) +(require "parse.rkt") +(require "compile.rkt") +(require "run.rkt") + +;; -> Void +;; Compile contents of stdin and use asm-interp to run +(define (main) + (read-line) ; ignore #lang racket line + (run (compile (parse (read))))) + diff --git a/langs/blackmail/run.rkt b/langs/blackmail/run.rkt new file mode 100644 index 00000000..1191f553 --- /dev/null +++ b/langs/blackmail/run.rkt @@ -0,0 +1,8 @@ +#lang racket +(require a86/interp) +(provide run) + +;; Asm -> Integer +(define (run is) + (asm-interp is)) + diff --git a/langs/blackmail/test/compile.rkt b/langs/blackmail/test/compile.rkt new file mode 100644 index 00000000..560e6f59 --- /dev/null +++ b/langs/blackmail/test/compile.rkt @@ -0,0 +1,8 @@ +#lang racket +(require "../compile.rkt") +(require "../parse.rkt") +(require "../run.rkt") +(require "test-runner.rkt") + +(test (λ (e) (run (compile (parse e))))) + diff --git a/langs/blackmail/test/interp.rkt b/langs/blackmail/test/interp.rkt new file mode 100644 index 00000000..41aa8c04 --- /dev/null +++ b/langs/blackmail/test/interp.rkt @@ -0,0 +1,7 @@ +#lang racket +(require "../interp.rkt") +(require "../parse.rkt") +(require "test-runner.rkt") + +(test (λ (e) (interp (parse e)))) + diff --git a/langs/blackmail/test/test-runner.rkt b/langs/blackmail/test/test-runner.rkt new file mode 100644 index 00000000..1e736f48 --- /dev/null +++ b/langs/blackmail/test/test-runner.rkt @@ -0,0 +1,14 @@ +#lang racket +(provide test) +(require rackunit) + +(define (test run) + (begin ;; Abscond + (check-equal? (run 7) 7) + (check-equal? (run -8) -8)) + + (begin ;; Blackmail + (check-equal? (run '(add1 (add1 7))) 9) + (check-equal? (run '(add1 (sub1 7))) 7))) + + diff --git a/langs/installer.rkt b/langs/installer.rkt index 8b5368f2..0b20b6e4 100644 --- a/langs/installer.rkt +++ b/langs/installer.rkt @@ -9,7 +9,7 @@ (path->string f))) (main (path->string (collection-file-path "src/" "ziggy")) own - (cdr (assoc lang-name '(("abscond" . "A") + (cdr (assoc lang-name '(#;("abscond" . "A") ("blackmail" . "B") ("con" . "C") ("dupe" . "D0") From 049889df284abacec3600f3bf167abcf9704ef3a Mon Sep 17 00:00:00 2001 From: David Van Horn Date: Wed, 27 Sep 2023 13:06:10 -0400 Subject: [PATCH 8/9] Con and Dupe files. --- langs/con/ast.rkt | 13 ++++++++++ langs/con/compile-ops.rkt | 13 ++++++++++ langs/con/compile-stdin.rkt | 13 ++++++++++ langs/con/compile.rkt | 39 ++++++++++++++++++++++++++++ langs/con/interp-prim.rkt | 9 +++++++ langs/con/interp-stdin.rkt | 12 +++++++++ langs/con/interp.rkt | 16 ++++++++++++ langs/con/main.rkt | 13 ++++++++++ langs/con/parse.rkt | 17 ++++++++++++ langs/con/run-stdin.rkt | 12 +++++++++ langs/con/run.rkt | 8 ++++++ langs/con/test/compile.rkt | 8 ++++++ langs/con/test/interp.rkt | 7 +++++ langs/con/test/test-runner.rkt | 27 +++++++++++++++++++ langs/dupe/ast.rkt | 16 ++++++++++++ langs/dupe/compile-ops.rkt | 20 ++++++++++++++ langs/dupe/compile-stdin.rkt | 13 ++++++++++ langs/dupe/compile.rkt | 46 +++++++++++++++++++++++++++++++++ langs/dupe/interp-prim.rkt | 9 +++++++ langs/dupe/interp-stdin.rkt | 12 +++++++++ langs/dupe/interp.rkt | 19 ++++++++++++++ langs/dupe/main.rkt | 13 ++++++++++ langs/dupe/parse.rkt | 21 +++++++++++++++ langs/dupe/run-stdin.rkt | 12 +++++++++ langs/dupe/run.rkt | 7 +++++ langs/dupe/test/compile.rkt | 8 ++++++ langs/dupe/test/interp.rkt | 7 +++++ langs/dupe/test/test-runner.rkt | 39 ++++++++++++++++++++++++++++ langs/dupe/types.rkt | 21 +++++++++++++++ langs/installer.rkt | 6 ++--- 30 files changed, 473 insertions(+), 3 deletions(-) create mode 100644 langs/con/ast.rkt create mode 100644 langs/con/compile-ops.rkt create mode 100644 langs/con/compile-stdin.rkt create mode 100644 langs/con/compile.rkt create mode 100644 langs/con/interp-prim.rkt create mode 100644 langs/con/interp-stdin.rkt create mode 100644 langs/con/interp.rkt create mode 100644 langs/con/main.rkt create mode 100644 langs/con/parse.rkt create mode 100644 langs/con/run-stdin.rkt create mode 100644 langs/con/run.rkt create mode 100644 langs/con/test/compile.rkt create mode 100644 langs/con/test/interp.rkt create mode 100644 langs/con/test/test-runner.rkt create mode 100644 langs/dupe/ast.rkt create mode 100644 langs/dupe/compile-ops.rkt create mode 100644 langs/dupe/compile-stdin.rkt create mode 100644 langs/dupe/compile.rkt create mode 100644 langs/dupe/interp-prim.rkt create mode 100644 langs/dupe/interp-stdin.rkt create mode 100644 langs/dupe/interp.rkt create mode 100644 langs/dupe/main.rkt create mode 100644 langs/dupe/parse.rkt create mode 100644 langs/dupe/run-stdin.rkt create mode 100644 langs/dupe/run.rkt create mode 100644 langs/dupe/test/compile.rkt create mode 100644 langs/dupe/test/interp.rkt create mode 100644 langs/dupe/test/test-runner.rkt create mode 100644 langs/dupe/types.rkt diff --git a/langs/con/ast.rkt b/langs/con/ast.rkt new file mode 100644 index 00000000..d68c3e6f --- /dev/null +++ b/langs/con/ast.rkt @@ -0,0 +1,13 @@ +#lang racket +(provide Lit Prim1 IfZero) + +;; type Expr = (Lit Integer) +;; | (Prim1 Op1 Expr) +;; | (IfZero Expr Expr Expr) + +;; type Op1 = 'add1 | 'sub1 + +(struct Lit (i) #:prefab) +(struct Prim1 (p e) #:prefab) +(struct IfZero (e1 e2 e3) #:prefab) + diff --git a/langs/con/compile-ops.rkt b/langs/con/compile-ops.rkt new file mode 100644 index 00000000..8f6bd44c --- /dev/null +++ b/langs/con/compile-ops.rkt @@ -0,0 +1,13 @@ +#lang racket +(provide compile-op1) +(require "ast.rkt") +(require a86/ast) + +(define rax 'rax) + +;; Op1 -> Asm +(define (compile-op1 p) + (match p + ['add1 (Add rax 1)] + ['sub1 (Sub rax 1)])) + diff --git a/langs/con/compile-stdin.rkt b/langs/con/compile-stdin.rkt new file mode 100644 index 00000000..532ee0eb --- /dev/null +++ b/langs/con/compile-stdin.rkt @@ -0,0 +1,13 @@ +#lang racket +(provide main) +(require "parse.rkt") +(require "compile.rkt") +(require a86/printer) + +;; -> Void +;; Compile contents of stdin, +;; emit asm code on stdout +(define (main) + (read-line) ; ignore #lang racket line + (asm-display (compile (parse (read))))) + diff --git a/langs/con/compile.rkt b/langs/con/compile.rkt new file mode 100644 index 00000000..59f077a6 --- /dev/null +++ b/langs/con/compile.rkt @@ -0,0 +1,39 @@ +#lang racket +(provide (all-defined-out)) +(require "ast.rkt") +(require "compile-ops.rkt") +(require a86/ast) + +(define rax 'rax) +;; Expr -> Asm +(define (compile e) + (prog (Global 'entry) + (Label 'entry) + (compile-e e) + (Ret))) + +;; Expr -> Asm +(define (compile-e e) + (match e + [(Lit i) (seq (Mov rax i))] + [(Prim1 p e) (compile-prim1 p e)] + [(IfZero e1 e2 e3) + (compile-ifzero e1 e2 e3)])) + +;; Op1 Expr -> Asm +(define (compile-prim1 p e) + (seq (compile-e e) + (compile-op1 p))) + +;; Expr Expr Expr -> Asm +(define (compile-ifzero e1 e2 e3) + (let ((l1 (gensym 'ifz)) + (l2 (gensym 'ifz))) + (seq (compile-e e1) + (Cmp rax 0) + (Jne l1) + (compile-e e2) + (Jmp l2) + (Label l1) + (compile-e e3) + (Label l2)))) diff --git a/langs/con/interp-prim.rkt b/langs/con/interp-prim.rkt new file mode 100644 index 00000000..2d3b7ffb --- /dev/null +++ b/langs/con/interp-prim.rkt @@ -0,0 +1,9 @@ +#lang racket +(provide interp-prim1) + +;; Op1 Integer -> Integer +(define (interp-prim1 op i) + (match op + ['add1 (add1 i)] + ['sub1 (sub1 i)])) + diff --git a/langs/con/interp-stdin.rkt b/langs/con/interp-stdin.rkt new file mode 100644 index 00000000..ce4885f7 --- /dev/null +++ b/langs/con/interp-stdin.rkt @@ -0,0 +1,12 @@ +#lang racket +(provide main) +(require "parse.rkt") +(require "interp.rkt") + +;; -> Void +;; Parse and interpret contents of stdin, +;; print result on stdout +(define (main) + (read-line) ; ignore #lang racket line + (println (interp (parse (read))))) + diff --git a/langs/con/interp.rkt b/langs/con/interp.rkt new file mode 100644 index 00000000..30fc6e04 --- /dev/null +++ b/langs/con/interp.rkt @@ -0,0 +1,16 @@ +#lang racket +(provide interp) +(require "ast.rkt") +(require "interp-prim.rkt") + +;; Expr -> Integer +(define (interp e) + (match e + [(Lit i) i] + [(Prim1 p e) (interp-prim1 p (interp e))] + [(IfZero e1 e2 e3) + (if (zero? (interp e1)) + (interp e2) + (interp e3))])) + + diff --git a/langs/con/main.rkt b/langs/con/main.rkt new file mode 100644 index 00000000..e0e38924 --- /dev/null +++ b/langs/con/main.rkt @@ -0,0 +1,13 @@ +#lang racket +(require "ast.rkt") +(require "parse.rkt") +(require "interp.rkt") +(require "compile.rkt") +(require "run.rkt") +(provide (all-from-out "ast.rkt")) +(provide (all-from-out "parse.rkt")) +(provide (all-from-out "interp.rkt")) +(provide (all-from-out "compile.rkt")) +(provide (all-from-out "run.rkt")) + + diff --git a/langs/con/parse.rkt b/langs/con/parse.rkt new file mode 100644 index 00000000..792f883d --- /dev/null +++ b/langs/con/parse.rkt @@ -0,0 +1,17 @@ +#lang racket +(provide parse) +(require "ast.rkt") + +;; S-Expr -> Expr +(define (parse s) + (match s + [(? exact-integer?) (Lit s)] + [(list (? op1? o) e) (Prim1 o (parse e))] + ;; NEW: + [(list 'if (list 'zero? e1) e2 e3) + (IfZero (parse e1) (parse e2) (parse e3))] + [_ (error "Parse error")])) + +(define (op1? x) + (memq x '(add1 sub1))) + diff --git a/langs/con/run-stdin.rkt b/langs/con/run-stdin.rkt new file mode 100644 index 00000000..16cf99e0 --- /dev/null +++ b/langs/con/run-stdin.rkt @@ -0,0 +1,12 @@ +#lang racket +(provide main) +(require "parse.rkt") +(require "compile.rkt") +(require "run.rkt") + +;; -> Void +;; Compile contents of stdin and use asm-interp to run +(define (main) + (read-line) ; ignore #lang racket line + (run (compile (parse (read))))) + diff --git a/langs/con/run.rkt b/langs/con/run.rkt new file mode 100644 index 00000000..1191f553 --- /dev/null +++ b/langs/con/run.rkt @@ -0,0 +1,8 @@ +#lang racket +(require a86/interp) +(provide run) + +;; Asm -> Integer +(define (run is) + (asm-interp is)) + diff --git a/langs/con/test/compile.rkt b/langs/con/test/compile.rkt new file mode 100644 index 00000000..560e6f59 --- /dev/null +++ b/langs/con/test/compile.rkt @@ -0,0 +1,8 @@ +#lang racket +(require "../compile.rkt") +(require "../parse.rkt") +(require "../run.rkt") +(require "test-runner.rkt") + +(test (λ (e) (run (compile (parse e))))) + diff --git a/langs/con/test/interp.rkt b/langs/con/test/interp.rkt new file mode 100644 index 00000000..41aa8c04 --- /dev/null +++ b/langs/con/test/interp.rkt @@ -0,0 +1,7 @@ +#lang racket +(require "../interp.rkt") +(require "../parse.rkt") +(require "test-runner.rkt") + +(test (λ (e) (interp (parse e)))) + diff --git a/langs/con/test/test-runner.rkt b/langs/con/test/test-runner.rkt new file mode 100644 index 00000000..4428c634 --- /dev/null +++ b/langs/con/test/test-runner.rkt @@ -0,0 +1,27 @@ +#lang racket +(provide test) +(require rackunit) + +(define (test run) + (begin ;; Abscond + (check-equal? (run 7) 7) + (check-equal? (run -8) -8)) + + (begin ;; Blackmail + (check-equal? (run '(add1 (add1 7))) 9) + (check-equal? (run '(add1 (sub1 7))) 7)) + + (begin ;; Con + (check-equal? (run '(if (zero? 0) 1 2)) 1) + (check-equal? (run '(if (zero? 1) 1 2)) 2) + (check-equal? (run '(if (zero? -7) 1 2)) 2) + (check-equal? (run '(if (zero? 0) + (if (zero? 1) 1 2) + 7)) + 2) + (check-equal? (run '(if (zero? (if (zero? 0) 1 0)) + (if (zero? 1) 1 2) + 7)) + 7))) + + diff --git a/langs/dupe/ast.rkt b/langs/dupe/ast.rkt new file mode 100644 index 00000000..50183b13 --- /dev/null +++ b/langs/dupe/ast.rkt @@ -0,0 +1,16 @@ +#lang racket +(provide Lit Prim1 If) + +;; type Expr = (Lit Datum) +;; | (Prim1 Op1 Expr) +;; | (If Expr Expr Expr) + +;; type Datum = Integer +;; | Boolean + +;; type Op1 = 'add1 | 'sub1 +;; | 'zero? + +(struct Lit (d) #:prefab) +(struct Prim1 (p e) #:prefab) +(struct If (e1 e2 e3) #:prefab) diff --git a/langs/dupe/compile-ops.rkt b/langs/dupe/compile-ops.rkt new file mode 100644 index 00000000..0ef4ebc8 --- /dev/null +++ b/langs/dupe/compile-ops.rkt @@ -0,0 +1,20 @@ +#lang racket +(provide compile-op1) +(require "ast.rkt") +(require "types.rkt") +(require a86/ast) + +(define rax 'rax) +(define r9 'r9) + +;; Op1 -> Asm +(define (compile-op1 p) + (match p + ['add1 (Add rax (value->bits 1))] + ['sub1 (Sub rax (value->bits 1))] + ['zero? + (seq (Cmp rax 0) + (Mov rax (value->bits #f)) + (Mov r9 (value->bits #t)) + (Cmove rax r9))])) + diff --git a/langs/dupe/compile-stdin.rkt b/langs/dupe/compile-stdin.rkt new file mode 100644 index 00000000..532ee0eb --- /dev/null +++ b/langs/dupe/compile-stdin.rkt @@ -0,0 +1,13 @@ +#lang racket +(provide main) +(require "parse.rkt") +(require "compile.rkt") +(require a86/printer) + +;; -> Void +;; Compile contents of stdin, +;; emit asm code on stdout +(define (main) + (read-line) ; ignore #lang racket line + (asm-display (compile (parse (read))))) + diff --git a/langs/dupe/compile.rkt b/langs/dupe/compile.rkt new file mode 100644 index 00000000..fa817ac1 --- /dev/null +++ b/langs/dupe/compile.rkt @@ -0,0 +1,46 @@ +#lang racket +(provide (all-defined-out)) +(require "ast.rkt") +(require "compile-ops.rkt") +(require "types.rkt") +(require a86/ast) + +(define rax 'rax) + +;; Expr -> Asm +(define (compile e) + (prog (Global 'entry) + (Label 'entry) + (compile-e e) + (Ret))) + +;; Expr -> Asm +(define (compile-e e) + (match e + [(Lit d) (compile-value d)] + [(Prim1 p e) (compile-prim1 p e)] + [(If e1 e2 e3) + (compile-if e1 e2 e3)])) + +;; Value -> Asm +(define (compile-value v) + (seq (Mov rax (value->bits v)))) + +;; Op1 Expr -> Asm +(define (compile-prim1 p e) + (seq (compile-e e) + (compile-op1 p))) + +;; Expr Expr Expr -> Asm +(define (compile-if e1 e2 e3) + (let ((l1 (gensym 'if)) + (l2 (gensym 'if))) + (seq (compile-e e1) + (Cmp rax (value->bits #f)) + (Je l1) + (compile-e e2) + (Jmp l2) + (Label l1) + (compile-e e3) + (Label l2)))) + diff --git a/langs/dupe/interp-prim.rkt b/langs/dupe/interp-prim.rkt new file mode 100644 index 00000000..e0ea0720 --- /dev/null +++ b/langs/dupe/interp-prim.rkt @@ -0,0 +1,9 @@ +#lang racket +(provide interp-prim1) + +;; Op1 Value -> Value +(define (interp-prim1 op v) + (match op + ['add1 (add1 v)] + ['sub1 (sub1 v)] + ['zero? (zero? v)])) diff --git a/langs/dupe/interp-stdin.rkt b/langs/dupe/interp-stdin.rkt new file mode 100644 index 00000000..ce4885f7 --- /dev/null +++ b/langs/dupe/interp-stdin.rkt @@ -0,0 +1,12 @@ +#lang racket +(provide main) +(require "parse.rkt") +(require "interp.rkt") + +;; -> Void +;; Parse and interpret contents of stdin, +;; print result on stdout +(define (main) + (read-line) ; ignore #lang racket line + (println (interp (parse (read))))) + diff --git a/langs/dupe/interp.rkt b/langs/dupe/interp.rkt new file mode 100644 index 00000000..920f0920 --- /dev/null +++ b/langs/dupe/interp.rkt @@ -0,0 +1,19 @@ +#lang racket +(provide interp) +(require "ast.rkt") +(require "interp-prim.rkt") + +;; type Value = +;; | Integer +;; | Boolean + +;; Expr -> Value +(define (interp e) + (match e + [(Lit d) d] + [(Prim1 p e) + (interp-prim1 p (interp e))] + [(If e1 e2 e3) + (if (interp e1) + (interp e2) + (interp e3))])) diff --git a/langs/dupe/main.rkt b/langs/dupe/main.rkt new file mode 100644 index 00000000..e0e38924 --- /dev/null +++ b/langs/dupe/main.rkt @@ -0,0 +1,13 @@ +#lang racket +(require "ast.rkt") +(require "parse.rkt") +(require "interp.rkt") +(require "compile.rkt") +(require "run.rkt") +(provide (all-from-out "ast.rkt")) +(provide (all-from-out "parse.rkt")) +(provide (all-from-out "interp.rkt")) +(provide (all-from-out "compile.rkt")) +(provide (all-from-out "run.rkt")) + + diff --git a/langs/dupe/parse.rkt b/langs/dupe/parse.rkt new file mode 100644 index 00000000..673a0266 --- /dev/null +++ b/langs/dupe/parse.rkt @@ -0,0 +1,21 @@ +#lang racket +(provide parse) +(require "ast.rkt") + +;; S-Expr -> Expr +(define (parse s) + (match s + [(? datum?) (Lit s)] + [(list (? op1? o) e) (Prim1 o (parse e))] + [(list 'if e1 e2 e3) + (If (parse e1) (parse e2) (parse e3))] + [_ (error "Parse error")])) + +;; Any -> Boolean +(define (datum? x) + (or (exact-integer? x) + (boolean? x))) + +(define (op1? x) + (memq x '(add1 sub1 zero?))) + diff --git a/langs/dupe/run-stdin.rkt b/langs/dupe/run-stdin.rkt new file mode 100644 index 00000000..16cf99e0 --- /dev/null +++ b/langs/dupe/run-stdin.rkt @@ -0,0 +1,12 @@ +#lang racket +(provide main) +(require "parse.rkt") +(require "compile.rkt") +(require "run.rkt") + +;; -> Void +;; Compile contents of stdin and use asm-interp to run +(define (main) + (read-line) ; ignore #lang racket line + (run (compile (parse (read))))) + diff --git a/langs/dupe/run.rkt b/langs/dupe/run.rkt new file mode 100644 index 00000000..227703c1 --- /dev/null +++ b/langs/dupe/run.rkt @@ -0,0 +1,7 @@ +#lang racket +(require a86/interp) +(require "types.rkt") +(provide run);; Asm -> Value +(define (run is) + (bits->value (asm-interp is))) + diff --git a/langs/dupe/test/compile.rkt b/langs/dupe/test/compile.rkt new file mode 100644 index 00000000..560e6f59 --- /dev/null +++ b/langs/dupe/test/compile.rkt @@ -0,0 +1,8 @@ +#lang racket +(require "../compile.rkt") +(require "../parse.rkt") +(require "../run.rkt") +(require "test-runner.rkt") + +(test (λ (e) (run (compile (parse e))))) + diff --git a/langs/dupe/test/interp.rkt b/langs/dupe/test/interp.rkt new file mode 100644 index 00000000..41aa8c04 --- /dev/null +++ b/langs/dupe/test/interp.rkt @@ -0,0 +1,7 @@ +#lang racket +(require "../interp.rkt") +(require "../parse.rkt") +(require "test-runner.rkt") + +(test (λ (e) (interp (parse e)))) + diff --git a/langs/dupe/test/test-runner.rkt b/langs/dupe/test/test-runner.rkt new file mode 100644 index 00000000..7dcac9f1 --- /dev/null +++ b/langs/dupe/test/test-runner.rkt @@ -0,0 +1,39 @@ +#lang racket +(provide test) +(require rackunit) + +(define (test run) + (begin ;; Abscond + (check-equal? (run 7) 7) + (check-equal? (run -8) -8)) + + (begin ;; Blackmail + (check-equal? (run '(add1 (add1 7))) 9) + (check-equal? (run '(add1 (sub1 7))) 7)) + + (begin ;; Con + (check-equal? (run '(if (zero? 0) 1 2)) 1) + (check-equal? (run '(if (zero? 1) 1 2)) 2) + (check-equal? (run '(if (zero? -7) 1 2)) 2) + (check-equal? (run '(if (zero? 0) + (if (zero? 1) 1 2) + 7)) + 2) + (check-equal? (run '(if (zero? (if (zero? 0) 1 0)) + (if (zero? 1) 1 2) + 7)) + 7)) + + (begin ;; Dupe + (check-equal? (run #t) #t) + (check-equal? (run #f) #f) + (check-equal? (run '(if #t 1 2)) 1) + (check-equal? (run '(if #f 1 2)) 2) + (check-equal? (run '(if 0 1 2)) 1) + (check-equal? (run '(if #t 3 4)) 3) + (check-equal? (run '(if #f 3 4)) 4) + (check-equal? (run '(if 0 3 4)) 3) + (check-equal? (run '(zero? 4)) #f) + (check-equal? (run '(zero? 0)) #t))) + + diff --git a/langs/dupe/types.rkt b/langs/dupe/types.rkt new file mode 100644 index 00000000..0ba82665 --- /dev/null +++ b/langs/dupe/types.rkt @@ -0,0 +1,21 @@ +#lang racket +(provide (all-defined-out)) +(define int-shift 1) +(define mask-int #b1) +(define type-int #b0) + +(define (bits->value b) + (cond [(= b (value->bits #t)) #t] + [(= b (value->bits #f)) #f] + [(int-bits? b) + (arithmetic-shift b (- int-shift))] + [else (error "invalid bits")])) + +(define (value->bits v) + (cond [(eq? v #t) #b01] + [(eq? v #f) #b11] + [(integer? v) (arithmetic-shift v int-shift)])) + +(define (int-bits? v) + (= type-int (bitwise-and v mask-int))) + diff --git a/langs/installer.rkt b/langs/installer.rkt index 0b20b6e4..1669b352 100644 --- a/langs/installer.rkt +++ b/langs/installer.rkt @@ -10,9 +10,9 @@ (main (path->string (collection-file-path "src/" "ziggy")) own (cdr (assoc lang-name '(#;("abscond" . "A") - ("blackmail" . "B") - ("con" . "C") - ("dupe" . "D0") + #;("blackmail" . "B") + #;("con" . "C") + #;("dupe" . "D0") ("dodger" . "D1") ("evildoer" . "E0") ("extort" . "E1") From dafd513e53019f2f1dc8ba8d142f13d7a4ef18be Mon Sep 17 00:00:00 2001 From: David Van Horn Date: Wed, 18 Oct 2023 15:08:38 -0400 Subject: [PATCH 9/9] Updates to www. --- www/assignments.scrbl | 6 +++--- www/assignments/1.scrbl | 9 +++++---- www/assignments/2.scrbl | 2 +- www/assignments/3.scrbl | 3 ++- www/assignments/4.scrbl | 2 +- www/defns.rkt | 22 ++++++++++++---------- www/notes/dupe.scrbl | 6 +++--- www/schedule.scrbl | 14 +++++++------- www/syllabus.scrbl | 4 ++-- 9 files changed, 36 insertions(+), 32 deletions(-) diff --git a/www/assignments.scrbl b/www/assignments.scrbl index 4ad05e98..ab5f20ec 100644 --- a/www/assignments.scrbl +++ b/www/assignments.scrbl @@ -4,9 +4,9 @@ @local-table-of-contents[#:style 'immediate-only] @include-section{assignments/1.scrbl} -@;include-section{assignments/2.scrbl} -@;include-section{assignments/3.scrbl} -@;include-section{assignments/4.scrbl} +@include-section{assignments/2.scrbl} +@include-section{assignments/3.scrbl} +@include-section{assignments/4.scrbl} @;include-section{assignments/5.scrbl} @;include-section{assignments/6.scrbl} @;;include-section{assignments/7.scrbl} diff --git a/www/assignments/1.scrbl b/www/assignments/1.scrbl index 949dde49..6280f879 100644 --- a/www/assignments/1.scrbl +++ b/www/assignments/1.scrbl @@ -4,7 +4,7 @@ @title[#:tag "Assignment 1" #:style 'unnumbered]{Assignment 1: Learning about Programming Languages} -@bold{Due: Friday, June 2, 11:59PM} +@bold{Due: Wednesday, September 6, 11:59PM} Find two programming languages that are new to you, and answer the following questions: @@ -34,10 +34,11 @@ Racket, Ruby, Scheme, SML, Visual Basic. @section[#:style 'unnumbered]{What to turn in} -@;{Submit this assignment via @link[@gradescope]{Gradescope}.} +Submit a PDF or plain text file containing your write-up via +@link[@gradescope]{Gradescope}. -Until this assignment is officially assigned (see the due date), submissions -will not be accepted. +@;{Until this assignment is officially assigned (see the due date), submissions +will not be accepted.} @;{We will be using GitHub Classroom. This means you will work with git repositories and turning in your work consists of pushing the diff --git a/www/assignments/2.scrbl b/www/assignments/2.scrbl index d224133f..87ffc0b1 100644 --- a/www/assignments/2.scrbl +++ b/www/assignments/2.scrbl @@ -1,7 +1,7 @@ #lang scribble/manual @title[#:tag "Assignment 2" #:style 'unnumbered]{Assignment 2: Racket Primer} -@bold{Due: Monday, June 5, 11:59PM} +@bold{Due: Wednesday, September 13, 11:59PM} The goal of this assignment is to gain practice programming in Racket. diff --git a/www/assignments/3.scrbl b/www/assignments/3.scrbl index 7f5175aa..1368efdf 100644 --- a/www/assignments/3.scrbl +++ b/www/assignments/3.scrbl @@ -5,7 +5,8 @@ @(require "../../langs/con-plus/semantics.rkt") @(require redex/pict) -@bold{Due: Monday, June 12, 11:59PM} +@bold{Due: @elem[#:style "strike"]{Friday, September 29, 11:59PM} + Monday, October 2, 11:59PM} The goal of this assignment is to extend the parser, interpreter, and compiler with some simple unary numeric and boolean operations and two diff --git a/www/assignments/4.scrbl b/www/assignments/4.scrbl index a51ce293..a5d5fbfd 100644 --- a/www/assignments/4.scrbl +++ b/www/assignments/4.scrbl @@ -7,7 +7,7 @@ @(require "../notes/ev.rkt") -@bold{Due: Tuesday, June 20, 11:59PM EST} +@bold{Due: Wednesday, November 1, 11:59PM EST} The goal of this assignment is to extend a compiler with binding forms and primitives that can take any number of arguments. diff --git a/www/defns.rkt b/www/defns.rkt index dc6525b0..287b47b3 100644 --- a/www/defns.rkt +++ b/www/defns.rkt @@ -34,16 +34,16 @@ (define staff (list #;(list "William Wegand" "wwegand@terpmail.umd.edu" "3:00-4:00PM MTWThF") - (list "Pierce Darragh" "pdarragh@umd.edu" "TBD") - (list "Fuxiao Liu" "fl3es@umd.edu" "TBD") - (list "Vivian Chen" "vchen8@terpmail.umd.edu" "TBD") - (list "Ian Morrill" "imorrill@terpmail.umd.edu" "TBD") - (list "Matthew Schneider" "mgl@umd.edu" "TBD") - (list "Rhea Jajodia" "rjajodia@terpmail.umd.edu" "TBD") - (list "Syed Zaidi" "szaidi@umd.edu" "TBD") - (list "William Wegand" "wfweg@verizon.net" "TBD") - (list "Wilson Smith" "smith@umd.edu" "TBD") - (list "Yuhwan Lee" "ylee9251@terpmail.umd.edu" "TBD") + (list "Pierce Darragh" "pdarragh@umd.edu") + (list "Fuxiao Liu" "fl3es@umd.edu") + (list "Vivian Chen" "vchen8@terpmail.umd.edu") + (list "Ian Morrill" "imorrill@terpmail.umd.edu") + (list "Matthew Schneider" "mgl@umd.edu") + (list "Rhea Jajodia" "rjajodia@terpmail.umd.edu") + (list "Syed Zaidi" "szaidi@umd.edu") + (list "William Wegand" "wfweg@verizon.net") + (list "Wilson Smith" "smith@umd.edu") + (list "Yuhwan Lee" "ylee9251@terpmail.umd.edu") )) @@ -56,3 +56,5 @@ ;(define discord "TBD") (define piazza "https://piazza.com/class/llwlfinnxr63c0/") (define gradescope "https://www.gradescope.com/courses/593113") + +(define feedback "https://docs.google.com/forms/d/e/1FAIpQLSc80xQELhHb_Ef-tn0DkpH2b6pYadQiT3aYSEJFNqEqBjzdGg/viewform?usp=sf_link") \ No newline at end of file diff --git a/www/notes/dupe.scrbl b/www/notes/dupe.scrbl index 19fcb7d7..47a3cf09 100644 --- a/www/notes/dupe.scrbl +++ b/www/notes/dupe.scrbl @@ -312,13 +312,13 @@ encoding: @#reader scribble/comment-reader (ex (bits->value #b000) -(eval:error (bits->value #b001)) +(bits->value #b001) (bits->value #b010) (bits->value #b011) (bits->value #b100) (eval:error (bits->value #b101)) (bits->value #b110) -(bits->value #b111) +(eval:error (bits->value #b111)) ) Notice that not all bits represent a value; name any odd number that's @@ -809,7 +809,7 @@ interpreter in a final conversion: (interp.v2 (parse '(if 7 1 2))) (interp.v2 (parse '(if (zero? 7) 1 2))) (eval:error (interp.v2 (parse '(add1 #f)))) -(eval:error (interp.v2 (parse '(add1 #t)))) +(interp.v2 (parse '(add1 #t))) ) Notice the last two examples. What's going on? diff --git a/www/schedule.scrbl b/www/schedule.scrbl index cff82eb8..9aa93946 100644 --- a/www/schedule.scrbl +++ b/www/schedule.scrbl @@ -40,27 +40,27 @@ @itemlist[@item{@secref["Dupe"]} @item{@secref{Dodger}}]) (list @wk{9/25} - "" + @seclink["Assignment 3"]{A3} @secref["Evildoer"] @secref["Extort"]) (list @wk{10/2} "" @secref["Fraud"] - @secref["Hustle"]) + @elem{@secref["Fraud"], cont.}) (list @wk{10/9} "" - @secref["Hoax"] + @elem{@secref["Fraud"], cont.} @secref["Midterm_1"]) (list @wk{10/16} - "" - "" - "") + "" + @elem{@secref["Fraud"], cont.} + @elem{@secref["Hustle"]}) (list @wk{10/23} "" "" "") - (list @wk{10/30} "" "" "") + (list @wk{10/30} @secref["Assignment 4"] "" "") (list @wk{11/6} "" "" "") (list @wk{11/13} "" "" "") (list @wk{11/20} "" @secref["Midterm_2"] "Thanksgiving break (no lecture)") diff --git a/www/syllabus.scrbl b/www/syllabus.scrbl index 03a95589..e6ba366c 100644 --- a/www/syllabus.scrbl +++ b/www/syllabus.scrbl @@ -40,8 +40,8 @@ of department; or CMSC graduate student. @bold{Lectures:} @itemlist[ -@item{0101: @lecture-schedule2, @classroom2} -@item{0201: @lecture-schedule1, @classroom1}] +@item{0101: @lecture-schedule2, @classroom2 (@prof2-initials)} +@item{0201: @lecture-schedule1, @classroom1 (@prof1-initials)}] @bold{Course Description:} @courseno is an introduction to compilers.