Skip to content
Snippets Groups Projects
Commit d8b6fcde authored by Federico Beffa's avatar Federico Beffa
Browse files

import: cabal: Make token recognition case-insensitive.

* guix/import/cabal.scm (make-rx-matcher): Add optional parameter FLAG.
  (is-property, is-flag, is-src-repo, is-exec, is-test-suite, is-benchmark,
  is-lib, is-else, is-if): Make test case-insensitive.
parent 85ef742c
No related branches found
No related tags found
No related merge requests found
...@@ -317,29 +317,38 @@ (define (get-offside port) ...@@ -317,29 +317,38 @@ (define (get-offside port)
(define (is-relation? c) (define (is-relation? c)
(and (char? c) (any (cut char=? c <>) '(#\< #\> #\=)))) (and (char? c) (any (cut char=? c <>) '(#\< #\> #\=))))
(define (make-rx-matcher pat) (define* (make-rx-matcher pat #:optional (flag #f))
"Compile PAT into a regular expression and creates a function matching a "Compile PAT into a regular expression with FLAG and creates a function
string against the created regexp." matching a string against the created regexp."
(let ((rx (make-regexp pat))) (cut regexp-exec rx <>))) (let ((rx (if flag
(make-regexp pat flag)
(make-regexp pat))))
(cut regexp-exec rx <>)))
(define is-property (make-rx-matcher "([a-zA-Z0-9-]+):[ \t]*(\\w?.*)$")) (define is-property (make-rx-matcher "([a-z0-9-]+):[ \t]*(\\w?.*)$"
regexp/icase))
(define is-flag (make-rx-matcher "^[Ff]lag +([a-zA-Z0-9_-]+)")) (define is-flag (make-rx-matcher "^flag +([a-z0-9_-]+)"
regexp/icase))
(define is-src-repo (define is-src-repo
(make-rx-matcher "^[Ss]ource-[Rr]epository +([a-zA-Z0-9_-]+)")) (make-rx-matcher "^source-repository +([a-z0-9_-]+)"
regexp/icase))
(define is-exec (make-rx-matcher "^[Ee]xecutable +([a-zA-Z0-9_-]+)")) (define is-exec (make-rx-matcher "^executable +([a-z0-9_-]+)"
regexp/icase))
(define is-test-suite (make-rx-matcher "^[Tt]est-[Ss]uite +([a-zA-Z0-9_-]+)")) (define is-test-suite (make-rx-matcher "^test-suite +([a-z0-9_-]+)"
regexp/icase))
(define is-benchmark (make-rx-matcher "^[Bb]enchmark +([a-zA-Z0-9_-]+)")) (define is-benchmark (make-rx-matcher "^benchmark +([a-z0-9_-]+)"
regexp/icase))
(define is-lib (make-rx-matcher "^[Ll]ibrary *")) (define is-lib (make-rx-matcher "^library *" regexp/icase))
(define is-else (make-rx-matcher "^else")) (define is-else (make-rx-matcher "^else" regexp/icase))
(define (is-if s) (string=? s "if")) (define (is-if s) (string-ci=? s "if"))
(define (is-and s) (string=? s "&&")) (define (is-and s) (string=? s "&&"))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment