From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Matt Wette Newsgroups: gmane.lisp.guile.user Subject: Re: Nyacc question: [found] where are the actions bound? Date: Sat, 14 Mar 2020 07:31:10 -0700 Message-ID: <6b4d3cde-3b75-3a42-786e-1d381f6c7cb0@gmail.com> References: <20200308101445.GB28250@tuxteam.de> <40b09b97-862e-6bb0-3205-45bb9dd35d46@gmail.com> <20200314115919.GD4091@tuxteam.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="73650"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sat Mar 14 15:31:33 2020 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jD7p5-000J26-HR for guile-user@m.gmane-mx.org; Sat, 14 Mar 2020 15:31:31 +0100 Original-Received: from localhost ([::1]:45440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jD7p4-0004Za-7z for guile-user@m.gmane-mx.org; Sat, 14 Mar 2020 10:31:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47042) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jD7op-0004ZU-Bc for guile-user@gnu.org; Sat, 14 Mar 2020 10:31:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jD7oo-0005ez-BG for guile-user@gnu.org; Sat, 14 Mar 2020 10:31:15 -0400 Original-Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:35135) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jD7oo-0005cM-4w for guile-user@gnu.org; Sat, 14 Mar 2020 10:31:14 -0400 Original-Received: by mail-pl1-x62e.google.com with SMTP id g6so5707012plt.2 for ; Sat, 14 Mar 2020 07:31:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=JUvJxq78ElBwGt21dMfgW3hY+jDHzpgqKviPi7wyvNo=; b=W2Asy4qPaWBn+pTgLclPyjRzHlwsEyENnDq0LvxU3++AEd/OidlYXYIJxGa3lKMfSf U7IIzlh94Mv+8yJ9Ok5X1x48e6Dfh/g18MGsZR7a77x+ptsuiSEJeV8ZMkcrax9J87Bj DlT4La9/2zzPbZpcyqeS/8R33xXjbPziaqRL+mc+/UDrBE47dhcdar7xUoCYX+hXE6K2 OQo3ieXWJjs1m29Zysiw1mye4oMVr//AdhRRi9UqJAblw00IxxtNuT+lO4xYamc/VMgo 5DFlCGa5osY1gfauLVPb2V2A3OKGh4UY3hyTI/EwbipUXphC3G3zW29qsfmrnV46pOzv n17Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=JUvJxq78ElBwGt21dMfgW3hY+jDHzpgqKviPi7wyvNo=; b=lWgtf1zFZu2XoxX4KVICbYzZIcFXG7cbPEBPWwEWQATtTr8sirAvx6LLnNngFcAo+G 9Qm8HrNvPx4ton1/F7VbCexuig/EwIvomh233LhNO/zvbmduoHKzlFrwwsjiItREmR/u z2KUeMiRgtk4c4lNIIx2ymC0pF/MHYs3rpkf/8xsg/TA7RXA+80qgUBsqmUpOoS0bG1A 80T1Sw9Q6EUuGRX5EOCHHHroyCVuY7+gbXM1aU3ZOiRQSSy96iD15rTbW6z36XjlKfKA pqtV7tTJjukkGxs3wZnmCS+FkcBvNnfhkTtCK/YCY1Gi+HP7m1iY+dBsmutQlTvh59FN VDDg== X-Gm-Message-State: ANhLgQ2ZTbL9l97DiCqOjlsF/RiPLep/JjNwkKbh6oFAkEc1OmROi51J 8zk28W+Oqs63cDUWQXDikY7RAqiV X-Google-Smtp-Source: ADFU+vtZtux7fGK/pGzTur0a16VatZQ2vaVTyB6gCcyQOlYFEGTPONaPe+gnJmGYa1Od9rTHmmY4Qw== X-Received: by 2002:a17:902:778c:: with SMTP id o12mr18886865pll.324.1584196272544; Sat, 14 Mar 2020 07:31:12 -0700 (PDT) Original-Received: from [192.168.2.183] (64-52-176-132.championbroadband.com. [64.52.176.132]) by smtp.gmail.com with ESMTPSA id f17sm48379998pge.48.2020.03.14.07.31.11 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 14 Mar 2020 07:31:11 -0700 (PDT) In-Reply-To: <20200314115919.GD4091@tuxteam.de> Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::62e X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:16303 Archived-At: On 3/14/20 4:59 AM, tomas@tuxteam.de wrote: > On Sun, Mar 08, 2020 at 08:10:50AM -0700, Matt Wette wrote: >> >> On 3/8/20 3:14 AM, tomas@tuxteam.de wrote: >>> Hi, > [...] > >>> My question is: where is the stuff resolved which is mentioned >>> in grammar actions? > Hah. Managed to answer my own question by reading the source. > > For the benefits of others who might have a similar question > (without knowing how to articulate it, like it happened to > me), here's the answer: > > Yes, the actions are "resolved" wrt the (calling) module's > top level environment. The magic happens here (that's wrt the > all-fresh V1.01.2), around lines 47 ff, in module/nyacc/parse.scm: > > (define (make-xct av) > (if (procedure? (vector-ref av 0)) > av > (vector-map (lambda (ix f) (eval f (current-module))) > (vector-map (lambda (ix actn) (wrap-action actn)) av)))) > > It's the (eval f (current-module)) which does the trick. The > trick happens in make-lalr-parser. > > Background: I envisioned something like > > (let ( ...some environment for the actions...) > ...make-lalr-parser...) > > and have make-lalr-parser pick up the bindings in the lexical > environment. > > but had to realize that make-lalr-parser ignores the lexical > environment. That's now clear to me, because (eval ... (current-module)) > looks at the caller's module's top-level bindings. > > One would have to call local-eval (from (ice-9 local-eval)) and > explicitly pass (the-environment) (from the same module) to > achieve what I had in mind. > > Not that I'm proposing that, mind you. I still barely know what > I'm doing at this point. Probably there are very good reasons > to resort to the (top-level) module bindings. > > I just wanted to understand, and I think I do now :-) > > As to your other proposal (writing out the pre-compiled parser > with write-lalr-*), I think it's orthogonal to my issue. This > might come in handy when the parser is heavy enough that it > takes a significant time constructing it (which it is not in my > little use case for now) > > Thanks & cheers > -- tomás I get it now.  What you expect makes much sense.  I will think about that. Matt