> Hi Jeff,
>
> hmmm, could you please explain what exactly goes on there?
> It looks like it would be nice to understand it, but at the
> moment, it looks, well, not exactly like C, but is as
> (un)understandable.
>
>
> thanks,
>
> Ingo
>
>
result: copy [] ;- where to put the parsed pieces
; Generate two parse rules using compose.
; They'll look like:
; space-piece: [copy x to " " (append result x)]
; end-piece: [copy x to end (append result x)]
;
; Those are both so similar, differing in only one
; thing that it seems like it would be nice to not
; have to type it twice and generate the rules instead.
foreach [rule thing] [space-piece " " end-piece 'end][
set rule compose [copy x to (thing) ([(append result x)])]
]
; so the parse rule now says essentially "stick only space
; deliminated strings in the result block" and that's
; what it does.
parse {this is a "test"} [some space-piece end-piece]
print mold result
== ["this" "is" "a" {"test"}]
; the copied chunk may be further massaged to remove
; or change desired chars before appending the result block.
Of course the (append result x) might be changed to:
(append result replace/all x ":" "_")
; Hope that's clearer. (-:
; -jeff