From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Jose Roberto B. de A. Monteiro" Newsgroups: gmane.lisp.guile.user Subject: Re: string parsing/preparation for latex Date: Tue, 08 Nov 2005 14:35:44 -0200 Message-ID: <1131467744.10838.3.camel@ariel.sel.eesc.usp.br> References: <20051107145304.0761d3d8@faust> <1131378541.3553.13.camel@ariel.sel.eesc.usp.br> <20051108155212.1f7f04c7@faust> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1131468549 17797 80.91.229.2 (8 Nov 2005 16:49:09 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 8 Nov 2005 16:49:09 +0000 (UTC) Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Nov 08 17:49:05 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EZWSn-0002iz-5Y for guile-user@m.gmane.org; Tue, 08 Nov 2005 17:36:49 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EZWSm-0007jr-Mf for guile-user@m.gmane.org; Tue, 08 Nov 2005 11:36:48 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EZWS5-0007Qc-6i for guile-user@gnu.org; Tue, 08 Nov 2005 11:36:05 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EZWS1-0007PT-S8 for guile-user@gnu.org; Tue, 08 Nov 2005 11:36:04 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EZWS1-0007PH-FH for guile-user@gnu.org; Tue, 08 Nov 2005 11:36:01 -0500 Original-Received: from [143.107.235.233] (helo=igbt.sel.eesc.usp.br) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EZWS1-0002lu-3p for guile-user@gnu.org; Tue, 08 Nov 2005 11:36:01 -0500 Original-Received: from ariel.sel.eesc.usp.br ([143.107.235.183] ident=mail) by igbt.sel.eesc.usp.br with esmtp (Exim 3.36 #1 (Debian)) id 1EZWRv-0000md-00 for ; Tue, 08 Nov 2005 14:35:55 -0200 Original-Received: from betoes by ariel.sel.eesc.usp.br with local (Exim 3.36 #1 (Debian)) id 1EZWRl-0003wX-00 for ; Tue, 08 Nov 2005 14:35:45 -0200 Original-To: guile-user@gnu.org In-Reply-To: <20051108155212.1f7f04c7@faust> X-Mailer: Evolution 2.2.3 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:4944 Archived-At: Em Ter, 2005-11-08 =E0s 15:52 +0100, David Pirotte escreveu: > On Mon, 07 Nov 2005 13:49:01 -0200 > "Jose Roberto B. de A. Monteiro" wrote: >=20 > > Em Seg, 2005-11-07 =E0s 14:53 +0100, David Pirotte escreveu: > > > does anyone understands why this does not return the expected result > > >=20 > > > (define *texu/reserved-characters* > > > ;; % \ { } ~ $ & # ^ _ > > > '( > > > #\% ;; comments > > > #\\ ;; command(follows by a space) > > > #\{ ;; definition of treatment block(main_arg) > > > #\} =09 > > > #\~ ;; indivisible space > > > #\$ ;; mathematical mode=20 > > > #\& ;; tabulation ... > > > #\# ;; symbol of parameter zone > > > #\^ ;; exponent > > > #\_ ;; index > > > ) > > > ) > > >=20 > > > (define (texu/prep-str-for-tex str) > > > (let ((str-lst (string->list str)) > > > (result (list))) > > > (for-each (lambda (chr) > > > (if (member chr *texu/reserved-characters*) > > > (set! result (cons chr (cons #\\ result))) > > > (set! result (cons chr result)))) > > > str-lst) > > > (reverse-list->string result) > > > )) > >=20 > > Because you should have this string: ";; % \\ { } ~ $ & # ^ _", with tw= o > > backslashes instead of one... the same for " >=20 > but that is not possible, because the string (here simulated) is a user t= yped in string > (through a gtk interface programmed in guile-gnome) upon which I have no= control.=20 > I precisly wish to parse it to create a .tex file later processed by late= x ... Ok, look at the foloowing: guile> (define s ";; % \\ { } ~ $ & # ^ _") We need the double backslash here to define one backslash in the internal string code. Then: guile> s ";; % \\ { } ~ $ & # ^ _" guile> (texu/prep-str-for-tex s) ";; \\% \\\\ \\{ \\} \\~ \\$ \\& \\# \\^ \\_" Well, I believe that your code is working properly. Each pair of '\' is in reality one '\'... _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user