Skip to content

Commit

Permalink
crook
Browse files Browse the repository at this point in the history
  • Loading branch information
dvanhorn committed Dec 2, 2024
1 parent 576e4bc commit 63437fb
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 51 deletions.
1 change: 0 additions & 1 deletion dodger/parse.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
[_ (error "parse error" s)])]
[_ (error "parse error" s)]))


;; Any -> Boolean
(define (datum? x)
(or (exact-integer? x)
Expand Down
1 change: 0 additions & 1 deletion dupe/parse.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
[_ (error "parse error" s)])]
[_ (error "parse error" s)]))


;; Any -> Boolean
(define (datum? x)
(or (exact-integer? x)
Expand Down
1 change: 0 additions & 1 deletion evildoer/parse.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
[_ (error "parse error" s)])]
[_ (error "parse error" s)]))


;; Any -> Boolean
(define (datum? x)
(or (exact-integer? x)
Expand Down
1 change: 0 additions & 1 deletion extort/parse.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
[_ (error "parse error" s)])]
[_ (error "parse error" s)]))


;; Any -> Boolean
(define (datum? x)
(or (exact-integer? x)
Expand Down
26 changes: 16 additions & 10 deletions fraud/parse.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@
(provide parse parse-closed)
(require "ast.rkt")

;; S-Expr -> Expr
;; s:S-Expr -> e:ClosedExpr
;; Parse s into (a potentially open) expr e
(define (parse s)
(match (parse/acc s '() '())
[(list _ e) e]))

;; S-Expr -> ClosedExpr
;; s:S-Expr -> e:ClosedExpr
;; Parse s into closed expr e; signal an error when e is open
(define (parse-closed s)
(match (parse/acc s '() '())
[(list '() e) e]
[(list fvs e) (error "unbound identifiers" fvs)]))

;; S-Expr [Listof Id] [Listof Id] -> (list [Listof Id] Expr)
;; Parse s into expr and list of free variables
;; assuming bvs are bound, fvs are free
;; s:S-Expr bvs:[Listof Id] fvs:[Listof Id]
;; -> (list fvs-e:[Listof Id] e:Expr)
;; Parse s into expr e and list of free variables fvs-e,
;; assuming variables in bvs are bound and fvs are free.
(define (parse/acc s bvs fvs)
(define (rec s bvs fvs)
(match s
Expand Down Expand Up @@ -50,7 +53,10 @@
[_ (error "parse error" s)]))
(rec s bvs fvs))

;; S-Expr [Listof Id] [Listof Id] -> (list [Listof Id] [Listof Expr])
;; s:S-Expr bvs:[Listof Id] fvs:[Listof Id]
;; -> (list fvs-e:[Listof Id] es:[Listof Expr])
;; Parse s into a list of expr es and list of free variables fvs-e,
;; assuming variables in bvs are bound and fvs are free.
(define (parse-es/acc s bvs fvs)
(match s
['() (list fvs '())]
Expand All @@ -62,10 +68,10 @@
(list fvs (cons e es))])])]
[_ (error "parse error")]))

;; [Listof Any] -> (Any -> Boolean)
(define (not-in m)
(λ (x) (not (memq x m))))

;; xs:[Listof Any] -> p:(x:Any -> Boolean)
;; Produce a predicate p for things not in xs
(define (not-in xs)
(λ (x) (not (memq x xs))))

;; Any -> Boolean
(define (datum? x)
Expand Down
26 changes: 16 additions & 10 deletions hoax/parse.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@
(provide parse parse-closed)
(require "ast.rkt")

;; S-Expr -> Expr
;; s:S-Expr -> e:ClosedExpr
;; Parse s into (a potentially open) expr e
(define (parse s)
(match (parse/acc s '() '())
[(list _ e) e]))

;; S-Expr -> ClosedExpr
;; s:S-Expr -> e:ClosedExpr
;; Parse s into closed expr e; signal an error when e is open
(define (parse-closed s)
(match (parse/acc s '() '())
[(list '() e) e]
[(list fvs e) (error "unbound identifiers" fvs)]))

;; S-Expr [Listof Id] [Listof Id] -> (list [Listof Id] Expr)
;; Parse s into expr and list of free variables
;; assuming bvs are bound, fvs are free
;; s:S-Expr bvs:[Listof Id] fvs:[Listof Id]
;; -> (list fvs-e:[Listof Id] e:Expr)
;; Parse s into expr e and list of free variables fvs-e,
;; assuming variables in bvs are bound and fvs are free.
(define (parse/acc s bvs fvs)
(define (rec s bvs fvs)
(match s
Expand Down Expand Up @@ -53,7 +56,10 @@
[_ (error "parse error" s)]))
(rec s bvs fvs))

;; S-Expr [Listof Id] [Listof Id] -> (list [Listof Id] [Listof Expr])
;; s:S-Expr bvs:[Listof Id] fvs:[Listof Id]
;; -> (list fvs-e:[Listof Id] es:[Listof Expr])
;; Parse s into a list of expr es and list of free variables fvs-e,
;; assuming variables in bvs are bound and fvs are free.
(define (parse-es/acc s bvs fvs)
(match s
['() (list fvs '())]
Expand All @@ -65,10 +71,10 @@
(list fvs (cons e es))])])]
[_ (error "parse error")]))

;; [Listof Any] -> (Any -> Boolean)
(define (not-in m)
(λ (x) (not (memq x m))))

;; xs:[Listof Any] -> p:(x:Any -> Boolean)
;; Produce a predicate p for things not in xs
(define (not-in xs)
(λ (x) (not (memq x xs))))

