pattern: Do not use record matching.
Mes does not support it, and also the code is cleaner without it! * gash/pattern.scm (pattern-match?, pattern-drop) (pattern-drop-right): Avoid record matching.
This commit is contained in:
parent
10ee7d286e
commit
7fb21c1549
|
@ -249,7 +249,7 @@ source string is the only string that will match it."
|
|||
(let ((start* (+ m (vector-length part))))
|
||||
(parts-match? rest start*)))))))
|
||||
|
||||
(match-let ((($ <pattern> parts) pattern))
|
||||
(let ((parts (pattern-parts pattern)))
|
||||
(if (and explicit-initial-period?
|
||||
(< start end)
|
||||
(char=? (string-ref str start) #\.))
|
||||
|
@ -276,13 +276,12 @@ source string is the only string that will match it."
|
|||
(#f str)
|
||||
(m (match-parts rest (+ m (vector-length part))))))))
|
||||
|
||||
(match-let ((($ <pattern> parts) pattern))
|
||||
(match parts
|
||||
(() str)
|
||||
((part . rest)
|
||||
(if (string-starts-with-part str part)
|
||||
(match-parts rest (vector-length part))
|
||||
str)))))
|
||||
(match (pattern-parts pattern)
|
||||
(() str)
|
||||
((part . rest)
|
||||
(if (string-starts-with-part str part)
|
||||
(match-parts rest (vector-length part))
|
||||
str))))
|
||||
|
||||
(define* (pattern-drop-right pattern str #:key greedy?)
|
||||
(define (match-parts parts i)
|
||||
|
@ -295,12 +294,11 @@ source string is the only string that will match it."
|
|||
(#f str)
|
||||
(m (match-parts rest m))))))
|
||||
|
||||
(match-let ((($ <pattern> parts) pattern))
|
||||
(let ((strap (reverse parts)))
|
||||
(match strap
|
||||
(() str)
|
||||
((part . rest)
|
||||
(if (string-ends-with-part str part)
|
||||
(let ((i (- (string-length str) (vector-length part))))
|
||||
(match-parts rest i))
|
||||
str))))))
|
||||
(let ((strap (reverse (pattern-parts pattern))))
|
||||
(match strap
|
||||
(() str)
|
||||
((part . rest)
|
||||
(if (string-ends-with-part str part)
|
||||
(let ((i (- (string-length str) (vector-length part))))
|
||||
(match-parts rest i))
|
||||
str)))))
|
||||
|
|
Loading…
Reference in New Issue