IUCompilerCourse / Essentials-of-Compilation

A book about compiling Racket and Python to x86-64 assembly
1.27k stars 137 forks source link

Add missing close paren in Racket listing #176

Open siadat opened 3 months ago

siadat commented 3 months ago

Issue

One of the Racket listings is missing a closing paren.

Solution

This PR adds the missing paren.

Verification

(struct Int (value)) (struct Prim (op args)) (struct Program (info body)) (define rd (Prim 'read '())) (define neg-eight (Prim '- (list (Int 8)))) (define ast1_1 (Prim '+ (list rd neg-eight)))

(define (is_exp ast) (match ast [(Int n) #t] [(Prim 'read '()) #t] [(Prim '- (list e)) (is_exp e)] [(Prim '+ (list e1 e2)) (and (is_exp e1) (is_exp e2))] [(Prim '- (list e1 e2)) (and (is_exp e1) (is_exp e2))] [else #f]))

(define (is_Lint ast) (match ast [(Program '() e) (is_exp e)] [else #f]))

(is_Lint (Program '() ast1_1)) (is_Lint (Program '() (Prim '* (list (Prim 'read '()) (Prim '+ (list (Int 8)))))))


It returns

$ racket Lint.rkt

t

f