Open siadat opened 1 month ago
It looks like I forgot the single-quote in a bunch of places.
That is, in Racket,
'(1 2 3)
is another way to write
(list 1 2 3)
I'll look into fixing this when I get back from vacation.
Thanks! In the grammar, (exp)
represents a list with one expression, which matches the ASTs. So, if we update the ASTs we might want to consider updating the grammar as well, perhaps to something like this:
exp ::= (Prim '- (list exp))
Just an observation regarding single-quote vs list: with single-quote the expressions inside the list get quoted as well and the result may be different, e.g. (list (+ 1 2) 3)
!= '((+ 1 2) 3)
.
I am excited to continue to follow the book this week. Enjoy your vacation! :)
Thanks for this great book. Just started reading the Racket book and I had a question regarding Section 1.2 (page 4). The AST examples are written in a format that is similar to the BNF grammar, and are not Racket code. Is that intentional?
For example, the AST for negative 8 is represented as this:
The equivalent Racket code would be
I'm learning Racket at the same time, and I was wondering why we don't use Racket to represent the AST. Thanks!