Skip to content

Commit 15719c1

Browse files
committed
Mountebank notes.
1 parent cea5729 commit 15719c1

5 files changed

Lines changed: 369 additions & 28 deletions

File tree

langs/mountebank/compile-datum.rkt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
;; Registers used
88
(define rax 'rax) ; return
99

10+
;; Datum -> Asm
11+
(define (compile-datum d)
12+
(cond
13+
[(string? d) (seq (Lea rax (load-string d)))]
14+
[(symbol? d) (seq (Lea rax (load-symbol d)))]
15+
[(compound? d) (compile-compound-datum d)]
16+
[else (compile-atom d)]))
17+
1018
(define (load-symbol s)
1119
(Plus (symbol->data-label s) type-symb))
1220

@@ -23,14 +31,6 @@
2331
(cons? d)
2432
(vector? d)))
2533

26-
;; Datum -> Asm
27-
(define (compile-datum d)
28-
(cond
29-
[(string? d) (seq (Lea rax (load-string d)))]
30-
[(symbol? d) (seq (Lea rax (load-symbol d)))]
31-
[(compound? d) (compile-compound-datum d)]
32-
[else (compile-atom d)]))
33-
3434
;; Datum -> Asm
3535
(define (compile-compound-datum d)
3636
(match (compile-quoted d)

langs/mountebank/parse.rkt

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
;; S-Expr -> Expr
2525
(define (parse-e s)
2626
(match s
27-
[(? self-quoting?) (Quote (parse-datum s))]
28-
[(list 'quote d) (Quote (parse-datum d))]
27+
[(? self-quoting?) (Quote s)]
28+
[(list 'quote d) (Quote d)]
2929
['eof (Eof)]
3030
[(? symbol?) (Var s)]
3131
[(list (? (op? op0) p0)) (Prim0 p0)]
@@ -84,23 +84,6 @@
8484
(PCons (parse-pat p1)
8585
(parse-pat (cons 'list ps)))]))
8686

87-
;; Datum -> Datum
88-
(define (parse-datum d)
89-
(match d
90-
[(box d)
91-
(box (parse-datum d))]
92-
[(cons d1 d2)
93-
(cons (parse-datum d1) (parse-datum d2))]
94-
['() '()]
95-
[(? symbol? s) s]
96-
[(? integer? i) i]
97-
[(? boolean? b) b]
98-
[(? string? s) s]
99-
[(? char? c) c]
100-
[(? vector? v)
101-
(apply vector (map parse-datum (vector->list v)))]
102-
[_ (error "parse datum error")]))
103-
10487
(define (self-quoting? x)
10588
(or (integer? x)
10689
(boolean? x)

www/notes.scrbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ suggestions for improving the material, @bold{please},
3131
@include-section{notes/knock.scrbl}
3232
@include-section{notes/loot.scrbl}
3333
@include-section{notes/mug.scrbl}
34+
@include-section{notes/mountebank.scrbl}
3435
@;include-section{notes/shakedown.scrbl}

0 commit comments

Comments
 (0)