From a328126da4db89b736b0db2121bc0c3bd67b90c8 Mon Sep 17 00:00:00 2001 From: Sam Tobin-Hochstadt Date: Sat, 3 Sep 2011 18:11:10 -0400 Subject: [PATCH] Split syntax-classes out into separate file to reduce requires. original commit: 77b619b7c2c4c4ef89f7830949ab90bdda07f5a2 --- .../typed-scheme/private/parse-classes.rkt | 26 +++++++++++++++++++ collects/typed-scheme/private/parse-type.rkt | 23 +--------------- 2 files changed, 27 insertions(+), 22 deletions(-) create mode 100644 collects/typed-scheme/private/parse-classes.rkt diff --git a/collects/typed-scheme/private/parse-classes.rkt b/collects/typed-scheme/private/parse-classes.rkt new file mode 100644 index 00000000..6e6b6db1 --- /dev/null +++ b/collects/typed-scheme/private/parse-classes.rkt @@ -0,0 +1,26 @@ +#lang racket/base + +(require syntax/parse) +(provide star ddd ddd/bound) + +(define-syntax-class star + #:description "*" + (pattern star:id + #:fail-unless (eq? '* (syntax-e #'star)) "missing *") + (pattern star:id + #:fail-unless (eq? '...* (syntax-e #'star)) "missing ...*")) + +(define-syntax-class ddd + #:description "..." + (pattern ddd:id + #:fail-unless (eq? '... (syntax-e #'ddd)) "missing ...")) + +(define-splicing-syntax-class ddd/bound + #:description "... followed by variable name" + #:attributes (bound) + (pattern i:id + #:attr s (symbol->string (syntax-e #'i)) + #:fail-unless ((string-length (attribute s)) . > . 3) #f + #:fail-unless (equal? "..." (substring (attribute s) 0 3)) "missing ..." + #:attr bound (datum->syntax #'i (string->symbol (substring (attribute s) 3)) #'i #'i)) + (pattern (~seq _:ddd bound:id))) diff --git a/collects/typed-scheme/private/parse-type.rkt b/collects/typed-scheme/private/parse-type.rkt index 1c07f6b8..45046205 100644 --- a/collects/typed-scheme/private/parse-type.rkt +++ b/collects/typed-scheme/private/parse-type.rkt @@ -8,6 +8,7 @@ syntax/parse (env type-env-structs tvar-env type-name-env type-alias-env lexical-env index-env) racket/match + "parse-classes.rkt" (for-template scheme/base "../base-env/colon.rkt") ;; needed at this phase for tests (combine-in (prefix-in t: "../base-env/base-types-extra.rkt") "../base-env/colon.rkt") @@ -30,28 +31,6 @@ (p stx*))) -(define-syntax-class star - #:description "*" - (pattern star:id - #:fail-unless (eq? '* (syntax-e #'star)) "missing *") - (pattern star:id - #:fail-unless (eq? '...* (syntax-e #'star)) "missing ...*")) - -(define-syntax-class ddd - #:description "..." - (pattern ddd:id - #:fail-unless (eq? '... (syntax-e #'ddd)) "missing ...")) - -(define-splicing-syntax-class ddd/bound - #:description "... followed by variable name" - #:attributes (bound) - (pattern i:id - #:attr s (symbol->string (syntax-e #'i)) - #:fail-unless ((string-length (attribute s)) . > . 3) #f - #:fail-unless (equal? "..." (substring (attribute s) 0 3)) "missing ..." - #:attr bound (datum->syntax #'i (string->symbol (substring (attribute s) 3)) #'i #'i)) - (pattern (~seq _:ddd bound:id))) - (define (parse-all-body s) (syntax-parse s [(ty)