Question 1 @ 2024-09-24 18:38
What’s your preference for when to do a remote class?
-
The evening before the fall break (2024-11-27).
-
The last class of the semester, which is also the evening after the fall break (2024-12-03).
-
Both of the above.
-
Neither, I have some other date that is a better choice.
-
None, I’d like all classes in-person.
Question 2 @ 2024-09-24 18:40
What is the reason we’re using BNFs to specify our language(s)?
-
They’re a popular simple way of specifying grammars.
-
They’re easier to implement in a statically-typed language.
-
They’re inherently compositional so they simplify implementing evaluators.
-
They turned out to be useful representations, as seen by the history of S-expressions vs M-expressions in Lisp.
-
No real reason.
Question 3 @ 2024-09-24 18:41
For the following BNF, what is the simplest way to avoid ambiguity from the language implementor’s point of view?
| <AE> + <AE>
| <AE> - <AE>
| <AE> * <AE>
| <AE> / <AE>
-
There is no ambiguity
-
Don’t do infix syntax, it’s always ambiguous
-
Change one of the
<AE>
s on each line to a<num>
to enforce a direction -
Add level(s) to enforce operator precedence
-
Add some required brackets around all options
-
Add some required brackets around all of the operator rules
Question 4 @ 2024-09-24 18:43
What is the problem with the following Typed Racket code?
[Num Number]
[Add AE AE]
[Sub AE AE])
(define (eval expr)
(cases expr
[(Num n) n]
[(Add l r) (+ (eval l) (eval r))]
[(Sub l r) (- (eval l) (eval r))]
[else expr]))
-
Broken
define-type
, since it refers to its own type - Missing contract comment
- Missing type declaration
-
Redundant
else
clause -
Bad type of the
else
clause