From c81b628282e96309bb296b35fab3fb5a678a61d1 Mon Sep 17 00:00:00 2001 From: Sorawee Porncharoenwase Date: Wed, 28 Oct 2020 18:25:46 -0700 Subject: [PATCH] Rename define-simple-macro to define-syntax-parse-rule This PR is based on @lexi-lambda's #1310. It resolves the conflicts in the mentioned PR and adjusts the version so that it's up-to-date. --- .../syntax/scribblings/parse/define.scrbl | 27 ++++++++++++------- racket/collects/syntax/parse/define.rkt | 9 ++++--- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/pkgs/racket-doc/syntax/scribblings/parse/define.scrbl b/pkgs/racket-doc/syntax/scribblings/parse/define.scrbl index 1d587a8283..815396a4bf 100644 --- a/pkgs/racket-doc/syntax/scribblings/parse/define.scrbl +++ b/pkgs/racket-doc/syntax/scribblings/parse/define.scrbl @@ -12,7 +12,7 @@ @defmodule[syntax/parse/define] -@defform[(define-simple-macro (macro-id . pattern) pattern-directive ... +@defform[(define-syntax-parse-rule (macro-id . pattern) pattern-directive ... template)]{ Defines a macro named @racket[macro-id]; equivalent to the following: @@ -26,11 +26,11 @@ Defines a macro named @racket[macro-id]; equivalent to the following: @(the-eval '(require syntax/parse/define)) @examples[#:eval the-eval -(define-simple-macro (fn x:id rhs:expr) (lambda (x) rhs)) +(define-syntax-parse-rule (fn x:id rhs:expr) (lambda (x) rhs)) ((fn x x) 17) (fn 1 2) -(define-simple-macro (fn2 x y rhs) +(define-syntax-parse-rule (fn2 x y rhs) #:declare x id #:declare y id #:declare rhs expr @@ -39,12 +39,7 @@ Defines a macro named @racket[macro-id]; equivalent to the following: (fn2 a #:b 'c) ] -@history[#:changed "6.12.0.3" @elem{Changed pattern head to @racket[(~var macro-id id)] from - @racket[macro-id], allowing tilde-prefixed identifiers or - identifiers containing colons to be used as @racket[macro-id] - without producing a syntax error.} - #:changed "6.90.0.29" @elem{Changed to always use the @racket[#:track-literals] - @racket[syntax-parse] option.}] +@history[#:added "7.9.0.3"] } @defform[(define-syntax-parser macro-id parse-option ... clause ...+)]{ @@ -68,4 +63,18 @@ Defines a macro named @racket[macro-id]; equivalent to: (fn3 a #:b 'c) ]} +@defform[(define-simple-macro (macro-id . pattern) pattern-directive ... + template)]{ +@deprecated[#:what "macro" @racket[define-syntax-parse-rule]] + +Re-exports @racket[define-syntax-parse-rule] for backward-compatibility. + +@history[#:changed "6.12.0.3" @elem{Changed pattern head to @racket[(~var macro-id id)] from + @racket[macro-id], allowing tilde-prefixed identifiers or + identifiers containing colons to be used as @racket[macro-id] + without producing a syntax error.} + #:changed "6.90.0.29" @elem{Changed to always use the @racket[#:track-literals] + @racket[syntax-parse] option.}] +} + @(close-eval the-eval) diff --git a/racket/collects/syntax/parse/define.rkt b/racket/collects/syntax/parse/define.rkt index 80af669b22..5e97c24e9b 100644 --- a/racket/collects/syntax/parse/define.rkt +++ b/racket/collects/syntax/parse/define.rkt @@ -2,19 +2,20 @@ (require (for-syntax racket/base syntax/parse "private/sc.rkt")) -(provide define-simple-macro +(provide define-syntax-parse-rule define-syntax-parser + (rename-out [define-syntax-parse-rule define-simple-macro]) (for-syntax (all-from-out syntax/parse))) -(define-syntax (define-simple-macro stx) +(define-syntax (define-syntax-parse-rule stx) (syntax-parse stx - [(define-simple-macro (macro:id . pattern) . body) + [(_ (macro:id . pattern) . body) #`(define-syntax macro (syntax-parser/template #,((make-syntax-introducer) stx) [((~var macro id) . pattern) . body]))])) -(define-simple-macro (define-syntax-parser macro:id option-or-clause ...) +(define-syntax-parse-rule (define-syntax-parser macro:id option-or-clause ...) (define-syntax macro (syntax-parser option-or-clause ...)))