;; Any -> Boolean
(define (datum? x)
Expand Down
26 changes: 16 additions & 10 deletions hustle/parse.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@
(provide parse parse-closed)
(require "ast.rkt")

;; S-Expr -> Expr
;; s:S-Expr -> e:ClosedExpr
;; Parse s into (a potentially open) expr e
(define (parse s)
(match (parse/acc s '() '())
[(list _ e) e]))

;; S-Expr -> ClosedExpr
;; s:S-Expr -> e:ClosedExpr
;; Parse s into closed expr e; signal an error when e is open
(define (parse-closed s)
(match (parse/acc s '() '())
[(list '() e) e]
[(list fvs e) (error "unbound identifiers" fvs)]))

;; S-Expr [Listof Id] [Listof Id] -> (list [Listof Id] Expr)
;; Parse s into expr and list of free variables
;; assuming bvs are bound, fvs are free
;; s:S-Expr bvs:[Listof Id] fvs:[Listof Id]
;; -> (list fvs-e:[Listof Id] e:Expr)
;; Parse s into expr e and list of free variables fvs-e,
;; assuming variables in bvs are bound and fvs are free.
(define (parse/acc s bvs fvs)
(define (rec s bvs fvs)
(match s
Expand Down Expand Up @@ -52,7 +55,10 @@
[_ (error "parse error" s)]))
(rec s bvs fvs))

;; S-Expr [Listof Id] [Listof Id] -> (list [Listof Id] [Listof Expr])
;; s:S-Expr bvs:[Listof Id] fvs:[Listof Id]
;; -> (list fvs-e:[Listof Id] es:[Listof Expr])
;; Parse s into a list of expr es and list of free variables fvs-e,
;; assuming variables in bvs are bound and fvs are free.
(define (parse-es/acc s bvs fvs)
(match s
['() (list fvs '())]
Expand All @@ -64,10 +70,10 @@
(list fvs (cons e es))])])]
[_ (error "parse error")]))

;; [Listof Any] -> (Any -> Boolean)
(define (not-in m)
(λ (x) (not (memq x m))))

;; xs:[Listof Any] -> p:(x:Any -> Boolean)
;; Produce a predicate p for things not in xs
(define (not-in xs)
(λ (x) (not (memq x xs))))

;; Any -> Boolean
(define (datum? x)
Expand Down
10 changes: 5 additions & 5 deletions iniquity/parse.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
[(list ys gs (Prog ds e))
(list ys gs (Prog (cons d ds) e))])])]))


;; S-Expr [Listof Id] [Listof Id] [Listof Id] [Listof Id] -> (list [Listof Id] [Listof Id] Defn)
;; s: definition shaped s-expr to be parsed
;; fs: defined function names
Expand Down Expand Up @@ -163,16 +162,17 @@
(list ys gs (cons e es))])])]
[_ (error "parse error")]))

;; [Listof Any] -> Boolean
(define (distinct? xs)
(not (check-duplicates xs)))

;; [Listof Any] -> (Any -> Boolean)
(define (not-in m)
(λ (x) (not (memq x m))))
;; xs:[Listof Any] -> p:(x:Any -> Boolean)
;; Produce a predicate p for things not in xs
(define (not-in xs)
(λ (x) (not (memq x xs))))
(define (in m)
(λ (x) (memq x m)))


;; Any -> Boolean
(define (datum? x)
(or (exact-integer? x)
Expand Down
9 changes: 5 additions & 4 deletions jig/parse.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,17 @@
(list ys gs (cons e es))])])]
[_ (error "parse error")]))

;; [Listof Any] -> Boolean
(define (distinct? xs)
(not (check-duplicates xs)))

;; [Listof Any] -> (Any -> Boolean)
(define (not-in m)
(λ (x) (not (memq x m))))
;; xs:[Listof Any] -> p:(x:Any -> Boolean)
;; Produce a predicate p for things not in xs
(define (not-in xs)
(λ (x) (not (memq x xs))))
(define (in m)
(λ (x) (memq x m)))


;; Any -> Boolean
(define (datum? x)
(or (exact-integer? x)
Expand Down
9 changes: 5 additions & 4 deletions knock/parse.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -231,16 +231,17 @@
[_ (error "parse pattern error")]))
(rec s xs ys gs))

;; [Listof Any] -> Boolean
(define (distinct? xs)
(not (check-duplicates xs)))

;; [Listof Any] -> (Any -> Boolean)
(define (not-in m)
(λ (x) (not (memq x m))))
;; xs:[Listof Any] -> p:(x:Any -> Boolean)
;; Produce a predicate p for things not in xs
(define (not-in xs)
(λ (x) (not (memq x xs))))
(define (in m)
(λ (x) (memq x m)))


;; Any -> Boolean
(define (datum? x)
(or (exact-integer? x)
Expand Down
9 changes: 5 additions & 4 deletions loot/parse.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -222,16 +222,17 @@
[_ (error "parse pattern error")]))
(rec s xs ys))

;; [Listof Any] -> Boolean
(define (distinct? xs)
(not (check-duplicates xs)))

;; [Listof Any] -> (Any -> Boolean)
(define (not-in m)
(λ (x) (not (memq x m))))
;; xs:[Listof Any] -> p:(x:Any -> Boolean)
;; Produce a predicate p for things not in xs
(define (not-in xs)
(λ (x) (not (memq x xs))))
(define (in m)
(λ (x) (memq x m)))


;; Any -> Boolean
(define (datum? x)
(or (exact-integer? x)
Expand Down

0 comments on commit 63437fb

Please sign in to comment.