unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Julien Lepiller <julien@lepiller.eu>
To: 35150@debbugs.gnu.org
Subject: [bug#35150] [PATCH 1/9] import: opam: Add more patterns to opam file parser.
Date: Thu,  4 Apr 2019 21:16:30 +0200	[thread overview]
Message-ID: <20190404191638.31953-1-julien@lepiller.eu> (raw)
In-Reply-To: <20190404205437.5fe1bd60@lepiller.eu>

* guix/import/opam.scm: Add more patterns to peg parser.
---
 guix/import/opam.scm | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/guix/import/opam.scm b/guix/import/opam.scm
index 36028a01d6..b5069cd2f3 100644
--- a/guix/import/opam.scm
+++ b/guix/import/opam.scm
@@ -58,7 +58,12 @@
 (define-peg-pattern weird-record all (and key (* SP) dict))
 (define-peg-pattern key body (+ (or (range #\a #\z) "-")))
 (define-peg-pattern value body (and (or conditional-value ground-value operator) (* SP)))
-(define-peg-pattern ground-value body (and (or multiline-string string-pat list-pat var) (* SP)))
+(define-peg-pattern choice-pat all (and (ignore "(") (* SP) choice (* SP)  (ignore ")")))
+(define-peg-pattern choice body
+  (or (and (or conditional-value ground-value) (* SP) (ignore "|") (* SP) choice)
+      conditional-value
+      ground-value))
+(define-peg-pattern ground-value body (and (or multiline-string string-pat choice-pat list-pat var) (* SP)))
 (define-peg-pattern conditional-value all (and ground-value (* SP) condition))
 (define-peg-pattern string-pat all (and QUOTE (* STRCHR) QUOTE))
 (define-peg-pattern list-pat all (and (ignore "[") (* SP) (* (and value (* SP))) (ignore "]")))
@@ -80,7 +85,8 @@
 (define-peg-pattern condition-form2 body
                     (and (* SP) (or condition-greater-or-equal condition-greater
                                     condition-lower-or-equal condition-lower
-                                    condition-neq condition-eq condition-content) (* SP)))
+                                    condition-neq condition-eq condition-not
+                                    condition-content) (* SP)))
 
 ;(define-peg-pattern condition-operator all (and (ignore operator) (* SP) condition-string))
 (define-peg-pattern condition-greater-or-equal all (and (ignore (and ">" "=")) (* SP) condition-string))
@@ -91,10 +97,12 @@
 (define-peg-pattern condition-or all (and condition-form2 (* SP) (ignore "|") (* SP) condition-form))
 (define-peg-pattern condition-eq all (and (? condition-content) (* SP) (ignore "=") (* SP) condition-content))
 (define-peg-pattern condition-neq all (and (? condition-content) (* SP) (ignore (and "!" "=")) (* SP) condition-content))
-(define-peg-pattern condition-content body (or condition-string condition-var))
+(define-peg-pattern condition-not all (and (ignore (and "!")) (* SP) condition-content))
+(define-peg-pattern condition-content body (or condition-paren condition-string condition-var))
 (define-peg-pattern condition-content2 body (and condition-content (* SP) (not-followed-by (or "&" "=" "!"))))
+(define-peg-pattern condition-paren body (and "(" condition-form ")"))
 (define-peg-pattern condition-string all (and QUOTE (* STRCHR) QUOTE))
-(define-peg-pattern condition-var all (+ (or (range #\a #\z) "-")))
+(define-peg-pattern condition-var all (+ (or (range #\a #\z) "-" ":")))
 
 (define (get-opam-repository)
   "Update or fetch the latest version of the opam repository and return the
@@ -171,18 +179,24 @@ path to the repository."
 (define (dependency->input dependency)
   (match dependency
     (('string-pat str) str)
+    ;; Arbitrary select the first dependency
+    (('choice-pat choice ...) (dependency->input (car choice)))
     (('conditional-value val condition)
      (if (native? condition) "" (dependency->input val)))))
 
 (define (dependency->native-input dependency)
   (match dependency
     (('string-pat str) "")
+    ;; Arbitrary select the first dependency
+    (('choice-pat choice ...) (dependency->input (car choice)))
     (('conditional-value val condition)
      (if (native? condition) (dependency->input val) ""))))
 
 (define (dependency->name dependency)
   (match dependency
     (('string-pat str) str)
+    ;; Arbitrary select the first dependency
+    (('choice-pat choice ...) (dependency->input (car choice)))
     (('conditional-value val condition)
      (dependency->name val))))
 
-- 
2.21.0

  reply	other threads:[~2019-04-04 19:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-04 18:54 [bug#35150] [PATCH] Unbundle opam dependencies Julien Lepiller
2019-04-04 19:16 ` Julien Lepiller [this message]
2019-04-04 19:16   ` [bug#35150] [PATCH 2/9] import: opam: Use dune-build-system when possible Julien Lepiller
2019-04-04 19:16   ` [bug#35150] [PATCH 3/9] gnu: Add ocaml-opam-file-format Julien Lepiller
2019-04-04 19:16   ` [bug#35150] [PATCH 4/9] gnu: ocaml-cmdliner: Update to 1.0.3 Julien Lepiller
2019-04-04 19:16   ` [bug#35150] [PATCH 5/9] gnu: Add ocaml-extlib Julien Lepiller
2019-04-04 19:16   ` [bug#35150] [PATCH 6/9] gnu: Add ocaml-cudf Julien Lepiller
2019-04-04 19:16   ` [bug#35150] [PATCH 7/9] gnu: Add ocaml-mccs Julien Lepiller
2019-04-04 19:16   ` [bug#35150] [PATCH 8/9] gnu: Add ocaml-dose3 Julien Lepiller
2019-04-04 19:16   ` [bug#35150] [PATCH 9/9] gnu: opam: Unbundle dependencies Julien Lepiller
2019-04-10 15:08   ` [bug#35150] [PATCH 1/9] import: opam: Add more patterns to opam file parser Ludovic Courtès
2019-04-10 15:09 ` [bug#35150] [PATCH] Unbundle opam dependencies Ludovic Courtès
2019-04-10 19:48   ` bug#35150: " Julien Lepiller

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://guix.gnu.org/

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

  git send-email \
    --in-reply-to=20190404191638.31953-1-julien@lepiller.eu \
    --to=julien@lepiller.eu \
    --cc=35150@debbugs.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.
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).