[racket] Looking for awk examples
The awk macro refers to the documentation in scsh; there are examples
of the awk macro there in:
http://www.scsh.net/docu/html/man-Z-H-9.html#node_sec_8.2.1
Some of the examples there may need some adaptation, as I don't think
Racket has an "sre" library to support the writing regexps with
s-expressions. Here's one adapted example:
Example:
#lang racket/base
(require mzlib/awk)
;; Reads the number of uncommented lines
(awk (read-line) (line) ((nlines 0))
("^\\s*;" nlines) ; A comment line.
(else (+ nlines 1))) ; Not a comment line.
The original sre for this was (: bos (* white) ";"), which I've
translated to a string representation that appears to be effective.
But it's not obvious from the documentation what kind of regular
expression strings are allowed by this mzlib/awk library, though.
Related: it's one of the "Larger Projects" proposed on the wiki, to
make a modern #lang scsh:
https://github.com/plt/racket/wiki/Intro-Projects