From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: Improved (and faster) reader Date: Thu, 23 Aug 2007 23:19:01 +0200 Message-ID: <87veb6gda2.fsf@chbouib.org> References: <1181845261.4156.1.camel@localhost.localdomain> <87zm1ojsie.fsf@chbouib.org> <87hcmr83d4.fsf@zip.com.au> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1187904065 9323 80.91.229.12 (23 Aug 2007 21:21:05 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 23 Aug 2007 21:21:05 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Aug 23 23:21:01 2007 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IOK6t-0004Rl-8s for guile-devel@m.gmane.org; Thu, 23 Aug 2007 23:20:59 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IOK6s-0006iE-NN for guile-devel@m.gmane.org; Thu, 23 Aug 2007 17:20:58 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IOK5r-0006Jf-Iz for guile-devel@gnu.org; Thu, 23 Aug 2007 17:19:55 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IOK5q-0006JE-PL for guile-devel@gnu.org; Thu, 23 Aug 2007 17:19:55 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IOK5q-0006J8-JI for guile-devel@gnu.org; Thu, 23 Aug 2007 17:19:54 -0400 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IOK5p-0002hU-Ip for guile-devel@gnu.org; Thu, 23 Aug 2007 17:19:54 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1IOK5f-0000J8-JL for guile-devel@gnu.org; Thu, 23 Aug 2007 23:19:43 +0200 Original-Received: from adh419.fdn.fr ([80.67.176.9]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 23 Aug 2007 23:19:43 +0200 Original-Received: from ludo by adh419.fdn.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 23 Aug 2007 23:19:43 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 111 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: adh419.fdn.fr X-URL: http://www.laas.fr/~lcourtes/ X-PGP-Key-ID: 0xEB1F5364 X-PGP-Key: http://www.laas.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 821D 815D 902A 7EAB 5CEE D120 7FBA 3D4F EB1F 5364 X-OS: i486-pc-linux-gnu User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) Cancel-Lock: sha1:CZFlCaXTDcY5j9UismalGK6cNXQ= X-Detected-Kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:6741 Archived-At: --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hi, Kevin Ryde 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'. --=-=-= Content-Type: text/x-patch; charset=iso-8859-1 Content-Disposition: inline; filename*=us-ascii''%2c%2creader-quote.diff Content-Transfer-Encoding: 8bit Content-Description: The patch --- orig/libguile/ChangeLog +++ mod/libguile/ChangeLog @@ -1,5 +1,8 @@ 2007-08-23 Ludovic Courtès + * 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 --- 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 + + * tests/reader.test (read-options)[positions on quote]: New + test, proposed by Kevin Ryde. + 2007-08-23 Kevin Ryde * 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))))) --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel --=-=-=--