use `contract-out` instead of `define/contract`

dev-srcloc
Matthew Butterick 8 years ago
parent 642ebc436a
commit 13e7f3ee97

@ -3,13 +3,7 @@
(define in-racket-expr? #f)
(define/contract (color-jsonic port)
(input-port? . -> . (values
(or/c string? eof-object?)
symbol?
(or/c symbol? #f)
(or/c exact-positive-integer? #f)
(or/c exact-positive-integer? #f)))
(define (color-jsonic port)
(define jsonic-lexer
(lexer
[(eof) (values lexeme 'eof #f #f #f)]
@ -31,7 +25,15 @@
(not (equal? (peek-string 2 0 port) "$@")))
(racket-lexer port)
(jsonic-lexer port)))
(provide color-jsonic)
(provide
(contract-out
[color-jsonic
(input-port? . -> . (values
(or/c string? eof-object?)
symbol?
(or/c symbol? #f)
(or/c exact-positive-integer? #f)
(or/c exact-positive-integer? #f)))]))
(module+ test
(require rackunit)

@ -1,14 +1,11 @@
#lang br
(require br/indent racket/gui/base racket/contract)
(provide indent-jsonic)
(require br/indent racket/contract racket/gui/base)
(define indent-width 2)
(define (left-bracket? c) (member c (list #\{ #\[)))
(define (right-bracket? c) (member c (list #\} #\])))
(define/contract (indent-jsonic tbox [posn 0])
((is-a?/c text%) exact-nonnegative-integer? . -> .
(or/c exact-nonnegative-integer? #f))
(define (indent-jsonic tbox [posn 0])
(define prev-line (previous-line tbox posn))
(define current-line (line tbox posn))
(define prev-indent (or (line-indent tbox prev-line) 0))
@ -22,6 +19,11 @@
(- prev-indent indent-width)]
[else prev-indent]))
(and (exact-positive-integer? current-indent) current-indent))
(provide
(contract-out
[indent-jsonic (((is-a?/c text%))
(exact-nonnegative-integer?) . ->* .
(or/c exact-nonnegative-integer? #f))]))
(module+ test
(require rackunit)

@ -1,10 +1,10 @@
#lang br/quicklang
(require "tokenizer.rkt" "parser.rkt" racket/contract)
(define/contract (read-syntax path port)
(any/c input-port? . -> . syntax?)
(define (read-syntax path port)
(define parse-tree (parse path (tokenize port)))
(define module-datum `(module jsonic-module jsonic-demo-2/expander
,parse-tree))
(datum->syntax #f module-datum))
(provide read-syntax)
(provide (contract-out
[read-syntax (any/c input-port? . -> . syntax?)]))

@ -13,11 +13,9 @@
(check-true (token? (token 'A-TOKEN-STRUCT "hi")))
(check-false (token? 42)))
(define/contract (tokenize port)
(input-port? . -> . (-> token?))
(define (tokenize port)
(port-count-lines! port)
(define/contract (next-token)
(-> token?)
(define (next-token)
(define our-lexer
(lexer
[(eof) eof]
@ -37,7 +35,8 @@
(pos lexeme-start)))]))
(our-lexer port))
next-token)
(provide tokenize)
(provide (contract-out
[tokenize (input-port? . -> . (-> token?))]))
(module+ test
(check-equal? (apply-tokenizer tokenize "// comment\n") empty)

Loading…
Cancel
Save