|
|
|
|
|
by martinflack
1348 days ago
|
|
I think what I'd really like is some way to expand format strings into McDermott-style code (and ideally vice versa). I think CL-PPCRE gets this correct for a similar domain: regex strings. The library is not pedantic about whether you provide the compact string or an expanded nice version. PPCRE> (parse-string "(ab)*")
(:GREEDY-REPETITION 0 NIL (:REGISTER "ab"))
PPCRE> (scan '(:greedy-repetition 0 nil (:register "ab")) "ababcd")
0
4
#(2)
#(4)
PPCRE>
|
|
Anyhow, while it's certainly possible to parse FORMAT control strings into S-expressions, ISTM that if you want them to be invertible back into FORMAT strings, you'll end up with control structure and constant strings being contained within the S-expression, with data extraction as a separate concern. IOW, you won't get McDermott's preferred style of interwoven control, data extraction, and constant strings. For instance, you could have this FORMAT control string
parse to something like but this still separates concerns the way FORMAT does, and the way OUT doesn't.