guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sxml-match bad pattern syntax


From: tomas
Subject: Re: sxml-match bad pattern syntax
Date: Tue, 28 Dec 2021 08:19:04 +0100

On Tue, Dec 28, 2021 at 01:21:31AM -0500, Thien-Thi Nguyen wrote:
> 
> In an effort to join the current millennium,

:-)

>                                             i have started to
> play w/ Guile 2.x's SXML facilities.  Good stuff!  I've run into
> a problem, however, and hope i can get help resolving it here.
> 
> The following small program attempts to use ‘sxml-match’ to
> remove an unwanted attribute from a (well-formed) SXML snippet.

> #!/usr/bin/guile -s
> !#
> (use-modules
>  (sxml match))
> 
> (define (unbogus x)
>   (sxml-match x
>     ((a (@ . ,attrs) ...)
>      `(a (@ ,@(delete '(shape "rect") attrs)) ...))))

I /think/ the ellipsis is at a wrong place there. Note that I'm coming
from "traditional" match, and I just have wrapped half of my brain
around that (which, BTW, is somewhat painful :-)

So take this with a grain of salt.

* Phenomenology (aka: I barely know what I'm doing):

If you replace your ellipses above by ". ,rest", things seem to work:

 (define (unbogus x)
   (sxml-match x
     ((a (@ . ,attrs) . ,rest)
      `(a (@ ,@(delete '(shape "rect") attrs)) . ,rest))))

 (unbogus '(a (@ (shape "rect") (href "foo.html")) "kid"))

 => (a (@ (href "foo.html")) "kid")

* Philosophy (aka blah, blah)

If those ellipses resemble what match do, I think they are wrong there:

  (@ . ,attrs) ...

would mean zero or more times the shape "(@ . ,attrs)". I think this
isn't what you want.

Put grains of salt everywhere :)

Cheers
-- 
t

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]