From b23ee8fc3f36d809c4728d4c31e91c95ab20b778 Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Tue, 24 Jan 2017 14:51:03 -0500 Subject: [PATCH] provide syntax-parse/typed-syntax as parse-typed-syntax - but dont remove the old name - closes #50 --- turnstile/examples/mlish+adhoc.rkt | 6 +++--- turnstile/scribblings/reference.scrbl | 7 +++++++ turnstile/turnstile.rkt | 4 +++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/turnstile/examples/mlish+adhoc.rkt b/turnstile/examples/mlish+adhoc.rkt index 1513da3..8b727b0 100644 --- a/turnstile/examples/mlish+adhoc.rkt +++ b/turnstile/examples/mlish+adhoc.rkt @@ -675,7 +675,7 @@ #:with out (cond [(×? #'τ_e) ;; e is tuple - (syntax-parse/typed-syntax #'clauses + (parse-typed-syntax #'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 - (syntax-parse/typed-syntax #'clauses + (parse-typed-syntax #'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 - (syntax-parse/typed-syntax #'clauses + (parse-typed-syntax #'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 diff --git a/turnstile/scribblings/reference.scrbl b/turnstile/scribblings/reference.scrbl index a8f8664..60e6226 100644 --- a/turnstile/scribblings/reference.scrbl +++ b/turnstile/scribblings/reference.scrbl @@ -32,6 +32,7 @@ and then press Control-@litchar{\}. @section{Forms} +@; define-typed-syntax--------------------------------------------------------- @defform*[ #:literals (≫ ⊢ ⇒ ⇐ ≻ : --------) ((define-typed-syntax (name-id . pattern) ≫ @@ -179,7 +180,13 @@ attach type information to the top-level @tt{x} identifier, so the ]} +@; parse-typed-syntax --------------------------------------------------------- +@defform[(parse-typed-syntax 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.} +@; define-primop -------------------------------------------------------------- @defform*[((define-primop typed-op-id τ) (define-primop typed-op-id : τ) (define-primop typed-op-id op-id τ) diff --git a/turnstile/turnstile.rkt b/turnstile/turnstile.rkt index d345217..f915344 100644 --- a/turnstile/turnstile.rkt +++ b/turnstile/turnstile.rkt @@ -4,7 +4,9 @@ -define-typed-syntax -define-syntax-category) define-typed-syntax define-syntax-category (rename-out [define-typed-syntax define-typerule]) - (for-syntax syntax-parse/typed-syntax)) + (for-syntax syntax-parse/typed-syntax + (rename-out + [syntax-parse/typed-syntax parse-typed-syntax]))) (require (except-in (rename-in macrotypes/typecheck