From: <tomas@tuxteam.de>
To: guile-user@gnu.org
Subject: Re: sxml-match bad pattern syntax
Date: Tue, 28 Dec 2021 09:28:32 +0100 [thread overview]
Message-ID: <YcrKsJE0PIYVA/5C@tuxteam.de> (raw)
In-Reply-To: <87a6gldutb.fsf@gnuvola.org>
[-- Attachment #1: Type: text/plain, Size: 1880 bytes --]
On Tue, Dec 28, 2021 at 02:58:56AM -0500, Thien-Thi Nguyen wrote:
>
> () <tomas@tuxteam.de>
> () Tue, 28 Dec 2021 08:19:04 +0100
>
> I /think/ the ellipsis is at a wrong place there [...]
> Haha, i know exactly how you feel.
%-)
> Ah, right! The ellipses are a tail that need to follow a head.
No, the ellipses tell the matcher that the symbol to its left acutally
stands for "zero or more of this". Consequently, you have to somehow [1]
use those ellipses on the right hand side (aka template) whenever you use
them on the left hand side (aka pattern) and vice versa.
> I guess i was confused by the documentation's use of ellipses in
> the conventional sense rather than the literal sense:
I think of the ellipses as a kind of funny Kleene star. Not really at
home in any world: in the regular world, because it isn't a star, in
the Scheme world, because it is postfix.
So, to come back on your original example,
(@ . ,attrs) ...
would match either empty (remember: zero or more) or
(@ (foo 1) (bar 2))
or
(@ (meep 1)) (@ "this ain't what we expected))
... so zero or more of (@ . stuff) where stuff stands for any
S-expression (note that it's sloppy: it will match things which aren't
lists of well-formed attribute lists [2]).
It won't match
(@ (foo 1)) (@ (bar 2)) ("rumpelstilzchen")
for example.
> Anyway, thanks to your help, i've managed to cobble together the
> following code, attached here for the benefit of future self:
[...]
Thanks. And thanks for the code :)
> Maybe it's idiomatic. Feedback on how to improve it welcome!
For the idiomatic part, I'll have to defer to those with more chevrons
;-)
Cheers
[1] Yes, some handwaving here.
[2] which isn't what you want to match, anyway. You want to match things
with one attribute list in them.
Cheers
--
t
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
next prev parent reply other threads:[~2021-12-28 8:28 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
2021-12-28 7:58 ` Thien-Thi Nguyen
2021-12-28 8:28 ` tomas [this message]
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=YcrKsJE0PIYVA/5C@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).