* [PATCH]
@ 2010-10-27 18:27 Neil Jerram
2010-10-27 18:29 ` [PATCH] Make (read-elisp) handle EOF Neil Jerram
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Neil Jerram @ 2010-10-27 18:27 UTC (permalink / raw)
To: guile-devel
[-- Attachment #1: Type: text/plain, Size: 353 bytes --]
I have a program that calls (read-elisp) in a loop, to read in a BBDB
file. When it gets to the end of the file, the next (read-elisp) throws
an error (wrong type arg, pair expected), and the attached patch makes
it return '*eoi* instead.
Is that correct? Is *eoi* better than #<eof> here? Or should I just
catch the exception instead?
Neil
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Make-read-elisp-handle-EOF.patch --]
[-- Type: text/x-diff, Size: 1142 bytes --]
From b6017106abe754c596efe208554e98efc0248662 Mon Sep 17 00:00:00 2001
From: Neil Jerram <neil@ossau.uklinux.net>
Date: Wed, 27 Oct 2010 19:23:35 +0100
Subject: [PATCH] Make (read-elisp) handle EOF
* module/language/elisp/parser.scm (get-expression): Handle the case
where a top level lex returns *eoi*.
---
module/language/elisp/parser.scm | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/module/language/elisp/parser.scm b/module/language/elisp/parser.scm
index 4d9b0c3..bb495ea 100644
--- a/module/language/elisp/parser.scm
+++ b/module/language/elisp/parser.scm
@@ -171,7 +171,7 @@
(define (get-expression lex)
(let* ((token (lex 'get))
- (type (car token))
+ (type (if (pair? token) (car token) token))
(return (lambda (result)
(if (pair? result)
(set-source-properties! result (source-properties token)))
@@ -194,6 +194,8 @@
(setter expr)
(force-promises! expr)
expr))
+ ((*eoi*)
+ (return token))
(else
(parse-error token "expected expression, got" token)))))
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Make (read-elisp) handle EOF
2010-10-27 18:27 [PATCH] Neil Jerram
@ 2010-10-27 18:29 ` Neil Jerram
2010-10-27 18:30 ` [PATCH] Noah Lavine
2010-10-27 22:14 ` [PATCH] Ludovic Courtès
2 siblings, 0 replies; 6+ messages in thread
From: Neil Jerram @ 2010-10-27 18:29 UTC (permalink / raw)
To: guile-devel
Neil Jerram <neil@ossau.uklinux.net> writes:
> I have a program that calls (read-elisp) in a loop [...]
Oh dear, sorry for omitting a proper Subject there. I've added one now.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH]
2010-10-27 18:27 [PATCH] Neil Jerram
2010-10-27 18:29 ` [PATCH] Make (read-elisp) handle EOF Neil Jerram
@ 2010-10-27 18:30 ` Noah Lavine
2010-10-27 22:14 ` [PATCH] Ludovic Courtès
2 siblings, 0 replies; 6+ messages in thread
From: Noah Lavine @ 2010-10-27 18:30 UTC (permalink / raw)
To: Neil Jerram; +Cc: guile-devel
*eoi* is what the LALR parser generator would need as input, so it
seems more consistent with the Guile API to make it return '*eoi*.
Noah
On Wed, Oct 27, 2010 at 2:27 PM, Neil Jerram <neil@ossau.uklinux.net> wrote:
> I have a program that calls (read-elisp) in a loop, to read in a BBDB
> file. When it gets to the end of the file, the next (read-elisp) throws
> an error (wrong type arg, pair expected), and the attached patch makes
> it return '*eoi* instead.
>
> Is that correct? Is *eoi* better than #<eof> here? Or should I just
> catch the exception instead?
>
> Neil
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH]
2010-10-27 18:27 [PATCH] Neil Jerram
2010-10-27 18:29 ` [PATCH] Make (read-elisp) handle EOF Neil Jerram
2010-10-27 18:30 ` [PATCH] Noah Lavine
@ 2010-10-27 22:14 ` Ludovic Courtès
2010-10-27 23:35 ` [PATCH] Neil Jerram
2 siblings, 1 reply; 6+ messages in thread
From: Ludovic Courtès @ 2010-10-27 22:14 UTC (permalink / raw)
To: guile-devel
Hi Neil,
Neil Jerram <neil@ossau.uklinux.net> writes:
> I have a program that calls (read-elisp) in a loop, to read in a BBDB
> file. When it gets to the end of the file, the next (read-elisp) throws
> an error (wrong type arg, pair expected), and the attached patch makes
> it return '*eoi* instead.
>
> Is that correct?
‘get-lexer/1’ can return '*eoi*, so yes, I think.
> Is *eoi* better than #<eof> here?
I don’t think so, since it’s the result returned by ‘read-elisp’, whose
callers shouldn’t see '*eoi*. So I think ‘get-expression’ should return
the EOF object when it encounters '*eoi*.
Besides, you might want to check if it’s fixed in the elisp branch, who
knows. :-)
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH]
2010-10-27 22:14 ` [PATCH] Ludovic Courtès
@ 2010-10-27 23:35 ` Neil Jerram
2010-11-20 15:42 ` [PATCH] Andy Wingo
0 siblings, 1 reply; 6+ messages in thread
From: Neil Jerram @ 2010-10-27 23:35 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guile-devel
ludo@gnu.org (Ludovic Courtès) writes:
> Besides, you might want to check if it’s fixed in the elisp branch, who
> knows. :-)
Ah, yes, I didn't think of that. As luck would have it, this has indeed
been fixed already. :-)
Thanks,
Neil
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH]
2010-10-27 23:35 ` [PATCH] Neil Jerram
@ 2010-11-20 15:42 ` Andy Wingo
0 siblings, 0 replies; 6+ messages in thread
From: Andy Wingo @ 2010-11-20 15:42 UTC (permalink / raw)
To: Neil Jerram; +Cc: Ludovic Courtès, guile-devel
On Thu 28 Oct 2010 01:35, Neil Jerram <neil@ossau.uklinux.net> writes:
> ludo@gnu.org (Ludovic Courtès) writes:
>
>> Besides, you might want to check if it’s fixed in the elisp branch, who
>> knows. :-)
>
> Ah, yes, I didn't think of that. As luck would have it, this has indeed
> been fixed already. :-)
And Brian's paperwork has finally come through, so we can merge it now,
after a review.
I have been totally negligent regarding getting the fine SoC work in. I
hope to get to that in the coming week.
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-11-20 15:42 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-27 18:27 [PATCH] Neil Jerram
2010-10-27 18:29 ` [PATCH] Make (read-elisp) handle EOF Neil Jerram
2010-10-27 18:30 ` [PATCH] Noah Lavine
2010-10-27 22:14 ` [PATCH] Ludovic Courtès
2010-10-27 23:35 ` [PATCH] Neil Jerram
2010-11-20 15:42 ` [PATCH] Andy Wingo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).