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"
|
<once-clause-identifier> ::= "once"
|
||||||
| "file-once"
|
| "file-once"
|
||||||
|
|
||||||
<common-file-clause> ::= '(' + <common-fille-clause-identifier>
|
<common-file-clause> ::= '(' + <common-file-clause-identifier>
|
||||||
+ <target-spec>
|
+ <common-target-spec>
|
||||||
+ <prereq-spec>
|
+ <common-prereq-spec>
|
||||||
+ <action>+ + ')'
|
+ <action>+ + ')'
|
||||||
|
|
||||||
<common-all-clause> ::= '(' + <common-all-clause-identifier>
|
<common-all-clause> ::= '(' + <common-all-clause-identifier>
|
||||||
+ <target-spec>
|
+ <common-target-spec>
|
||||||
+ <prereq-spec>
|
+ <common-prereq-spec>
|
||||||
+ <action>+ + ')'
|
+ <action>+ + ')'
|
||||||
|
|
||||||
<common-md5-clause> ::= '(' + <common-md5-clause-identifier>
|
<common-md5-clause> ::= '(' + <common-md5-clause-identifier>
|
||||||
+ <target-spec>
|
+ <common-target-spec>
|
||||||
+ <prereq-spec>
|
+ <common-prereq-spec>
|
||||||
+ <action-spec> + ')'
|
+ <action-spec> + ')'
|
||||||
|
|
||||||
<common-always-clause> ::= '(' + <common-always-clause-identifier>
|
<common-always-clause> ::= '(' + <common-always-clause-identifier>
|
||||||
+ <target-spec>
|
+ <common-target-spec>
|
||||||
+ <prereq-spec>
|
+ <common-prereq-spec>
|
||||||
+ <action-spec> + ')'
|
+ <action-spec> + ')'
|
||||||
|
|
||||||
<common-once-clause> ::= '(' + <common-once-clause-identifier>
|
<common-once-clause> ::= '(' + <common-once-clause-identifier>
|
||||||
+ <target-spec>
|
+ <common-target-spec>
|
||||||
+ <prereq-spec>
|
+ <common-prereq-spec>
|
||||||
+ <action-spec> + ')'
|
+ <action-spec> + ')'
|
||||||
|
|
||||||
<common-file-clause-identifier> ::= "common-file"
|
<common-file-clause-identifier> ::= "common-file"
|
||||||
|
@ -102,13 +102,25 @@ MAKEFILE:
|
||||||
<common-once-clause-identifier> ::= "common-once"
|
<common-once-clause-identifier> ::= "common-once"
|
||||||
| "common-file-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-spec> ::= <target> | <target-list>
|
||||||
<target> ::= <filename>
|
<target> ::= <filename>
|
||||||
<target-list> ::= '(' + <filename>+ + ')'
|
<target-list> ::= '(' + <filename>+ + ')'
|
||||||
|
|
||||||
<prereq-spec> ::= <prereq> | <prereq-list>
|
<prereq-spec> ::= <prereq-list>
|
||||||
<prereq> ::= <filename>
|
<prereq> ::= <filename>
|
||||||
<prereq-list> ::= '(' + <filename>* + ')'
|
<prereq-list> ::= '(' + <prereq>* + ')'
|
||||||
|
|
||||||
<action> ::= <function-call> | <value>
|
<action> ::= <function-call> | <value>
|
||||||
|
|
||||||
|
|
|
@ -42,12 +42,20 @@
|
||||||
(suffix (list-ref maybe-target 2))
|
(suffix (list-ref maybe-target 2))
|
||||||
(target-name (string-append prefix match suffix))
|
(target-name (string-append prefix match suffix))
|
||||||
(cooked-prereqs (map (lambda (prereq)
|
(cooked-prereqs (map (lambda (prereq)
|
||||||
(replace-by-match prereq match))
|
(if (string? prereq)
|
||||||
|
(replace-by-match prereq match)
|
||||||
|
prereq))
|
||||||
(common-rule-prereqs current)))
|
(common-rule-prereqs current)))
|
||||||
(make-wants-build? (common-rule-wants-build? current))
|
(make-wants-build? (common-rule-wants-build? current))
|
||||||
(wants-build? (apply make-wants-build?
|
(wants-build?
|
||||||
(append (list target-name)
|
(lambda args
|
||||||
cooked-prereqs)))
|
(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))
|
(make-build-func (common-rule-build-func current))
|
||||||
(build-func
|
(build-func
|
||||||
(lambda args
|
(lambda args
|
||||||
|
@ -84,30 +92,40 @@
|
||||||
;;; (is-matched-by? "%.tex" "bar.o") ---> #f
|
;;; (is-matched-by? "%.tex" "bar.o") ---> #f
|
||||||
;;;
|
;;;
|
||||||
(define (is-matched-by? target-descr target-name)
|
(define (is-matched-by? target-descr target-name)
|
||||||
(let* ((submatches (map (lambda (match-no)
|
(let ((submatches (if (string? target-descr)
|
||||||
(match:substring
|
(get-submatches-percent target-descr)
|
||||||
(regexp-search (rx (: (submatch (* any))
|
#f)))
|
||||||
(submatch "%")
|
(if submatches
|
||||||
(submatch (* any))))
|
(let* ((left (list-ref submatches 0))
|
||||||
target-descr)
|
(middle (list-ref submatches 1))
|
||||||
match-no))
|
(right (list-ref submatches 2))
|
||||||
(list 1 2 3)))
|
(constructed-rx (if (and (string? middle) (string=? "%" middle))
|
||||||
(left (list-ref submatches 0))
|
(rx (: (submatch ,left)
|
||||||
(middle (list-ref submatches 1))
|
(submatch (* any))
|
||||||
(right (list-ref submatches 2))
|
(submatch ,right)))
|
||||||
(constructed-rx (if (string=? "%" middle)
|
(rx (: (submatch ,left)
|
||||||
(rx (: (submatch ,left)
|
(submatch ,middle)
|
||||||
(submatch (* any))
|
(submatch ,right)))))
|
||||||
(submatch ,right)))
|
(maybe-match (regexp-search constructed-rx target-name)))
|
||||||
(rx (: (submatch ,left)
|
(if maybe-match
|
||||||
(submatch ,middle)
|
(map (lambda (match-no)
|
||||||
(submatch ,right)))))
|
(match:substring maybe-match match-no))
|
||||||
(maybe-match (regexp-search constructed-rx target-name)))
|
(list 1 2 3))
|
||||||
(if maybe-match
|
#f))
|
||||||
(map (lambda (match-no)
|
(let ((maybe-match (regexp-search target-descr target-name)))
|
||||||
(match:substring maybe-match match-no))
|
(if maybe-match
|
||||||
(list 1 2 3))
|
(map (lambda (match-no) (match:substring maybe-match match-no))
|
||||||
#f)))
|
(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
|
;;; returns the string where the match is replaced with replacement
|
||||||
|
|
Loading…
Reference in New Issue