From 39bacd45d50bf57aaf0cd79b7ebde184f13706d6 Mon Sep 17 00:00:00 2001 From: Ryan Culpepper Date: Thu, 9 Aug 2018 18:30:32 +0200 Subject: [PATCH] syntax/parse: simplify head pattern compilation The continuation expression for a head pattern evaluates to a procedure that takes the rest of the term and the current progress. --- racket/collects/syntax/parse/private/parse.rkt | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/racket/collects/syntax/parse/private/parse.rkt b/racket/collects/syntax/parse/private/parse.rkt index 4382f4a681..e4437a89b9 100644 --- a/racket/collects/syntax/parse/private/parse.rkt +++ b/racket/collects/syntax/parse/private/parse.rkt @@ -539,11 +539,8 @@ Conventions: (syntax-case stx () [(parse:S x cx pattern0 pr es k) (syntax-case #'pattern0 () - [#s(internal-rest-pattern rest-x rest-cx rest-pr) - #`(let ([rest-x x] - [rest-cx cx] - [rest-pr pr]) - k)] + [#s(internal-rest-pattern) + #`(k x cx pr)] [#s(pat:any) #'k] [#s(pat:svar name) @@ -924,8 +921,8 @@ Conventions: (with-syntax ([pattern (convert-list-pattern #'pattern - #'#s(internal-rest-pattern rest-x rest-cx rest-pr))]) - #'(parse:S x cx pattern pr es k))] + #'#s(internal-rest-pattern))]) + #'(parse:S x cx pattern pr es (lambda (rest-x rest-cx rest-pr) k)))] [#s(hpat:action action subpattern) #'(parse:A x cx action pr es (parse:H x cx rest-x rest-cx rest-pr subpattern pr es k))] [#s(hpat:delimit pattern) @@ -975,8 +972,8 @@ Conventions: [_ #'(parse:S x cx ;; FIXME: consider proper-list-pattern? (yes is consistent with ~seq) - #s(pat:pair head #s(internal-rest-pattern rest-x rest-cx rest-pr)) - pr es k)])])) + #s(pat:pair head #s(internal-rest-pattern)) + pr es (lambda (rest-x rest-cx rest-pr) k))])])) ;; (parse:dots x cx EH-pattern S-pattern pr es k) : expr[Ans] ;; In k: attrs(EH-pattern, S-pattern) are bound.