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

Yes.

> 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
         (loop
            (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
list.

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
      (make
         (loop
            (NIL (chain (till ">")))
            (char)
            (T (tail '`(chop "item") @)) ) )
      (cond
         ((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>")
      (when
         (match '(@X "i" "t" "e" "m")
            (make
               (loop
                  (NIL (chain (till ">")))
                  (char)
                  (T (tail '`(chop "item") @)) ) ) )
         (got something in @X without trailing "item")
         ... ) ) )

Again, just ideas, not tested ;-)

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

Reply via email to