PLQ #2Done on:   Tuesday, September 24th

Question 1 @ 2024-09-24 18:38

What’s your preference for when to do a remote class?


Question 2 @ 2024-09-24 18:40

What is the reason we’re using BNFs to specify our language(s)?


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> ::= <num>
      | <AE> + <AE>
      | <AE> - <AE>
      | <AE> * <AE>
      | <AE> / <AE>

Question 4 @ 2024-09-24 18:43

What is the problem with the following Typed Racket code?

(define-type AE
  [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]))