Add typed/syntax/modread, typed/syntax/srcloc, and typed/syntax/readerr (#353)
* add typed/syntax/modread.rkt * add typed/syntax/srcloc.rkt * add typed/syntax/readerr.rkt
This commit is contained in:
parent
a1f8908a29
commit
8c0a5a0b3e
22
typed-racket-more/typed/syntax/modread.rkt
Normal file
22
typed-racket-more/typed/syntax/modread.rkt
Normal file
|
@ -0,0 +1,22 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(provide with-module-reading-parameterization check-module-form)
|
||||
|
||||
(require typed/racket/unsafe)
|
||||
|
||||
(unsafe-require/typed syntax/modread
|
||||
[with-module-reading-parameterization
|
||||
(All (A) (-> (-> A) A))]
|
||||
[check-module-form
|
||||
;; check-module-form is already protected with the contract:
|
||||
;; (-> (or/c syntax? eof-object?)
|
||||
;; (or/c symbol? list?)
|
||||
;; (or/c string? path? false/c)
|
||||
;; any) ; This is any because the contract doesn't need
|
||||
;; ; to enforce that it's (or/c syntax? false/c).
|
||||
;; ; From the documentation:
|
||||
(-> (U (Syntaxof Any) EOF) ; (or/c syntax? eof-object?)
|
||||
Symbol ; symbol?
|
||||
(U String False) ; (or/c string? false/c)
|
||||
(U (Syntaxof Any) False))] ; (or/c syntax? false/c)
|
||||
)
|
23
typed-racket-more/typed/syntax/readerr.rkt
Normal file
23
typed-racket-more/typed/syntax/readerr.rkt
Normal file
|
@ -0,0 +1,23 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
;; Since typed racket can generate contracts for these, this doesn't
|
||||
;; need to use unsafe-require/typed.
|
||||
(require/typed/provide syntax/readerr
|
||||
[raise-read-error
|
||||
(-> String
|
||||
Any
|
||||
(U Positive-Integer False)
|
||||
(U Natural False)
|
||||
(U Positive-Integer False)
|
||||
(U Natural False)
|
||||
[#:extra-srclocs (Listof srcloc)]
|
||||
Nothing)]
|
||||
[raise-read-eof-error
|
||||
(-> String
|
||||
Any
|
||||
(U Positive-Integer False)
|
||||
(U Natural False)
|
||||
(U Positive-Integer False)
|
||||
(U Natural False)
|
||||
Nothing)]
|
||||
)
|
74
typed-racket-more/typed/syntax/srcloc.rkt
Normal file
74
typed-racket-more/typed/syntax/srcloc.rkt
Normal file
|
@ -0,0 +1,74 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
(provide Source-Location
|
||||
Source-Location-List
|
||||
Source-Location-Vector
|
||||
source-location?
|
||||
source-location-list?
|
||||
source-location-vector?
|
||||
check-source-location!
|
||||
build-source-location
|
||||
build-source-location-list
|
||||
build-source-location-vector
|
||||
build-source-location-syntax
|
||||
source-location-known?
|
||||
source-location-source
|
||||
source-location-line
|
||||
source-location-column
|
||||
source-location-position
|
||||
source-location-span
|
||||
source-location-end
|
||||
update-source-location
|
||||
source-location->string
|
||||
source-location->prefix
|
||||
)
|
||||
|
||||
(require typed/racket/unsafe)
|
||||
|
||||
(define-type Source-Location
|
||||
(U srcloc
|
||||
(Syntaxof Any)
|
||||
Source-Location-List
|
||||
Source-Location-Vector
|
||||
False))
|
||||
|
||||
(define-type Source-Location-List
|
||||
(List Any
|
||||
(U Positive-Integer False)
|
||||
(U Natural False)
|
||||
(U Positive-Integer False)
|
||||
(U Natural False)))
|
||||
|
||||
(define-type Source-Location-Vector
|
||||
(Vector Any
|
||||
(U Positive-Integer False)
|
||||
(U Natural False)
|
||||
(U Positive-Integer False)
|
||||
(U Natural False)))
|
||||
|
||||
(unsafe-require/typed syntax/srcloc
|
||||
[source-location? (-> Any Boolean)]
|
||||
[source-location-list? (-> Any Boolean)]
|
||||
[source-location-vector? (-> Any Boolean)]
|
||||
[check-source-location! (-> Symbol Any Void)]
|
||||
[build-source-location (-> Source-Location * srcloc)]
|
||||
[build-source-location-list (-> Source-Location * Source-Location-List)]
|
||||
[build-source-location-vector (-> Source-Location * Source-Location-Vector)]
|
||||
[build-source-location-syntax (-> Source-Location * (Syntaxof Any))]
|
||||
[source-location-known? (-> Source-Location Boolean)]
|
||||
[source-location-source (-> Source-Location Any)]
|
||||
[source-location-line (-> Source-Location (U Positive-Integer False))]
|
||||
[source-location-column (-> Source-Location (U Natural False))]
|
||||
[source-location-position (-> Source-Location (U Positive-Integer False))]
|
||||
[source-location-span (-> Source-Location (U Natural False))]
|
||||
[source-location-end (-> Source-Location (U Natural False))]
|
||||
[update-source-location (-> Source-Location
|
||||
[#:source Any]
|
||||
[#:line (U Positive-Integer False)]
|
||||
[#:column (U Natural False)]
|
||||
[#:position (U Positive-Integer False)]
|
||||
[#:span (U Natural False)]
|
||||
Source-Location)]
|
||||
[source-location->string (-> Source-Location String)]
|
||||
[source-location->prefix (-> Source-Location String)]
|
||||
)
|
Loading…
Reference in New Issue
Block a user