File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 232232 (list (seq (Push rax))
233233 (seq)
234234 (cons x cm))]
235+ [(PSymb s)
236+ (let ((fail (gensym)))
237+ (list (seq (Lea r9 (Plus (symbol->data-label s) type-symb))
238+ (Cmp rax r9)
239+ (Jne fail))
240+ (seq (Label fail)
241+ (Add rsp (* 8 (length cm)))
242+ (Jmp next))
243+ cm))]
235244 [(PLit l)
236245 (let ((fail (gensym)))
237246 (list (seq (Cmp rax (imm->bits l))
Original file line number Diff line number Diff line change 104104 (match p
105105 [(PWild) r]
106106 [(PVar x) (ext r x v)]
107+ [(PSymb s) (and (eq? s v) r)]
107108 [(PLit l) (and (eqv? l v) r)]
108109 [(PBox p)
109110 (match v
Original file line number Diff line number Diff line change 103103 (match p
104104 [(PWild) r]
105105 [(PVar x) (ext r x v)]
106+ [(PSymb s) (and (eq? s v) r)]
106107 [(PLit l) (and (eqv? l v) r)]
107108 [(PBox p)
108109 (match v
Original file line number Diff line number Diff line change 6767 [(? char?) (PLit p)]
6868 ['_ (PWild)]
6969 [(? symbol?) (PVar p)]
70+ [(list 'quote s) (PSymb s)]
7071 [(list 'quote (list))
7172 (PLit '() )]
7273 [(list 'box p)
7374 (PBox (parse-pat p))]
7475 [(list 'cons p1 p2)
7576 (PCons (parse-pat p1) (parse-pat p2))]
7677 [(list 'and p1 p2)
77- (PAnd (parse-pat p1) (parse-pat p2))]))
78+ (PAnd (parse-pat p1) (parse-pat p2))]
79+ [(cons 'list '() )
80+ (PLit '() )]
81+ [(cons 'list (cons p1 ps))
82+ (PCons (parse-pat p1)
83+ (parse-pat (cons 'list ps)))]))
7884
7985;; Datum -> Datum
8086(define (parse-datum d)
Original file line number Diff line number Diff line change 310310 (check-equal? (run ''foo ) 'foo )
311311 (check-equal? (run '(eq? (match #t [_ "foo " ]) "bar " )) #f )
312312 (check-equal? (run '(eq? (match #t [_ 'foo ]) 'bar )) #f )
313+ (check-equal? (run '(match 'foo ['bar #t ] [_ #f ])) #f )
314+ (check-equal? (run '(match 'foo ['foo #t ] [_ #f ])) #t )
313315
314316 ;; Mountebank examples
315317 (check-equal? (run '#())
Original file line number Diff line number Diff line change 248248 (list (seq (Push rax))
249249 (seq)
250250 (cons x cm))]
251+ [(PSymb s)
252+ (let ((fail (gensym)))
253+ (list (seq (Lea r9 (Plus (symbol->data-label s) type-symb))
254+ (Cmp rax r9)
255+ (Jne fail))
256+ (seq (Label fail)
257+ (Add rsp (* 8 (length cm)))
258+ (Jmp next))
259+ cm))]
251260 [(PLit l)
252261 (let ((fail (gensym)))
253262 (list (seq (Cmp rax (imm->bits l))
Original file line number Diff line number Diff line change 112112 (match p
113113 [(PWild) r]
114114 [(PVar x) (ext r x v)]
115+ [(PSymb s) (and (eq? s v) r)]
115116 [(PLit l) (and (eqv? l v) r)]
116117 [(PBox p)
117118 (match v
Original file line number Diff line number Diff line change 111111 (match p
112112 [(PWild) r]
113113 [(PVar x) (ext r x v)]
114+ [(PSymb s) (and (eq? s v) r)]
114115 [(PLit l) (and (eqv? l v) r)]
115116 [(PBox p)
116117 (match v
Original file line number Diff line number Diff line change 7171 [(? char?) (PLit p)]
7272 ['_ (PWild)]
7373 [(? symbol?) (PVar p)]
74+ [(list 'quote s) (PSymb s)]
7475 [(list 'quote (list))
7576 (PLit '() )]
7677 [(list 'box p)
Original file line number Diff line number Diff line change 309309 (check-equal? (run '(eq? (symbol->string 'foo ) "foo " )) #f )
310310 (check-equal? (run ''foo ) 'foo )
311311 (check-equal? (run '(eq? (match #t [_ "foo " ]) "bar " )) #f )
312- (check-equal? (run '(eq? (match #t [_ 'foo ]) 'bar )) #f ))
312+ (check-equal? (run '(eq? (match #t [_ 'foo ]) 'bar )) #f )
313+ (check-equal? (run '(match 'foo ['bar #t ] [_ #f ])) #f )
314+ (check-equal? (run '(match 'foo ['foo #t ] [_ #f ])) #t ))
313315
314316(define (test-runner-io run)
315317 ;; Evildoer examples
You can’t perform that action at this time.
0 commit comments