From c390d9678072cbd5a4ff46dfff7aa736216a1ea5 Mon Sep 17 00:00:00 2001 From: Jon Rafkind Date: Thu, 12 Apr 2012 12:48:59 -0600 Subject: [PATCH] [honu] only allow semicolons in expression sequence position --- collects/honu/core/private/honu-typed-scheme.rkt | 7 +++++++ collects/honu/core/private/parse2.rkt | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/collects/honu/core/private/honu-typed-scheme.rkt b/collects/honu/core/private/honu-typed-scheme.rkt index 4c4e9db509..edd082899a 100644 --- a/collects/honu/core/private/honu-typed-scheme.rkt +++ b/collects/honu/core/private/honu-typed-scheme.rkt @@ -472,9 +472,16 @@ Then, in the pattern above for 'if', 'then' would be bound to the following synt (debug "expanded ~a unexpanded ~a\n" (if parsed (syntax->datum parsed) parsed) (syntax->datum unparsed)) + #'(begin + (define-syntax (parse-more stx) + (syntax-case stx () + [(_ stuff (... ...)) + (do-parse-rest #'(stuff (... ...)) #'parse-more)])) + (parse-more forms ...)) ;; if parsed is #f then we don't want to expand to anything that will print ;; so use an empty form, begin, `parsed' could be #f becuase there was no expression ;; in the input such as parsing just ";". + #; (with-syntax ([parsed (if (not parsed) #'(begin) (remove-repeats parsed) #; diff --git a/collects/honu/core/private/parse2.rkt b/collects/honu/core/private/parse2.rkt index a1cb598477..53ee99c947 100644 --- a/collects/honu/core/private/parse2.rkt +++ b/collects/honu/core/private/parse2.rkt @@ -143,7 +143,9 @@ (provide do-parse-rest) (define (do-parse-rest stx parse-more) - (syntax-parse stx + (syntax-parse stx #:literal-sets (cruft) + [(semicolon semicolon ... rest ...) + (do-parse-rest #'(rest ...) parse-more)] [(stuff ...) (debug "Parse rest ~a\n" (syntax->datum #'(stuff ...))) (define-values (parsed unparsed) @@ -431,6 +433,7 @@ (define-splicing-syntax-class no-left [pattern (~seq) #:when (and (= precedence 0) (not current))]) (syntax-parse #'(head rest ...) #:literal-sets (cruft) + #; [(semicolon . rest) (debug "Parsed a semicolon, finishing up with ~a\n" current) (values (left current) #'rest)]