Thanks for that Danny :) I'll try to do that. Although I think that readtables documentations aren't understandable. I mean, searching on Google I can find 3 or 4 questions about them and no one seems to understand them.
> From: [email protected] > Date: Mon, 29 Apr 2013 12:44:54 -0600 > Subject: Re: [racket] I just can't understand readtables > To: [email protected] > CC: [email protected] > > Hi Tomas, > > For this particular case, you might not even need to use readtables. > Since you're already dealing with making your own Clojure-style > language, you might be able to override the literal datum macro, > #%datum, to rewrite uses of byte strings to regexps. > > Here's what this might look like: > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > #lang racket/base > > (module my-custom-language racket/base > ;; Example of overriding #%datum: > (provide (except-out (all-from-out racket/base) > #%datum) > (rename-out (#%my-datum #%datum))) > > (require (for-syntax racket/base)) > > ;; Here is our substitute definition for processing raw datums in > ;; our language: > (define-syntax (#%my-datum stx) > (syntax-case stx () > [(_ . bstring) > (bytes? (syntax-e #'bstring)) > ;; If we see a raw byte string, translate it to a use of > ;; a regexp. > (with-syntax ([an-str (bytes->string/utf-8 (syntax-e #'bstring))]) > (syntax/loc stx > (regexp an-str)))] > [(_ . other) > ;; Otherwise, delegate to the original definition of #%datum: > (syntax/loc stx > (#%datum . other))]))) > > > ;; Here is an example use of that custom language: > (module test (submod ".." my-custom-language) > (define r #"hello world, this should be a regexp") > (printf "~v\n" r) > (regexp? r)) > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
____________________ Racket Users list: http://lists.racket-lang.org/users

