guix-commits
[Top][All Lists]
Advanced

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

04/08: import: cabal: Allow curly bracket before else statement.


From: guix-commits
Subject: 04/08: import: cabal: Allow curly bracket before else statement.
Date: Mon, 6 Jun 2022 07:29:26 -0400 (EDT)

lbraun pushed a commit to branch master
in repository guix.

commit e3337f35afa83e746f0a66451fd4d2212c032b03
Author: Lars-Dominik Braun <lars@6xq.net>
AuthorDate: Sun May 1 08:34:42 2022 +0200

    import: cabal: Allow curly bracket before else statement.
    
    * guix/import/cabal.scm (is-else): Turn into procedure.
    (lex-line): Move IS-ELSE…
    (lex-word): …here.
    * tests/hackage.scm (test-cabal-elif-brackets): Extend testcase.
---
 guix/import/cabal.scm | 4 ++--
 tests/hackage.scm     | 5 ++++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/guix/import/cabal.scm b/guix/import/cabal.scm
index 9f3862fa14..8f59a63cb9 100644
--- a/guix/import/cabal.scm
+++ b/guix/import/cabal.scm
@@ -384,7 +384,7 @@ matching a string against the created regexp."
 
 (define is-lib (make-rx-matcher "^library *" regexp/icase))
 
-(define is-else (make-rx-matcher "^else" regexp/icase))
+(define (is-else s) (string-ci=? s "else"))
 
 (define (is-elif s) (string-ci=? s "elif"))
 
@@ -576,6 +576,7 @@ LOC is the current port location."
   (let* ((w (read-delimited " <>=():\t\n" port 'peek)))
     (cond ((is-if w) (lex-if loc))
           ((is-elif w) (lex-elif loc))
+          ((is-else w) (lex-else loc))
           ((is-test w port) (lex-test w loc))
           ((is-true w) (lex-true loc))
           ((is-false w) (lex-false loc))
@@ -599,7 +600,6 @@ the current port location."
      ((is-custom-setup s) => (cut lex-custom-setup <> loc))
      ((is-benchmark s) => (cut lex-benchmark <> loc))
      ((is-lib s) (lex-lib loc))
-     ((is-else s) (lex-else loc))
      (else (unread-string s port) #f))))
 
 (define (lex-property port loc)
diff --git a/tests/hackage.scm b/tests/hackage.scm
index 4ce48b6baf..98f9c34fd2 100644
--- a/tests/hackage.scm
+++ b/tests/hackage.scm
@@ -398,7 +398,10 @@ library
   elif os(guix) { Build-depends: ghc-c }
   elif os(third) {
     Build-depends: ghc-d }
-  else
+  elif os(fourth)
+  {
+    Build-depends: ghc-d
+  } else
     Build-depends: ghc-e
 ")
 



reply via email to

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