unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Help with match
@ 2019-05-09 10:04 swedebugia
  2019-05-10 13:53 ` Timothy Sample
  0 siblings, 1 reply; 3+ messages in thread
From: swedebugia @ 2019-05-09 10:04 UTC (permalink / raw)
  To: guix-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 279 bytes --]

Hi

I am almost finished with the quicklisp importer but I'm stuck with not
being able to match what I want with the pattern matcher.

I (still) don't understand the documentation for this matcher and I
can't get it to do what I want it seems :/

-- 
Cheers Swedebugia

[-- Attachment #1.1.2: match-error.txt --]
[-- Type: text/plain, Size: 1578 bytes --]

scheme@(guile-user) [8]> (let ((l '(asd-record (license-line (text-until-dq MIT)) (synopsis-line (text-until-dq An async HTTP client)) dependencies (dependencies (text alexandria)) (dependencies (text babel)) (dependencies (text fast-io)) (dependencies (text cl-async)) (dependencies (text blackbird)) (dependencies (text quri)) (dependencies (text fast-http)) (dependencies (text fast-io)) (dependencies (text cl-async-ssl)) (dependencies (text cl-cookie)) (dependencies (text file)))))
		       (match l           ;; <- the input object
         (('asd-record (who (_ val)) ...)  ;; <- the pattern
          who)))          ;; <- the expression evaluated upon matching
<unnamed port>:170:23: Throw to key `match-error' with args `("match" "no matching pattern" (asd-record (license-line (text-until-dq MIT)) (synopsis-line (text-until-dq An async HTTP client)) dependencies (dependencies (text alexandria)) (dependencies (text babel)) (dependencies (text fast-io)) (dependencies (text cl-async)) (dependencies (text blackbird)) (dependencies (text quri)) (dependencies (text fast-http)) (dependencies (text fast-io)) (dependencies (text cl-async-ssl)) (dependencies (text cl-cookie)) (dependencies (text file))))'.

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [9]> (let ((l '(asd-record (license-line (text-until-dq MIT)))))
		       (match l           ;; <- the input object
         (('asd-record (who (_ val)) ...)  ;; <- the pattern
          who)))          ;; <- the expression evaluated upon matching
$5 = (license-line)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Help with match
  2019-05-09 10:04 Help with match swedebugia
@ 2019-05-10 13:53 ` Timothy Sample
  2019-05-10 15:44   ` swedebugia
  0 siblings, 1 reply; 3+ messages in thread
From: Timothy Sample @ 2019-05-10 13:53 UTC (permalink / raw)
  To: swedebugia; +Cc: guix-devel

Hi swedebugia,

swedebugia <swedebugia@riseup.net> writes:

> Hi
>
> I am almost finished with the quicklisp importer but I'm stuck with not
> being able to match what I want with the pattern matcher.
>
> I (still) don't understand the documentation for this matcher and I
> can't get it to do what I want it seems :/

Here’s your input form:

'(asd-record
  (license-line (text-until-dq MIT))
  (synopsis-line (text-until-dq An async HTTP client))
  dependencies
  (dependencies (text alexandria))
  (dependencies (text babel))
  (dependencies (text fast-io))
  (dependencies (text cl-async))
  (dependencies (text blackbird))
  (dependencies (text quri))
  (dependencies (text fast-http))
  (dependencies (text fast-io))
  (dependencies (text cl-async-ssl))
  (dependencies (text cl-cookie))
  (dependencies (text file)))

The pattern you use is “('asd-record (who (_ val)) ...)”.  The reason it
doesn’t match is because not all elements after the symbol “asd-record”
have the form “(who (_ val))” (the failing element is the one that is
just the symbol “dependencies”).  The ellipsis means that all of the
remaining elements have to match the previous pattern.

My guess is that you don’t mean to have that “dependencies” symbol
in the input.

I was just about to send this, but there’s another issue!  The
“synopsis-line” form has five elements, but the pattern “(_ val)” will
only match a two-element list.  Should the “An async HTTP client” part
should be a string?

Hope that helps and good luck with the importer!


-- Tim

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Help with match
  2019-05-10 13:53 ` Timothy Sample
@ 2019-05-10 15:44   ` swedebugia
  0 siblings, 0 replies; 3+ messages in thread
From: swedebugia @ 2019-05-10 15:44 UTC (permalink / raw)
  To: Timothy Sample; +Cc: guix-devel


[-- Attachment #1.1: Type: text/plain, Size: 874 bytes --]

On 2019-05-10 15:53, Timothy Sample wrote:
> My guess is that you don’t mean to have that “dependencies” symbol
> in the input.
> 
> I was just about to send this, but there’s another issue!  The
> “synopsis-line” form has five elements, but the pattern “(_ val)” will
> only match a two-element list.  Should the “An async HTTP client” part
> should be a string?
> 
> Hope that helps and good luck with the importer!

Thanks a lot for looking at this. 🙂

After writing this email I realized I need to change the peg-patterns to
1) output a string for multiple output
2) match the structure metadata-ref procedure in opam.scm so I dont have
to fiddle with the matcher.

The parsing of asd-files has proven to be a big challenge because of the
diversity of the files (tabs, spaces, different prefix, etc.)
-- 
Cheers Swedebugia


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-10 15:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-09 10:04 Help with match swedebugia
2019-05-10 13:53 ` Timothy Sample
2019-05-10 15:44   ` swedebugia

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

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).