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