rename parse-typed-syntax to syntax-parse/typecheck; closes #50 again

This commit is contained in:
Stephen Chang 2017-01-24 16:56:12 -05:00
parent 896ec53151
commit 0084146c1c
3 changed files with 20 additions and 12 deletions

View File

@ -675,7 +675,7 @@
#:with out
(cond
[(×? #'τ_e) ;; e is tuple
(parse-typed-syntax #'clauses
(syntax-parse/typecheck #'clauses
[([x ... (~datum ->) e_body])
#:with (~× ty ...) #'τ_e
#:fail-unless (stx-length=? #'(ty ...) #'(x ...))
@ -689,7 +689,7 @@
(let- ([x- (acc z)] ...) e_body-))
ty_body]])]
[(List? #'τ_e) ;; e is List
(parse-typed-syntax #'clauses
(syntax-parse/typecheck #'clauses
[([(~or (~and (~and xs [x ...]) (~parse rst (generate-temporary)))
(~and (~seq (~seq x (~datum ::)) ... rst:id) (~parse xs #'())))
(~datum ->) e_body] ...+)
@ -721,7 +721,7 @@
(let- ([x- (acc1 z)] ... [rst- (acc2 z)]) e_body-)] ...))
( ty_body ...)]])]
[else ;; e is variant
(parse-typed-syntax #'clauses
(syntax-parse/typecheck #'clauses
[([Clause:id x:id ...
(~optional (~seq #:when e_guard) #:defaults ([e_guard #'(ext-stlc:#%datum . #t)]))
(~datum ->) e_c_un] ...+) ; un = unannotated with expected ty

View File

@ -180,8 +180,11 @@ attach type information to the top-level @tt{x} identifier, so the
]}
@; parse-typed-syntax ---------------------------------------------------------
@defform[(parse-typed-syntax stx option ... rule ...+)]{
@defform[(define-typerule ....)]{Alias for @racket[define-typed-syntax].}
@defform[(define-syntax/typecheck ....)]{Alias for @racket[define-typed-syntax].}
@; syntax-parse/typecheck------------------------------------------------------
@defform[(syntax-parse/typecheck stx option ... rule ...+)]{
A @racket[syntax-parse]-like form that supports
@racket[define-typed-syntax]-style clauses. In particular, see the
"rule" part of @racket[define-typed-syntax]'s grammar above.}
@ -199,18 +202,22 @@ identifier @racket[op-id], e.g.:
When not specified, @racket[op-id] is @racket[typed-op-id] suffixed with
@litchar{-} (see @secref{racket-}).}
@; define-syntax-category -----------------------------------------------------
@defform[(define-syntax-category name-id)]{
Defines a new "category" of syntax by defining a series of forms and functions.
Turnstile pre-declares @racket[(define-syntax-category type)], which in turn
defines the following forms and functions.
defines the following forms and functions:
@margin-note{It's not important to immediately understand all these
definitions. Some, like @racket[type?] and @racket[mk-type], are
more "low-level" and are mainly used by the other forms. The most useful forms
are probably @racket[define-typed-syntax], and the type-defining forms
@racket[define-base-type], @racket[define-type-constructor], and
@racket[define-binding-type].}
Note: It's typically not necessary to
use any forms other than @racket[define-base-type] and
@racket[define-type-constructor] in conjunction with @racket[define-typed-syntax]. The other forms are considered "low-level" and are automatically used by @racket[define-typed-syntax].
@itemlist[
@item{@racket[define-typed-syntax], as described above.
Uses @racket[current-typecheck-relation] for typechecking.}
@item{@defform[(define-typerule ....)]{An alias for @racket[define-typed-syntax].}}
@item{@defform*[((define-base-type base-type-name-id)
(define-base-type base-type-name-id : kind))]{
Defines a base type. @racket[(define-base-type τ)] in turn defines:

View File

@ -3,10 +3,11 @@
(provide (except-out (all-from-out macrotypes/typecheck)
-define-typed-syntax -define-syntax-category)
define-typed-syntax define-syntax-category
(rename-out [define-typed-syntax define-typerule])
(rename-out [define-typed-syntax define-typerule]
[define-typed-syntax define-syntax/typecheck])
(for-syntax syntax-parse/typed-syntax
(rename-out
[syntax-parse/typed-syntax parse-typed-syntax])))
[syntax-parse/typed-syntax syntax-parse/typecheck])))
(require (except-in (rename-in
macrotypes/typecheck