On this page:
format-id/  record
with-sub-range-binders
with-arrows
syntax-parser-with-arrows
record-sub-range-binders!
maybe-record-sub-range-binders!
current-recorded-sub-range-binders
sub-range-binder/  c
7.1

35 Formatting identifiers so that DrRacket still shows arrows

Georges Dupéron <[email protected]>

procedure

(format-id/record lctx    
  fmt    
  [#:source src    
  #:props props]    
  vs ...)  identifier?
  lctx : (or/c syntax? #f)
  fmt : 
(stx-e/c
 (and/c string?
        (regexp-match/c "^([^~]|~~|~a|~A)*$")))
  src : (or/c syntax? #f) = #f
  props : (or/c syntax? #f) = #f
  vs : 
(or/c string? symbol? keyword? char? number?
      (syntax/c string?)
      identifier?
      (syntax/c keyword?)
      (syntax/c char?)
      (syntax/c number?))
Like format-id, but cooperates with with-sub-range-binders to record sub-range binders, which allow DrRacket to draw arrows from the identifiers present in vs ... to occurrences of the resulting identifier. It also means that when one or more identifiers present in vs ... are concatenated with other strings, it is possible to rename parts of the resulting identifier in DrRacket.

If fmt is a syntax object containing a string, then arrows are drawn from the format itself to the generated identifier, for each part of the format which appears in the identifier (e.g. if the format is "x~~y~az", then two arrows will be drawn from the format, one for "x~~y", and one for "z".

This function must be called within the dynamic extent of with-sub-range-binders or with-arrows.

syntax

(with-sub-range-binders body-expr ... stx-expr)

The value produced by stx-expr must be a syntax object. All sub-range binders recorded via record-sub-range-binders! or maybe-record-sub-range-binders! are added to the syntax object in a 'sub-range-binders property.

syntax

(with-arrows body-expr ... stx-expr)

Equivalent to:

(with-disappeared-uses
 (with-sub-range-binders
  body-expr ... stx-expr))

syntax

(syntax-parser-with-arrows . syntax-parser-options+clauses)

Equivalent to:

(λ (stx)
  (with-arrows
   ((syntax-parser . syntax-parser-options+clauses) stx)))

Within the syntax-parser-options+clauses, it is possible to use the stx identifier to refer to the whole syntax, in addition to using syntax/parse’s this-syntax.

procedure

(record-sub-range-binders! sub-range-binders)  void?

  sub-range-binders : 
(or/c sub-range-binder/c
      (listof sub-range-binder/c))
Cooperates with the enclosing with-sub-range-binders or with-arrows to record the given sub-range-binders so that they are added to the syntax object returned by with-sub-range-binders or with-arrows.

This function must be called within the dynamic extent of with-sub-range-binders or with-arrows.

procedure

(maybe-record-sub-range-binders! sub-range-binders)  void?

  sub-range-binders : 
(or/c sub-range-binder/c
      (listof sub-range-binder/c))
Cooperates with the enclosing with-sub-range-binders or with-arrows to record the given sub-range-binders so that they are added to the syntax object returned by with-sub-range-binders or with-arrows.

If this function is not called within the dynamic extent of with-sub-range-binders or with-arrows, it has no effect and the sub-range-binders are not recorded.

This parameter contains the list of sub-range-binders recorded so far by the nearest with-sub-range-binders or with-arrows.

value

sub-range-binder/c : chaperone-contract?

 = 
(or/c (vector/c syntax?
                exact-nonnegative-integer? exact-nonnegative-integer?
                (real-in 0 1) (real-in 0 1)
                syntax?
                exact-nonnegative-integer? exact-nonnegative-integer?
                (real-in 0 1) (real-in 0 1))
      (vector/c syntax?
                exact-nonnegative-integer? exact-nonnegative-integer?
                syntax?
                exact-nonnegative-integer? exact-nonnegative-integer?))
A contract accepting valid representations of sub-range binders.