File tree Expand file tree Collapse file tree 3 files changed +21
-3
lines changed
Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 231231
232232 (define visited
233233 (transduce (build-vector original-visits)
234+ (peeking
235+ (λ (visit)
236+ (unless (syntax-original-path visit)
237+ (raise-arguments-error
238+ 'source-analyze "pre-enriched visit is missing original path "
239+ "visited syntax " visit))))
234240 (deduplicating #:key syntax-original-path)
235241 (mapping enrich)
242+ (peeking
243+ (λ (visit)
244+ (unless (syntax-original-path visit)
245+ (raise-arguments-error
246+ 'source-analyze "post-enriched visit is missing original path "
247+ "visited syntax " visit))))
236248 (sorting syntax-path<=> #:key syntax-original-path)
237249 #:into into-list))
238250
Original file line number Diff line number Diff line change 1616(provide
1717 (contract-out
1818 [syntax-original-path (-> syntax? (or/c syntax-path? #false ))]
19+ [syntax-has-original-path? (-> syntax? boolean?)]
1920 [syntax-label-original-paths (-> syntax? syntax?)]
2021 [syntax-originally-neighbors? (-> syntax? syntax? boolean?)]
2122 [syntax-extract-originals-from-pair (-> syntax? syntax? (values syntax? syntax?))]))
4748 (syntax-label-paths stx original-syntax-path-key))
4849
4950
51+ (define (syntax-has-original-path? stx)
52+ (and (syntax-property stx original-syntax-path-key) #true ))
53+
54+
5055(define (syntax-original-path stx)
5156 ; The property value will be a cons tree if a macro produced a syntax object with the path property
5257 ; set. The main way this occurs is via `(begin x ...)`, as each of the `x` subforms counts as an
Original file line number Diff line number Diff line change 88 (contract-out
99 [syntax-replacement? (-> any/c boolean?)]
1010 [syntax-replacement
11- (-> #:original-syntax (and/c syntax? syntax-original?)
11+ (-> #:original-syntax (and/c syntax? syntax-original? syntax-has-original-path? )
1212 #:new-syntax syntax?
1313 #:source source?
1414 #:introduction-scope (->* (syntax?) ((or/c 'flip 'add 'remove )) syntax?)
1515 syntax-replacement?)]
1616 [syntax-replacement-render (-> syntax-replacement? string-replacement?)]
17- [syntax-replacement-original-syntax (-> syntax-replacement? (and/c syntax? syntax-original?))]
17+ [syntax-replacement-original-syntax
18+ (-> syntax-replacement? (and/c syntax? syntax-has-original-path?))]
1819 [syntax-replacement-new-syntax (-> syntax-replacement? syntax?)]
1920 [syntax-replacement-source (-> syntax-replacement? source?)]
2021 [syntax-replacement-introduction-scope
242243(module+ test
243244 (test-case (name-string syntax-replacement-render)
244245 (define orig-code "(+ 1 (+ 2 3)) " )
245- (define orig-stx (with-input-from-string orig-code read-syntax))
246+ (define orig-stx (syntax-label-original-paths ( with-input-from-string orig-code read-syntax) ))
246247 (define orig-start (sub1 (syntax-position orig-stx)))
247248 (define flip (make-syntax-introducer))
248249 (define new-stx
You can’t perform that action at this time.
0 commit comments