6 Lab My First Language


practice with an s-exp language

Exercise 12. Change "arith.rkt" to allow literal booleans—#false, #true, #f, and #tin the same way that literal numbers and strings are allowed. image

Exercise 13. Change the grammar of if in "arith.rkt" to have then and else keywords:
  Expression = ...
  | (if Expression then Expression else Expression)
Of course, you will need to create your own if macro to replace the one from racket.

You can use a #:datum-literals clause in syntax-parse to support then and else. But after you get that working, make #:literals work, which will involve defining then and else as macros that always complain if they are used outisde of teir designated positions in if, like else in racket. image

Exercise 14. Make the define-function language a proper language as implemented by a "algebra.rkt" module. Allow just the forms in the grammarnothing more, nothing less. image

Exercise 15. Add 17 additional primitive arithmetic operators to "algebra.rkt". Don’t wear out your copy-and-paste keys by making 17 copies of the definition of plus. image