Skip to content

Commit 0eb11a9

Browse files
committed
crook
1 parent 386a91b commit 0eb11a9

8 files changed

Lines changed: 32 additions & 21 deletions

File tree

iniquity/parse.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
(define (rec ss fs)
3636
(match ss
3737
[(list s) fs]
38-
[(cons (cons 'define sd) sr)
38+
[(cons (cons (? (not-in fs) 'define) sd) sr)
3939
(match (parse-defn-name sd)
4040
[f (if (memq f fs)
4141
(error "duplicate definition" f)

iniquity/test/parse.rkt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,18 @@
5555
(Prog (list (Defn 'define '() (Lit 0)))
5656
(App 'define '())))
5757
(check-exn exn:fail? (λ () (parse '(define (f y y) y) 1)))
58+
(check-exn exn:fail? (λ () (parse '(define (f y) y) '(define (f x) x) 1)))
5859
(check-equal? (parse-closed '(define (f x) (g x))
5960
'(define (g x) (f x))
6061
'(f 0))
6162
(Prog (list (Defn 'f '(x) (App 'g (list (Var 'x))))
6263
(Defn 'g '(x) (App 'f (list (Var 'x)))))
63-
(App 'f (list (Lit 0))))))
64+
(App 'f (list (Lit 0)))))
65+
(check-equal? (parse '(define (define x) x)
66+
'(define 1))
67+
(Prog (list (Defn 'define '(x) (Var 'x)))
68+
(App 'define (list (Lit 1)))))
69+
(check-exn exn:fail? (λ () (parse '(define (define x) x)
70+
'(define (g x) x)
71+
'(define (g 1))))))
6472

jig/parse.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
(define (rec ss fs)
3636
(match ss
3737
[(list s) fs]
38-
[(cons (cons 'define sd) sr)
38+
[(cons (cons (? (not-in fs) 'define) sd) sr)
3939
(match (parse-defn-name sd)
4040
[f (if (memq f fs)
4141
(error "duplicate definition" f)

jig/test/parse.rkt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
(check-equal? (parse "asdf") (p (Lit "asdf")))
4848
(check-equal? (parse '(make-string 10 #\a))
4949
(p (Prim2 'make-string (Lit 10) (Lit #\a)))))
50+
5051
(begin ; Iniquity
5152
(check-equal? (parse '(define (f x) x) 1)
5253
(Prog (list (Defn 'f '(x) (Var 'x))) (Lit 1)))

knock/parse.rkt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
(define (rec ss fs)
4242
(match ss
4343
[(list s) fs]
44-
[(cons (cons 'define sd) sr)
44+
[(cons (cons (? (not-in fs) 'define) sd) sr)
4545
(match (parse-defn-name sd)
4646
[f (if (memq f fs)
4747
(error "duplicate definition" f)
@@ -126,14 +126,14 @@
126126
(list ys gs (Let x e1 e2))])])]
127127
[_ (error "let: bad syntax" s)])]
128128
['match
129-
(match sr
130-
[(cons s sr)
131-
(match (rec s xs ys gs)
132-
[(list ys gs e)
133-
(match (parse-match-clauses/acc sr fs xs ys gs)
134-
[(list ys gs ps es)
135-
(list ys gs (Match e ps es))])])]
136-
[_ (error "match: bad syntax" s)])]
129+
(match sr
130+
[(cons s sr)
131+
(match (rec s xs ys gs)
132+
[(list ys gs e)
133+
(match (parse-match-clauses/acc sr fs xs ys gs)
134+
[(list ys gs ps es)
135+
(list ys gs (Match e ps es))])])]
136+
[_ (error "match: bad syntax" s)])]
137137
[_
138138
(match (parse-es/acc sr fs xs ys gs)
139139
[(list ys gs es)

knock/test/parse.rkt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
(check-equal? (parse "asdf") (p (Lit "asdf")))
4848
(check-equal? (parse '(make-string 10 #\a))
4949
(p (Prim2 'make-string (Lit 10) (Lit #\a)))))
50+
5051
(begin ; Iniquity
5152
(check-equal? (parse '(define (f x) x) 1)
5253
(Prog (list (Defn 'f '(x) (Var 'x))) (Lit 1)))

loot/parse.rkt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
(define (rec ss fs)
4242
(match ss
4343
[(list s) fs]
44-
[(cons (cons 'define sd) sr)
44+
[(cons (cons (? (not-in fs) 'define) sd) sr)
4545
(match (parse-defn-name sd)
4646
[f (if (memq f fs)
4747
(error "duplicate definition" f)
@@ -116,14 +116,14 @@
116116
(list ys (Let x e1 e2))])])]
117117
[_ (error "let: bad syntax" s)])]
118118
['match
119-
(match sr
120-
[(cons s sr)
121-
(match (rec s xs ys)
122-
[(list ys e)
123-
(match (parse-match-clauses/acc sr xs ys)
124-
[(list ys ps es)
125-
(list ys (Match e ps es))])])]
126-
[_ (error "match: bad syntax" s)])]
119+
(match sr
120+
[(cons s sr)
121+
(match (rec s xs ys)
122+
[(list ys e)
123+
(match (parse-match-clauses/acc sr xs ys)
124+
[(list ys ps es)
125+
(list ys (Match e ps es))])])]
126+
[_ (error "match: bad syntax" s)])]
127127

128128
[(or 'lambda)
129129
(match sr

loot/test/parse.rkt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
(check-equal? (parse "asdf") (p (Lit "asdf")))
4848
(check-equal? (parse '(make-string 10 #\a))
4949
(p (Prim2 'make-string (Lit 10) (Lit #\a)))))
50+
5051
(begin ; Iniquity
5152
(check-equal? (parse '(define (f x) x) 1)
5253
(Prog (list (Defn 'f '(x) (Var 'x))) (Lit 1)))

0 commit comments

Comments
 (0)