[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: Neil Jerram
Subject: [PATCH]
Date: Wed, 27 Oct 2010 19:27:47 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

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?


>From b6017106abe754c596efe208554e98efc0248662 Mon Sep 17 00:00:00 2001
From: Neil Jerram <address@hidden>
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)
+      ((*eoi*)
+       (return token))
         (parse-error token "expected expression, got" token)))))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]