From 5d1ff0327f23021872a9ef367411ea8a188135b2 Mon Sep 17 00:00:00 2001 From: Ben Greenman Date: Wed, 26 Jul 2017 18:22:48 -0400 Subject: [PATCH] doc: scribblings for 'syntax/source-syntax' --- source-syntax/info.rkt | 4 +++- source-syntax/scribblings/source-syntax.scrbl | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 source-syntax/scribblings/source-syntax.scrbl diff --git a/source-syntax/info.rkt b/source-syntax/info.rkt index 938d17ae..cfcbd446 100644 --- a/source-syntax/info.rkt +++ b/source-syntax/info.rkt @@ -8,4 +8,6 @@ (define pkg-authors '(samth stamourv eli)) -(define version "1.1") \ No newline at end of file +(define version "1.1") + +(define scribblings '(("scribblings/source-syntax.scrbl" () (tool-library)))) diff --git a/source-syntax/scribblings/source-syntax.scrbl b/source-syntax/scribblings/source-syntax.scrbl new file mode 100644 index 00000000..7c1211dc --- /dev/null +++ b/source-syntax/scribblings/source-syntax.scrbl @@ -0,0 +1,24 @@ +#lang scribble/manual +@require[scribble/example (for-label racket/base racket/contract)] + +@title{Source Syntax} + +@defmodule[syntax/source-syntax]{} + +@defproc[(recover-source-syntax [orig syntax?] + [expanded syntax?] + [#:traverse-now? now? boolean? #f]) + (-> syntax? (or/c syntax? #f))]{ + Return a procedure that accepts a syntax object from @racket[expanded] + and returns the outermost syntax object in @racket[orig] that has the same + location as the given syntax object. + If no syntax object in @racket[orig] has the same location as the given syntax + object, the procedure repeats with the parent of the given syntax object. +} + +@examples[#:eval (make-base-eval '(require syntax/source-syntax)) + (let* ([orig #'(λ (x [y 0]) (+ x y))] + [expanded (expand orig)] + [recovered ((recover-source-syntax orig expanded) expanded)]) + (syntax? recovered)) +]