support for rx with three submatches in common rules.
This commit is contained in:
parent
9a25d38343
commit
68a122a2a5
38
SYNTAX
38
SYNTAX
|
@ -59,29 +59,29 @@ MAKEFILE:
|
|||
<once-clause-identifier> ::= "once"
|
||||
| "file-once"
|
||||
|
||||
<common-file-clause> ::= '(' + <common-fille-clause-identifier>
|
||||
+ <target-spec>
|
||||
+ <prereq-spec>
|
||||
<common-file-clause> ::= '(' + <common-file-clause-identifier>
|
||||
+ <common-target-spec>
|
||||
+ <common-prereq-spec>
|
||||
+ <action>+ + ')'
|
||||
|
||||
<common-all-clause> ::= '(' + <common-all-clause-identifier>
|
||||
+ <target-spec>
|
||||
+ <prereq-spec>
|
||||
+ <common-target-spec>
|
||||
+ <common-prereq-spec>
|
||||
+ <action>+ + ')'
|
||||
|
||||
<common-md5-clause> ::= '(' + <common-md5-clause-identifier>
|
||||
+ <target-spec>
|
||||
+ <prereq-spec>
|
||||
+ <common-target-spec>
|
||||
+ <common-prereq-spec>
|
||||
+ <action-spec> + ')'
|
||||
|
||||
<common-always-clause> ::= '(' + <common-always-clause-identifier>
|
||||
+ <target-spec>
|
||||
+ <prereq-spec>
|
||||
+ <common-target-spec>
|
||||
+ <common-prereq-spec>
|
||||
+ <action-spec> + ')'
|
||||
|
||||
<common-once-clause> ::= '(' + <common-once-clause-identifier>
|
||||
+ <target-spec>
|
||||
+ <prereq-spec>
|
||||
+ <common-target-spec>
|
||||
+ <common-prereq-spec>
|
||||
+ <action-spec> + ')'
|
||||
|
||||
<common-file-clause-identifier> ::= "common-file"
|
||||
|
@ -102,13 +102,25 @@ MAKEFILE:
|
|||
<common-once-clause-identifier> ::= "common-once"
|
||||
| "common-file-once"
|
||||
|
||||
<common-target-spec> ::= <target-descr> | <target> | <target-list>
|
||||
<target-descr> ::= <target-pattern> | <target-rx>
|
||||
<target-pattern> ::= '"' + <prefix> + '%' + <suffix> + '"'
|
||||
<prefix> ::= <letter-or-digit>*
|
||||
<suffix> ::= <letter-or-digit>*
|
||||
<target-rx> ::= '(' + "rx" + '(' + <submatch-connector>
|
||||
+ <submatch-clause>{3} + ')' + ')'
|
||||
|
||||
<common-prereq-spec> ::= <prereq-descr>
|
||||
<prereq-pattern> ::= '"' + <prefix> + '%' + <suffix> + '"'
|
||||
<prereq-descr> ::= '(' + { <prereq-pattern> | <prereq> }* + ')'
|
||||
|
||||
<target-spec> ::= <target> | <target-list>
|
||||
<target> ::= <filename>
|
||||
<target-list> ::= '(' + <filename>+ + ')'
|
||||
|
||||
<prereq-spec> ::= <prereq> | <prereq-list>
|
||||
<prereq-spec> ::= <prereq-list>
|
||||
<prereq> ::= <filename>
|
||||
<prereq-list> ::= '(' + <filename>* + ')'
|
||||
<prereq-list> ::= '(' + <prereq>* + ')'
|
||||
|
||||
<action> ::= <function-call> | <value>
|
||||
|
||||
|
|
|
@ -42,12 +42,20 @@
|
|||
(suffix (list-ref maybe-target 2))
|
||||
(target-name (string-append prefix match suffix))
|
||||
(cooked-prereqs (map (lambda (prereq)
|
||||
(replace-by-match prereq match))
|
||||
(if (string? prereq)
|
||||
(replace-by-match prereq match)
|
||||
prereq))
|
||||
(common-rule-prereqs current)))
|
||||
(make-wants-build? (common-rule-wants-build? current))
|
||||
(wants-build? (apply make-wants-build?
|
||||
(append (list target-name)
|
||||
cooked-prereqs)))
|
||||
(wants-build?
|
||||
(lambda args
|
||||
(bind-fluids-common target-name prefix match suffix
|
||||
(lambda ()
|
||||
(apply
|
||||
(apply make-wants-build?
|
||||
(append (list target-name)
|
||||
cooked-prereqs))
|
||||
args)))))
|
||||
(make-build-func (common-rule-build-func current))
|
||||
(build-func
|
||||
(lambda args
|
||||
|
@ -84,30 +92,40 @@
|
|||
;;; (is-matched-by? "%.tex" "bar.o") ---> #f
|
||||
;;;
|
||||
(define (is-matched-by? target-descr target-name)
|
||||
(let* ((submatches (map (lambda (match-no)
|
||||
(match:substring
|
||||
(regexp-search (rx (: (submatch (* any))
|
||||
(submatch "%")
|
||||
(submatch (* any))))
|
||||
target-descr)
|
||||
match-no))
|
||||
(list 1 2 3)))
|
||||
(left (list-ref submatches 0))
|
||||
(middle (list-ref submatches 1))
|
||||
(right (list-ref submatches 2))
|
||||
(constructed-rx (if (string=? "%" middle)
|
||||
(rx (: (submatch ,left)
|
||||
(submatch (* any))
|
||||
(submatch ,right)))
|
||||
(rx (: (submatch ,left)
|
||||
(submatch ,middle)
|
||||
(submatch ,right)))))
|
||||
(maybe-match (regexp-search constructed-rx target-name)))
|
||||
(if maybe-match
|
||||
(map (lambda (match-no)
|
||||
(match:substring maybe-match match-no))
|
||||
(list 1 2 3))
|
||||
#f)))
|
||||
(let ((submatches (if (string? target-descr)
|
||||
(get-submatches-percent target-descr)
|
||||
#f)))
|
||||
(if submatches
|
||||
(let* ((left (list-ref submatches 0))
|
||||
(middle (list-ref submatches 1))
|
||||
(right (list-ref submatches 2))
|
||||
(constructed-rx (if (and (string? middle) (string=? "%" middle))
|
||||
(rx (: (submatch ,left)
|
||||
(submatch (* any))
|
||||
(submatch ,right)))
|
||||
(rx (: (submatch ,left)
|
||||
(submatch ,middle)
|
||||
(submatch ,right)))))
|
||||
(maybe-match (regexp-search constructed-rx target-name)))
|
||||
(if maybe-match
|
||||
(map (lambda (match-no)
|
||||
(match:substring maybe-match match-no))
|
||||
(list 1 2 3))
|
||||
#f))
|
||||
(let ((maybe-match (regexp-search target-descr target-name)))
|
||||
(if maybe-match
|
||||
(map (lambda (match-no) (match:substring maybe-match match-no))
|
||||
(list 1 2 3))
|
||||
#f)))))
|
||||
|
||||
(define (get-submatches-percent target-descr)
|
||||
(map (lambda (match-no)
|
||||
(match:substring (regexp-search (rx (: (submatch (* any))
|
||||
(submatch "%")
|
||||
(submatch (* any))))
|
||||
target-descr)
|
||||
match-no))
|
||||
(list 1 2 3)))
|
||||
|
||||
;;;
|
||||
;;; returns the string where the match is replaced with replacement
|
||||
|
|
Loading…
Reference in New Issue