From 8280c77142467d28cafcf2f79dfdb64861f01632 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 25 Apr 2021 10:56:53 -0700 Subject: matcher: use @(as) capture. * share/txr/stdlib/match.tl (expand-quasi-match): Instead of accessing args with car and cadr, capture that part in the match using @(as) and refer to the variable. --- share/txr/stdlib/match.tl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/share/txr/stdlib/match.tl b/share/txr/stdlib/match.tl index 80750e6c..2cca5322 100644 --- a/share/txr/stdlib/match.tl +++ b/share/txr/stdlib/match.tl @@ -860,9 +860,10 @@ (list ^@(require @nil (str= (sys:quasi ,(car args)) (sub-str ,str ,pos t))))) ;; `@var@...` (existing binding) - (((@(eq 'sys:var) @(bound-p vlist vars @sym) . @nil) . @rest) + ((@(as avar (@(eq 'sys:var) @(bound-p vlist vars @sym) . @nil)) + . @rest) (with-gensyms (txt len npos) - (list* ^@(with ,txt (sys:quasi ,(car args))) + (list* ^@(with ,txt (sys:quasi ,avar)) ^@(with ,len (len ,txt)) ^@(with ,npos (+ ,pos ,len)) ^@(require @nil @@ -920,10 +921,10 @@ (quasi-match vlist rest (cons sym vars) str npos)))) ;; `@var0@var1` (unbound followed by bound) (((@(eq 'sys:var) @sym) - (@(eq 'sys:var) @(bound-p vlist vars @bsym) . @mods) + @(as bvar (@(eq 'sys:var) @(bound-p vlist vars @bsym) . @mods)) . @rest) (with-gensyms (txt end npos) - (list* ^@(with ,txt (sys:quasi ,(cadr args))) + (list* ^@(with ,txt (sys:quasi ,bvar)) ^@(require @(with ,end (search-str ,str ,txt ,pos)) ,end) ^@(with ,npos (+ ,end (len ,txt))) -- cgit v1.2.3