On Tue, Nov 03, 2009 at 05:58:20PM +0100, Henrik Sarvell wrote:
> Am I missing something? Won't the first (from) basically find the
> first instance of "<item" and put the reader at that place? If I use


> match here am I not matching on the whole of the rest of the document?

No, I was talking about the return value of 'make'

(while (from "<item>")
   (println                                       # Instead of printing
      (make                                       # do further matching
            (NIL (chain (till ">")))              # Collect until next tag
            (char)                                # Skip '>'
            (T (tail '`(chop "item") @)) ) ) ) )  # See if we got <item>

'make' returns everything that was collected by 'till' and 'chain' in a

The tail of that list will be ("i" "t" "e" "m") if 'loop' was terminated
by the 'T' clause, or something unexpected when end of file was hit (the
'NIL' clause).

So how about such a structure:

(while (from "<item>")
   (let Lst
            (NIL (chain (till ">")))
            (T (tail '`(chop "item") @)) ) )
         ((match ... Lst)
            ... )
         ((match ... Lst)

You could also immediately check for the trailing ("i" "t" "e" "m") and
discard results which do not match it:

(use @X
   (while (from "<item>")
         (match '(@X "i" "t" "e" "m")
                  (NIL (chain (till ">")))
                  (T (tail '`(chop "item") @)) ) ) )
         (got something in @X without trailing "item")
         ... ) ) )

Again, just ideas, not tested ;-)

- Alex
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

Reply via email to