How would you go about designing a pipe to parse records with arbitrary
variable data in them?

In Frank's post we had the advantage of knowing that a comma delineated
all the fields we were interested in.  How would we proceed if each
"constant" or field separator had an arbitrary number of variable fields
following it?

Suppose for example we had a stream of records, where each record had
the general form of:

CONSTANT1 {variable1a variable1b ...} CONSTANT2 {variable2a variable2b
...} ..., where everything is blank delineated.

We know in advance the values of all the constants, but we don't know
the number, type, or length of the variables interspersed between them.
We would like to parse out the variables, perform operations, and write
them back out.

In rexx this seems like a job for iteratively parsing the record into
variable strings and arrays indexed by WORD(varstring) to figure out
what we've got.  How would you approach this in pipes?

One simpleminded idea I have is to use multiple spec stages.  First,
spec subst fs constant write to break each record into its constituent
constant/variable parts, parse each newly generated record with spec a:
word (I am lucky in that I know in advance the maximum number of
variables), then use conditional processing to do the work on the
variables, and write them back out.

Reply via email to