guile-devel
[Top][All Lists]
Advanced

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

Re: Improved (and faster) reader


From: Ludovic Courtès
Subject: Re: Improved (and faster) reader
Date: Thu, 23 Aug 2007 23:19:01 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

Hi,

Kevin Ryde <address@hidden> writes:

> address@hidden (Ludovic Courtès) writes:
>>
>> +scm_read_quote (int chr, SCM port)
>
> I think you may have lost source properties from quote and quasi-quote
> forms,
>
>       (read-enable 'positions)
>       (source-properties (read (open-input-string "'x")))
>       => ()

Good catch.  Did you actually trigger it or did you just notice it in
the source?

I committed the attached fix.

Thanks!

Ludo'.

--- orig/libguile/ChangeLog
+++ mod/libguile/ChangeLog
@@ -1,5 +1,8 @@
 2007-08-23  Ludovic Courtès  <address@hidden>
 
+       * read.c (scm_read_quote): Record position and copy source
+       expression when asked to.  Reported by Kevin Ryde.
+
        * stime.c: Define `_REENTRANT' only if not already defined.
 
 2007-08-21  Kevin Ryde  <address@hidden>


--- orig/libguile/read.c
+++ mod/libguile/read.c
@@ -610,6 +610,8 @@
 scm_read_quote (int chr, SCM port)
 {
   SCM p;
+  long line = SCM_LINUM (port);
+  int column = SCM_COL (port) - 1;
 
   switch (chr)
     {
@@ -643,6 +645,17 @@
     }
 
   p = scm_cons2 (p, scm_read_expression (port), SCM_EOL);
+  if (SCM_RECORD_POSITIONS_P)
+    scm_whash_insert (scm_source_whash, p,
+                     scm_make_srcprops (line, column,
+                                        SCM_FILENAME (port),
+                                        SCM_COPY_SOURCE_P
+                                        ? (scm_cons2 (SCM_CAR (p),
+                                                      SCM_CAR (SCM_CDR (p)),
+                                                      SCM_EOL))
+                                        : SCM_UNDEFINED,
+                                        SCM_EOL));
+
 
   return p;
 }


--- orig/test-suite/ChangeLog
+++ mod/test-suite/ChangeLog
@@ -1,3 +1,8 @@
+2007-08-23  Ludovic Courtès  <address@hidden>
+
+       * tests/reader.test (read-options)[positions on quote]: New
+       test, proposed by Kevin Ryde.
+
 2007-08-23  Kevin Ryde  <address@hidden>
 
        * tests/ports.test (port-for-each): New test for passing freed cell,


--- orig/test-suite/tests/reader.test
+++ mod/test-suite/tests/reader.test
@@ -152,5 +152,11 @@
                   (lambda ()
                     (read-string "(+ 1 2 3)")))))
       (and (equal? (source-property sexp 'line) 0)
+           (equal? (source-property sexp 'column) 0))))
+  (pass-if "positions on quote"
+    (let ((sexp (with-read-options '(positions)
+                  (lambda ()
+                    (read-string "'abcde")))))
+      (and (equal? (source-property sexp 'line) 0)
            (equal? (source-property sexp 'column) 0)))))
 




reply via email to

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