Skip to content

Commit 12429c1

Browse files
committed
Parser bug with symbol patterns.
1 parent 5761241 commit 12429c1

4 files changed

Lines changed: 13 additions & 3 deletions

File tree

langs/mountebank/parse.rkt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@
6868
['_ (PWild)]
6969
[(? symbol?) (PVar p)]
7070
[(? string?) (PStr p)]
71-
[(list 'quote s) (PSymb s)]
71+
[(list 'quote (? symbol? s))
72+
(PSymb s)]
7273
[(list 'quote (list))
7374
(PLit '())]
7475
[(list 'box p)

langs/mountebank/test/test-runner.rkt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@
314314
(check-equal? (run '(match 'foo ['foo #t] [_ #f])) #t)
315315
(check-equal? (run '(match "foo" ["foo" #t] [_ #f])) #t)
316316
(check-equal? (run '(match "foo" ["bar" #t] [_ #f])) #f)
317+
(check-equal? (run '(match (cons '+ (cons 1 (cons 2 '())))
318+
[(cons '+ (cons x (cons y '())))
319+
(+ x y)]))
320+
3))
317321

318322
;; Mountebank examples
319323
(check-equal? (run '#())

langs/mug/parse.rkt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@
7272
['_ (PWild)]
7373
[(? symbol?) (PVar p)]
7474
[(? string?) (PStr p)]
75-
[(list 'quote s) (PSymb s)]
75+
[(list 'quote (? symbol? s))
76+
(PSymb s)]
7677
[(list 'quote (list))
7778
(PLit '())]
7879
[(list 'box p)

langs/mug/test/test-runner.rkt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,11 @@
313313
(check-equal? (run '(match 'foo ['bar #t] [_ #f])) #f)
314314
(check-equal? (run '(match 'foo ['foo #t] [_ #f])) #t)
315315
(check-equal? (run '(match "foo" ["foo" #t] [_ #f])) #t)
316-
(check-equal? (run '(match "foo" ["bar" #t] [_ #f])) #f))
316+
(check-equal? (run '(match "foo" ["bar" #t] [_ #f])) #f)
317+
(check-equal? (run '(match (cons '+ (cons 1 (cons 2 '())))
318+
[(cons '+ (cons x (cons y '())))
319+
(+ x y)]))
320+
3))
317321

318322
(define (test-runner-io run)
319323
;; Evildoer examples

0 commit comments

Comments
 (0)