From e3337f35afa83e746f0a66451fd4d2212c032b03 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sun, 1 May 2022 08:34:42 +0200 Subject: import: cabal: Allow curly bracket before else statement. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guix/import') 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) -- cgit v1.2.3