Skip to content

Commit 27e23af

Browse files
committed
Note update.
1 parent 600e710 commit 27e23af

1 file changed

Lines changed: 23 additions & 6 deletions

File tree

www/assignments/5.scrbl

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,21 @@ two booleans are equal.}
105105
106106
@section[#:tag-prefix "a5-" #:style 'unnumbered]{Extending your Parser, yet again!}
107107
108+
@margin-note{@bold{CHANGE:} This grammar was changed slightly on
109+
Friday 9/27 and 4:40PM. The original grammar did not have binary
110+
subtraction primitive @tt{-}, only the unary negation @tt{-}
111+
primitive. The grammar has been fixed and the code in @tt{lex.rkt}
112+
and @tt{parse.rkt} has been updated. If you clone the repository
113+
after this time, you have the changes. If you cloned before, you can
114+
download the udpated
115+
@link["https://raw.githubusercontent.com/cmsc430/assign05/master/lex.rkt"]{@tt{lex.rkt}}
116+
and
117+
@link["https://raw.githubusercontent.com/cmsc430/assign05/master/parse.rkt"]{@tt{parse.rkt}} files.
118+
You can see a diff to the files
119+
@link["https://github.com/cmsc430/assign05/commit/22f7a64f1419bc69b19d5ff1c8845e583fbf9b1c"]{here}.}
120+
121+
122+
108123
109124
Extend your Fraud+ parser for the Hustle+ language based on the following
110125
grammar:
@@ -120,17 +135,21 @@ grammar:
120135
121136
<compound> ::= <prim1> <expr>
122137
| <prim2> <expr> <expr>
138+
| - <expr> <maybe-expr>
123139
| if <expr> <expr> <expr>
124140
| cond <clause>* <else>
125141
| let <bindings> <expr>
126142
127-
<prim1> ::= add1 | sub1 | abs | - | zero? | integer->char | char->integer
143+
<prim1> ::= add1 | sub1 | abs | zero? | integer->char | char->integer
128144
| char? | integer? | boolean? | string? | box? | empty? | cons?
129145
| box | unbox | car | cdr | string-length
130146
131147
<prim2> ::= make-string | string-ref | = | < | <=
132148
| char=? | boolean=? | +
133149
150+
<maybe-expr> ::=
151+
| <expr>
152+
134153
<clause> ::= ( <expr> <expr> )
135154
| [ <expr> <expr> ]
136155
@@ -153,16 +172,15 @@ which are defined as follows (only the new parts are shown):
153172
(racketblock
154173
; type Token =
155174
; ...
156-
; | `(prim1 ,Prim1)
157-
; | `(prim2 ,Prim2)
158175
; | String
159176
177+
; type Prim = Prim1 | Prim2 | '-
178+
160179
; type Prim1 =
161180
; | 'add1
162181
; | 'sub1
163182
; | 'zero?
164183
; | 'abs
165-
; | '-
166184
; | 'integer->char
167185
; | 'char->integer
168186
; | 'char?
@@ -187,7 +205,6 @@ which are defined as follows (only the new parts are shown):
187205
; | 'char=?
188206
; | 'boolean=?
189207
; | '+
190-
; | '-
191208
)
192209
193210
The lexer will take care of reading the @tt{#lang racket} header and
@@ -207,7 +224,7 @@ the module:
207224
As an example, @racket[parse] should produce @racket['(add1 (sub1 7))]
208225
if given
209226
210-
@racketblock['(lparen (prim1 add1) lparen (prim1 sub1) 7 rparen rparen eof)]
227+
@racketblock['(lparen (prim add1) lparen (prim sub1) 7 rparen rparen eof)]
211228
212229
You should not need to make any changes to @tt{lex.rkt}.
213230

0 commit comments

Comments
 (0)