Hello,

This is version 6.5.0.5.

(define-syntax (define-tokens stx)
  (syntax-case stx []
    [(_ token
        #:+ Token (extra ...)
        #:with [[subtoken #:+ SubToken subrest ...] ...]
        [id #:+ ID #:-> parent #:as Type rest ...] ...)
     (with-syntax ([token->datum (format-id #'token "~a->datum" (syntax-e
#'token))]
                   [([id? id-datum] ...) (for/list ([<id> (in-list
(syntax->list #'(id ...)))])
                                           (list (format-id <id> "~a?"
(syntax-e <id>))
                                                 (format-id <id> "~a-datum"
(syntax-e <id>))))])
       #'(begin (struct: token : Token ([source : Any] [line : Natural]
[column : Natural]
                                                       [position : Natural]
[span : Natural] extra ...))
                (struct: subtoken : SubToken subrest ...) ...
                (define-token id #:+ ID #:-> parent #:as Type rest ...) ...

                (define token->datum : (-> Token Datum)
                  (lambda [instance]
                    (cond [(id? instance) (id-datum instance)] ...
                          [else (assert (object-name instance)
symbol?)])))))]))

The following code is okay, however, if more definitions are added, then
the typechecking will refuse to terminate itself.

(define-tokens css-token
  #:+ CSS-Token ()
  #:with [[css:numeric #:+ CSS:Numeric css-token ([representation :
String])]
          [css:number #:+ CSS:Number css:numeric ()]]
  [css:bad  #:+ CSS:Bad #:-> css-token #:as Datum]
  [css:close #:+ CSS:Close #:-> css-token #:as Char]
  [css:cd #:+ CSS:CD #:-> css-token #:as Symbol]
  [css:match #:+ CSS:Match #:-> css-token #:as Char]
  [css:ident #:+ CSS:Ident #:-> css-token #:as Symbol]
  [css:url #:+ CSS:URL #:-> css-token #:as String]
  [css:function #:+ CSS:Function #:-> css-token #:as Symbol])

The attachment contains the full example to run.
Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Attachment: infinite-typechecking.rkt
Description: Binary data

Reply via email to