fix lexer contract

This commit is contained in:
Robby Findler 2013-02-26 08:47:59 -06:00
parent 478ec22d02
commit 3c295d14d0
2 changed files with 15 additions and 13 deletions

View File

@ -3,6 +3,16 @@
unstable/options) unstable/options)
(provide lexer/c) (provide lexer/c)
(define (end/c start type)
(cond
[(equal? 'eof type)
(or/c exact-positive-integer? #f)]
[start
(and/c exact-positive-integer?
(>/c start))]
[else
#f]))
(define lexer/c (define lexer/c
(option/c (option/c
(or/c (->i ([in (and/c input-port? port-counts-lines?)]) (or/c (->i ([in (and/c input-port? port-counts-lines?)])
@ -10,11 +20,7 @@
[type symbol?] [type symbol?]
[paren (or/c symbol? #f)] [paren (or/c symbol? #f)]
[start (or/c exact-positive-integer? #f)] [start (or/c exact-positive-integer? #f)]
[end (start) [end (start type) (end/c start type)]))
(if start
(and/c exact-positive-integer?
(>=/c start))
#f)]))
(->i ([in (and/c input-port? port-counts-lines?)] (->i ([in (and/c input-port? port-counts-lines?)]
[offset exact-nonnegative-integer?] [offset exact-nonnegative-integer?]
[mode any/c]) [mode any/c])
@ -22,11 +28,7 @@
[type symbol?] [type symbol?]
[paren (or/c symbol? #f)] [paren (or/c symbol? #f)]
[start (or/c exact-positive-integer? #f)] [start (or/c exact-positive-integer? #f)]
[end (start) [end (start type) (end/c start type)]
(if start
(and/c exact-positive-integer?
(>=/c start))
#f)]
[backup exact-nonnegative-integer?] [backup exact-nonnegative-integer?]
[new-mode any/c]))) [new-mode any/c])))
#:tester (λ (x) (and (procedure? x) #:tester (λ (x) (and (procedure? x)

View File

@ -7,9 +7,9 @@
(provide (provide
(contract-out (contract-out
[racket-lexer lexer/c] [racket-lexer lexer/c])
[racket-lexer/status lexer/c] racket-lexer/status
[racket-nobar-lexer/status lexer/c])) racket-nobar-lexer/status)
(define-lex-abbrevs (define-lex-abbrevs