diff --git a/langs/dupe/ast.rkt b/langs/dupe/ast.rkt index 50183b13..11f58818 100644 --- a/langs/dupe/ast.rkt +++ b/langs/dupe/ast.rkt @@ -1,16 +1,13 @@ #lang racket (provide Lit Prim1 If) - ;; type Expr = (Lit Datum) ;; | (Prim1 Op1 Expr) ;; | (If Expr Expr Expr) - ;; type Datum = Integer ;; | Boolean - ;; type Op1 = 'add1 | 'sub1 ;; | 'zero? - (struct Lit (d) #:prefab) (struct Prim1 (p e) #:prefab) (struct If (e1 e2 e3) #:prefab) + diff --git a/langs/dupe/compile.rkt b/langs/dupe/compile.rkt index fa817ac1..3a39225c 100644 --- a/langs/dupe/compile.rkt +++ b/langs/dupe/compile.rkt @@ -8,7 +8,7 @@ (define rax 'rax) ;; Expr -> Asm -(define (compile e) +(define (compile e) (prog (Global 'entry) (Label 'entry) (compile-e e) @@ -17,8 +17,8 @@ ;; Expr -> Asm (define (compile-e e) (match e - [(Lit d) (compile-value d)] - [(Prim1 p e) (compile-prim1 p e)] + [(Lit d) (compile-value d)] + [(Prim1 p e) (compile-prim1 p e)] [(If e1 e2 e3) (compile-if e1 e2 e3)])) diff --git a/langs/dupe/interp-prim.rkt b/langs/dupe/interp-prim.rkt index e0ea0720..09116bb7 100644 --- a/langs/dupe/interp-prim.rkt +++ b/langs/dupe/interp-prim.rkt @@ -7,3 +7,4 @@ ['add1 (add1 v)] ['sub1 (sub1 v)] ['zero? (zero? v)])) + diff --git a/langs/dupe/interp.rkt b/langs/dupe/interp.rkt index 920f0920..ade09931 100644 --- a/langs/dupe/interp.rkt +++ b/langs/dupe/interp.rkt @@ -6,7 +6,6 @@ ;; type Value = ;; | Integer ;; | Boolean - ;; Expr -> Value (define (interp e) (match e @@ -17,3 +16,4 @@ (if (interp e1) (interp e2) (interp e3))])) + diff --git a/langs/dupe/parse.rkt b/langs/dupe/parse.rkt index 673a0266..e67d3135 100644 --- a/langs/dupe/parse.rkt +++ b/langs/dupe/parse.rkt @@ -11,6 +11,7 @@ (If (parse e1) (parse e2) (parse e3))] [_ (error "Parse error")])) + ;; Any -> Boolean (define (datum? x) (or (exact-integer? x) diff --git a/langs/dupe/run.rkt b/langs/dupe/run.rkt index 227703c1..37cba759 100644 --- a/langs/dupe/run.rkt +++ b/langs/dupe/run.rkt @@ -1,7 +1,8 @@ #lang racket (require a86/interp) (require "types.rkt") -(provide run);; Asm -> Value +(provide run) +;; Asm -> Value (define (run is) (bits->value (asm-interp is))) diff --git a/langs/dupe/test/interp.rkt b/langs/dupe/test/interp.rkt index 41aa8c04..dc33c12a 100644 --- a/langs/dupe/test/interp.rkt +++ b/langs/dupe/test/interp.rkt @@ -2,6 +2,6 @@ (require "../interp.rkt") (require "../parse.rkt") (require "test-runner.rkt") - + (test (λ (e) (interp (parse e)))) diff --git a/langs/dupe/test/test-runner.rkt b/langs/dupe/test/test-runner.rkt index 7dcac9f1..650b1313 100644 --- a/langs/dupe/test/test-runner.rkt +++ b/langs/dupe/test/test-runner.rkt @@ -36,4 +36,3 @@ (check-equal? (run '(zero? 4)) #f) (check-equal? (run '(zero? 0)) #t))) -