Re: Portin SSAX/SXML
Andy Wingo <[email protected]> Sat, 24 Jul 2004 11:19:39 +0100
| Newsgroups | gmane.lisp.scheme.ssax-sxml |
|---|---|
| Message-ID | <1090664378.30247.160.camel@localhost> |
Hey Oleg, Thanks for your reply. I finally got around to properly packaging SSAX, and wanted to share some notes. On Sat, 2004-07-10 at 00:32 -0700, [email protected] wrote: > > Guile's syntax-rules support sucks, though -- the module takes about a > > second to load up. > > Perhaps you would like to use SSAX/lib/SSAX-expanded.scm then > (especially for simple.scm, which you enclosed). I ended up doing this. Of course, that way you don't get sxml:make-parser and related macros, which is a bit wrong. I'm not sure what I'll do about this. It could be, as you say, that I should only avoid r5rs macros in the simple wrapper, and load up the full macros for (sxml ssax). Dunno. Also as you suggested, the -expanded source file is filtered as it is being opened. For the production code, it takes only the forms headed by `define', and for the tests, it imports the (sxml ssax) module, then loads up and evaluates the forms not headed by `define'. It is worth noting that the tests can't run with just the exports given in Michael's packages.scm; I had to poke into the internal stucture of the (sxml ssax) module to get at the following symbols: ssax:read-NCName ssax:read-QName ssax:largest-unres-name ssax:Prefix-XML ssax:resolve-name ssax:scan-Misc ssax:assert-token ssax:handle-parsed-entity ssax:warn ssax:skip-pi ssax:S-chars ssax:skip-S ssax:ncname-starting-char? make-xml-token unesc-string name-compare Michael, are those intentionally omitted from your interface? > > The other guile-related bit that matters is input-parse.scm; next-token > > is MUCH MUCH MUCH faster with `read-delimited' from guile's > > (ice-9 rdelim). > > I don't know about Guile's module system; some systems support > selected importing of code Odd. You can select certain things to import, you can rename symbols programmatically, but you can't select certain things to _not_ import. Well, since guile doesn't compile, and has first-class modules, you can hack around it in other ways. I fixed it. > > (define* (xml->sxml #:optional (port (current-input-port))) > It should be possible then to define 'define-opt' to map to native > Guile's form define*. Ah yes, I did that with input-parse.scm. Here it is, for the record. ;; rewrite oleg's define-opt into define* style (define-macro (define-opt bindings body . body-rest) (let* ((rev-bindings (reverse bindings)) (opt-bindings (and (pair? rev-bindings) (pair? (car rev-bindings)) (eq? 'optional (caar rev-bindings)) (cdar rev-bindings)))) (if opt-bindings `(define* ,(append (reverse (cons #:optional (cdr rev-bindings))) opt-bindings) ,body ,@body-rest) `(define* ,bindings ,body ,@body-rest)))) So, ssax 5.1 is in guile-lib now (or will be headed there soon). Thanks for the comments, they helped a lot. And thanks for the code as well :) Cheers, -- Andy Wingo <[email protected]> http://ambient.2y.net/wingo/ ------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click