unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: guile-devel@gnu.org
Subject: Re: Improved (and faster) reader
Date: Thu, 23 Aug 2007 23:19:01 +0200	[thread overview]
Message-ID: <87veb6gda2.fsf@chbouib.org> (raw)
In-Reply-To: 87hcmr83d4.fsf@zip.com.au

[-- Attachment #1: Type: text/plain, Size: 438 bytes --]

Hi,

Kevin Ryde <user42@zip.com.au> writes:

> ludo@gnu.org (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'.


[-- Attachment #2: The patch --]
[-- Type: text/x-patch, Size: 1876 bytes --]

--- orig/libguile/ChangeLog
+++ mod/libguile/ChangeLog
@@ -1,5 +1,8 @@
 2007-08-23  Ludovic Courtès  <ludo@gnu.org>
 
+	* 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  <user42@zip.com.au>


--- 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  <ludo@gnu.org>
+
+	* tests/reader.test (read-options)[positions on quote]: New
+	test, proposed by Kevin Ryde.
+
 2007-08-23  Kevin Ryde  <user42@zip.com.au>
 
 	* 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)))))
 




[-- Attachment #3: Type: text/plain, Size: 143 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel

  reply	other threads:[~2007-08-23 21:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-14 18:21 Further profiling, including howto Andy Wingo
2007-07-22 16:46 ` Improved (and faster) reader Ludovic Courtès
2007-08-11 10:52   ` Ludovic Courtès
2007-08-23  1:08   ` Kevin Ryde
2007-08-23 21:19     ` Ludovic Courtès [this message]
2007-08-25  0:45       ` Kevin Ryde
2007-08-25  8:23         ` Ludovic Courtès
2007-08-25 13:15           ` Andy Wingo
2007-08-26 17:05             ` Ludovic Courtès
2007-09-03 16:59     ` 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=87veb6gda2.fsf@chbouib.org \
    --to=ludo@gnu.org \
    --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).