{"size": 2233, "ext": "scrbl", "max_stars_repo_path": "share/pkgs/compatibility-doc/mzlib/scribblings/awk.scrbl", "max_stars_repo_name": "takikawa/racket-ppa", "max_stars_repo_stars_event_min_datetime": "2018-07-29T04:13:52.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-14T16:11:17.000Z", "max_issues_repo_path": "compatibility-doc/mzlib/scribblings/awk.scrbl", "max_issues_repo_name": "NoahStoryM/compatibility", "max_issues_repo_issues_event_min_datetime": "2017-08-25T20:26:37.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T17:48:40.000Z", "max_forks_repo_path": "compatibility-doc/mzlib/scribblings/awk.scrbl", "max_forks_repo_name": "NoahStoryM/compatibility", "max_forks_repo_forks_event_min_datetime": "2015-03-09T12:20:01.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-09T05:02:56.000Z"}
{"max_stars_count": 10, "max_issues_count": 15, "max_forks_count": 8, "avg_line_length": 31.9, "max_line_length": 70, "alphanum_fraction": 0.605015674}
#lang scribble/doc
@(require "common.rkt"
          (for-label mzlib/awk
                     scheme/contract))

@mzlib[#:mode title awk]

@defform/subs[
#:literals (after range / => :range range: :range: else)
(awk next-record-expr
     (record field-id ...)
     maybe-counter
     ((state-variable init-expr) ...)
     maybe-continue
  clause ...)
([maybe-counter code:blank
                id]
 [maybe-continue code:blank
                 id]
 [clause (test body ...+)
         (test => procedure-expr)
         (/ regexp-str / (id-or-false ...+) body ...+)
         (range excl-start-test excl-stop-test body ...+)
         (:range incl-start-test excl-stop-test body ...+)
         (range: excl-start-test incl-stop-test body ...+)
         (:range: incl-start-test incl-stop-test body ...+)
         (else body ...+)
         (after body ...+)]
 [test integer
       regexp-string
       expr]
 [excl-start-test test]
 [excl-stop-test test]
 [incl-start-test test]
 [incl-stop-test test]
 [id-or-false id
              #f])]{

The @racket[awk] macro from Scsh @cite["Shivers06"]. In addition to
@racket[awk], the Scsh-compatible procedures @racket[match:start],
@racket[match:end], @racket[match:substring], and @racket[regexp-exec]
are defined. These @racketidfont{match:} procedures must be used to
extract match information in a regular expression clause when using
the @racket[=>] form.  }

@deftogether[(
@defproc[(match:start [rec ....]
                      [which exact-nonnegative-integer? 0])
         exact-nonnegative-integer?]
@defproc[(match:end   [rec ....]
                      [which exact-nonnegative-integer? 0])
         exact-nonnegative-integer?]
@defproc[(match:substring   
                      [rec ....]
                      [which exact-nonnegative-integer? 0])
         string?]
)]{

Extracts a start position, end position, or substring corresponding to
a match. The first argument is the value supplied to the procedure
after @racket[=>] in a @racket[awk] clause or the result of
@racket[regexp-exec].}


@defproc[(regexp-exec [re (or/c string? regexp?)] [s string?])
         (or/c .... false/c)]{

Matches a regexp to a string, returning a record compatible with
@racket[match:start], etc.}
