From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Israelsson Tampe Newsgroups: gmane.lisp.guile.devel Subject: Re: how to implement mutual recursive parsers in syntax-parse Date: Sat, 19 May 2012 00:05:43 +0200 Message-ID: References: <87obppmgr8.fsf@pobox.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=14dae934048df480f804c056c013 X-Trace: dough.gmane.org 1337378754 8647 80.91.229.3 (18 May 2012 22:05:54 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 18 May 2012 22:05:54 +0000 (UTC) Cc: guile-devel To: Andy Wingo Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat May 19 00:05:53 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SVVJ2-00009n-Sa for guile-devel@m.gmane.org; Sat, 19 May 2012 00:05:53 +0200 Original-Received: from localhost ([::1]:38448 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SVVJ2-0006mM-9Z for guile-devel@m.gmane.org; Fri, 18 May 2012 18:05:52 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:34438) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SVVIy-0006m6-HE for guile-devel@gnu.org; Fri, 18 May 2012 18:05:49 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SVVIw-0003v0-Fv for guile-devel@gnu.org; Fri, 18 May 2012 18:05:48 -0400 Original-Received: from mail-yw0-f41.google.com ([209.85.213.41]:56479) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SVVIw-0003un-5k for guile-devel@gnu.org; Fri, 18 May 2012 18:05:46 -0400 Original-Received: by yhr47 with SMTP id 47so4114152yhr.0 for ; Fri, 18 May 2012 15:05:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=3LCfx3QQqs4IX/GFAImr20guprb/ZsoT2E53PDUkiq8=; b=Tsn/pjcC2SE28whnE/pcO0RccQTbMBb9qpQF7LSB7XmAZoNhstWoBlxylMLUsOi8ij XZ0IeH1HzPgQ5xGPrADTTB6Beb244iuHdO73gpbvXzXMm4VWFgmJbwi/wTYg10RkoFst Qof470pVczJ+91k9ZbuAdRIatbgVI9Vf79t/xBOtRWc8GQ0RStSBHNv6k2dBSilylT1M XyIxBP8e6Srfciu3CvpGwo1sCOooKtaX/LsNaiz4amNjx6B3VXwoj8FAOIhCemy7C6t0 qnTwAOsMb4iRQ6p8UI9r2Z9s2LfvSO8RuL912FDRdOmipqV8NhHTiQ1zNlTWoshbryF4 ILDg== Original-Received: by 10.50.216.232 with SMTP id ot8mr2057758igc.22.1337378743812; Fri, 18 May 2012 15:05:43 -0700 (PDT) Original-Received: by 10.50.242.102 with HTTP; Fri, 18 May 2012 15:05:43 -0700 (PDT) In-Reply-To: <87obppmgr8.fsf@pobox.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.213.41 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:14489 Archived-At: --14dae934048df480f804c056c013 Content-Type: text/plain; charset=ISO-8859-1 Another clue, Put this into a file and load it (define (f x) (c)) (define-syntax c (lambda (x) (pk 'c) #t)) ,x f shows 0 (assert-nargs-ee/locals 1) ;; 1 arg, 0 locals 2 (toplevel-ref 1) ;; # 4 (tail-call 0) at examples/mutual.scm:9:14 and (f 1) yields scheme@(guile-user) [4]> (f 1) ERROR: In procedure #: ERROR: Wrong type to apply: # This is confusing!! /Stefan On Tue, May 15, 2012 at 8:38 PM, Andy Wingo wrote: > On Mon 14 May 2012 21:13, Stefan Israelsson Tampe > writes: > > > (begin > > (define parser-a code-a ...) > > (define-syntax a spec-a)) > > > > (begin > > (define parser-b code-b ...) > > (define-syntax b spec-b)) > > > > In racket they manage to evaluate the define-syntax forms before the > define-forms cause in the expansion > > of code-a amd code-b they need the spec's spec-a and spec-b. > > > > Do you have any ideas how solve this. I do have a fix for problem but it > is not easy to use. > > Have you tried master? If I understand you correctly I think it should > work there. > > Andy > -- > http://wingolog.org/ > --14dae934048df480f804c056c013 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Another clue,

Put this into a file and load it

=A0(define (f = x) (c))
=A0(define-syntax c (lambda (x) (pk 'c) #t))

,x f sho= ws

=A0=A0 0=A0=A0=A0 (assert-nargs-ee/locals 1)=A0=A0=A0=A0=A0 ;; 1= arg, 0 locals
=A0=A0 2=A0=A0=A0 (toplevel-ref 1)=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0 ;; #<syntax-transformer c>
=A0=A0 4=A0=A0=A0 (tail-call 0)=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 at examples/mutual.scm:9:14

and (f 1) yields

scheme@(guil= e-user) [4]> (f 1)
ERROR: In procedure #<syntax-transformer c>:=
ERROR: Wrong type to apply: #<syntax-transformer c>

This is confusing!!

/Stefan

On= Tue, May 15, 2012 at 8:38 PM, Andy Wingo <wingo@pobox.com> wr= ote:
On Mon 14 May 2012 21:13, = Stefan Israelsson Tampe <stef= an.itampe@gmail.com> writes:

> (begin
> =A0=A0 (define parser-a code-a ...)
> =A0=A0 (define-syntax a spec-a))
>
> (begin
> =A0=A0 (define parser-b code-b ...)
> =A0=A0 (define-syntax b spec-b))
>
> In racket they manage to evaluate the define-syntax forms before the d= efine-forms cause in the expansion
> of code-a amd code-b they need the spec's spec-a and spec-b.
>
> Do you have any ideas how solve this. I do have a fix for problem but = it is not easy to use.

Have you tried master? =A0If I understand you correctly I think it sh= ould
work there.

Andy
--
http://wingolog.org/=

--14dae934048df480f804c056c013--