From 56bb28dfc6058e611f763695ee759989237cbb55 Mon Sep 17 00:00:00 2001 From: Ryan Culpepper Date: Wed, 11 May 2011 00:45:30 -0600 Subject: [PATCH] unstable/syntax: added explode-module-path-index --- collects/unstable/scribblings/syntax.scrbl | 14 ++++++++++++++ collects/unstable/syntax.rkt | 14 ++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/collects/unstable/scribblings/syntax.scrbl b/collects/unstable/scribblings/syntax.scrbl index 6747eb2b49..2fcab2e2ec 100644 --- a/collects/unstable/scribblings/syntax.scrbl +++ b/collects/unstable/scribblings/syntax.scrbl @@ -18,6 +18,20 @@ @unstable[@author+email["Ryan Culpepper" "ryanc@racket-lang.org"]] +@defproc[(explode-module-path-index [mpi module-path-index?]) + (listof (or/c module-path? resolved-module-path? #f))]{ + +Unfolds @racket[mpi] using @racket[module-path-index-split], returning +a list of the relative module paths together with the terminal +resolved module path or @racket[#f] for the ``self'' module. + +@examples[#:eval the-eval +(explode-module-path-index (car (identifier-binding #'lambda))) +(explode-module-path-index (caddr (identifier-binding #'lambda))) +(explode-module-path-index (car (identifier-binding #'define-values))) +] +} + @;{----} @margin-note{This binding was added by Vincent St-Amour.} diff --git a/collects/unstable/syntax.rkt b/collects/unstable/syntax.rkt index c34bbbb18b..44d9810efa 100644 --- a/collects/unstable/syntax.rkt +++ b/collects/unstable/syntax.rkt @@ -7,13 +7,14 @@ syntax-list ;; by cce: - syntax-source-file-name syntax-source-directory ;; by stamourv: + format-unique-id - format-unique-id) + ;; by ryanc + explode-module-path-index) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; @@ -60,3 +61,12 @@ ((make-syntax-introducer) (apply format-id lctx #:source src #:props props #:cert cert fmt args))) + +;; by ryanc + +(define (explode-module-path-index mpi) + (let-values ([(x y) (module-path-index-split mpi)]) + (cons x + (if (module-path-index? y) + (explode-module-path-index y) + (list y)))))