From: Neil Jerram <neil@ossau.uklinux.net>
To: guile-devel@gnu.org
Subject: [PATCH]
Date: Wed, 27 Oct 2010 19:27:47 +0100 [thread overview]
Message-ID: <87d3qvo5i4.fsf@ossau.uklinux.net> (raw)
[-- 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
next reply other threads:[~2010-10-27 18:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-27 18:27 Neil Jerram [this message]
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
-- strict thread matches above, loose matches on Subject: below --
2012-11-10 16:08 [PATCH] Ludovic Courtès
2012-11-10 19:18 ` [PATCH] Mark H Weaver
2012-11-11 3:30 ` [PATCH] Ian Price
2012-11-11 6:06 ` [PATCH] Noah Lavine
2012-11-11 14:02 ` [PATCH] Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d3qvo5i4.fsf@ossau.uklinux.net \
--to=neil@ossau.uklinux.net \
--cc=guile-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).