[CM] extending the reader?

Gregg Reynolds dev at mobileink.com
Fri Oct 8 09:41:54 PDT 2021


Thanks. Looking at the c code I realized I made an embarrassingly dumb
mistake interpreting the error. The problem is not that the reader does not
accept '.', but that it expects it to be followed by an expression as in
'(a . b)'. So it chokes on '(a .)', as it should. Hacking the C code to
accept the latter would obviously be a bad idea. ;) So I'll just catch the
error and tell the user to  use './' instead of '.'.

On the other hand, it would be nice if the error args included the string
that caused the error in a more convenient form. It's included in the
message string, but it would be nice if it were passed in isolation, like
'(:data ...badcode here...)' or some such.

Thanks!

On Fri, Oct 8, 2021 at 9:27 AM <bil at ccrma.stanford.edu> wrote:

> I can't think of a way to do this in scheme code.
> *read-error-hook* is not currently called at the
> point of the error (probably line 69449 in s7.c).
> I suppose it could be called, but I'd need to back
> out with the new input (if any), which would take
> a ton of testing.  You could change the C code,
> perhaps --
>
>    {
>      s7_pointer pt;
>      pt = current_input_port(sc);
>      fprintf(stderr, "%c\n", port_data(pt)[port_position(pt) - 2]);
>    }
>
> at that pointer prints ".", so you know it's reading
> ".)".  You'd need to add the symbol ./ to the current
> list in the reader, then pop back to whatever was
> being read before that -- kinda tricky!
> I'll look into extending *read-error-hook*, but with
> input like that, there are probably more such gotchas.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/pipermail/cmdist/attachments/20211008/7865eb5b/attachment.html>


More information about the Cmdist mailing list