unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: <tomas@tuxteam.de>
To: guile-user@gnu.org
Subject: Re: sxml-match bad pattern syntax
Date: Tue, 28 Dec 2021 08:19:04 +0100	[thread overview]
Message-ID: <Ycq6aHxHC/pOkRxV@tuxteam.de> (raw)
In-Reply-To: <87h7atdzbo.fsf@gnuvola.org>

[-- Attachment #1: Type: text/plain, Size: 1534 bytes --]

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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

  reply	other threads:[~2021-12-28  7:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-28  6:21 sxml-match bad pattern syntax Thien-Thi Nguyen
2021-12-28  7:19 ` tomas [this message]
2021-12-28  7:58   ` Thien-Thi Nguyen
2021-12-28  8:28     ` tomas
2021-12-28  9:21       ` Thien-Thi Nguyen
2021-12-28 10:06         ` tomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Ycq6aHxHC/pOkRxV@tuxteam.de \
    --to=tomas@tuxteam.de \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).