From: Christian Lynbech
Subject: temporary changing readtable
Date: 
Message-ID: <ofbsjecah0.fsf@chl.ted.dk.eu.ericsson.se>
I have been playing with Bakers META parser, but have run into a
problem with readtables that I do not quite know how to solve.

Bakers parser introduces a compact syntax for the match expressions,
thorugh read macros. Unfortunately, we have used some of the symbols
as ordinary symbols elsewhere in the application, and that file no
longer compiles when the readtable modifications for the parser is in
effect.

I could of course modify the code in question, but I would much rather
confine the readtable modifications to the file with the META parser
stuff.

The relevant part of the META parser setup looks a bit like this:

    (defvar *orig-readtable* (copy-readtable))

    (defstruct (meta
                (:print-function
                 (lambda (m s d &aux (char (meta-char m)) (form (meta-form m)))
                   (declare (ignore d))
                   (ecase char
                     ((··@ #\! #\$) (format s "~A~A" char form))
                     (#\[ (format s "[~{~A~^ ~}]" form))
                     (#\{ (format s "{~{~A~^ ~}}" form))))))
      char
      form)

    (defun meta-reader (s c) (make-meta :char c :form (read s)))

    (mapc #'(lambda (c) (set-macro-character c #'meta-reader t)) 
          '(··@ #\$ #\!))

so I tried adding this last in the parser file:

    (eval-when (compile load eval)
      (setq *readtable* *orig-readtable*))

to reset the readtable, but it doesn't seem to have any effect
(compilation of the other file still fails). 

Am I on the right track in how to do this?


PS

I am using ACL6. It may be that it uses different readtables in
different situations (ie. special tables for load/compile).

I haven't got the actual compilation error handy, sorry.



------------------------+-----------------------------------------------------
Christian Lynbech       | Ericsson Telebit, Skanderborgvej 232, DK-8260 Viby J
Phone: +45 8938 5244    | email: ·················@ted.ericsson.dk
Fax:   +45 8938 5101    | web:   www.ericsson.com
------------------------+-----------------------------------------------------
Hit the philistines three times over the head with the Elisp reference manual.
                                        - ·······@hal.com (Michael A. Petonic)
From: Raymond Wiker
Subject: Re: temporary changing readtable
Date: 
Message-ID: <86vghmm1mi.fsf@raw.grenland.fast.no>
Christian Lynbech <·················@ted.ericsson.dk> writes:

> I have been playing with Bakers META parser, but have run into a
> problem with readtables that I do not quite know how to solve.
> 
> Bakers parser introduces a compact syntax for the match expressions,
> thorugh read macros. Unfortunately, we have used some of the symbols
> as ordinary symbols elsewhere in the application, and that file no
> longer compiles when the readtable modifications for the parser is in
> effect.
> 
> I could of course modify the code in question, but I would much rather
> confine the readtable modifications to the file with the META parser
> stuff.
> 
> The relevant part of the META parser setup looks a bit like this:
> 
>     (defvar *orig-readtable* (copy-readtable))
> 

        load and compile-file bind *read-table*, so it may be better
to do like this instead:

(in-package "META-PARSER")

(defparameter *meta-readtable* nil)

(eval-when (:compile-toplevel :load-toplevel :execute)
  (setq *meta-readtable* (copy-readtable nil))
  (setq *readtable* *meta-readtable*)

        ...)

        This way, you'll "automatically" get the original readtable
back, and you'll be able to switch to *meta-readtable* whenever
required. 

        //Raymond.

-- 
Raymond Wiker                        Mail:  ·············@fast.no
Senior Software Engineer             Web:   http://www.fast.no/
Fast Search & Transfer ASA           Phone: +47 23 01 11 60
P.O. Box 1677 Vika                   Fax:   +47 35 54 87 99
NO-0120 Oslo, NORWAY                 Mob:   +47 48 01 11 60

Try FAST Search: http://alltheweb.com/