From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Matt Wette Newsgroups: gmane.lisp.guile.user Subject: Re: Nyacc question: where are the actions bound? Date: Thu, 30 Jul 2020 06:50:08 -0700 Message-ID: References: <20200308101445.GB28250@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="blaine.gmane.org:116.202.254.214"; logging-data="32032"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Thu Jul 30 15:50:29 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 1k18x2-0008BW-Ua for guile-user@m.gmane-mx.org; Thu, 30 Jul 2020 15:50:28 +0200 Original-Received: from localhost ([::1]:56108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k18x2-0008Sd-1A for guile-user@m.gmane-mx.org; Thu, 30 Jul 2020 09:50:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k18wp-0008Qw-0T for guile-user@gnu.org; Thu, 30 Jul 2020 09:50:15 -0400 Original-Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:40318) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k18wn-0000s8-7W for guile-user@gnu.org; Thu, 30 Jul 2020 09:50:14 -0400 Original-Received: by mail-pl1-x630.google.com with SMTP id u10so4683617plr.7 for ; Thu, 30 Jul 2020 06:50:12 -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=6V9igoFbueHIRx1rb1hkknNGCVz5cD2vNkOT5yG1HC0=; b=ou6e+yheRaRoPaC7B40x6jFpxnNQ2kGTo1JAIOsuAOEZ4W67+eT/nqbElK0CJsFmJn ScoqGD5omXxuIXZtw4vuOauwDagvofvgDkcZ6VBFy2oiaff78n1gzFpl7/mbg/yMvAQL W/x9YEGYj2kIEv8WBn7IlTKtLqi8I2avGKleEBAbHm8eTiWMwND739buLmYEVrLgGqCW ltzc5uCr+872Ndd/ZEZ0yljqZhMQWTt2fXXJgbU6m22Akcqck3Ly2z/B4vjt/IjhQhQO +2SY8JnBCuqcoI8ii5tpWjlhTTBY7n6jfyOeO42wSTvggVUFQrZdjqPq3os+DwG3aksi U8Kg== 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=6V9igoFbueHIRx1rb1hkknNGCVz5cD2vNkOT5yG1HC0=; b=BDUYpEyehaSaSynQhu275pWv2Iu69lp7A0thtaKOUxAc3WBC50KVMTQGOTM7TTODSw 0qEKmUgtS2SdVsYv/JBlm13wnuI5wpumjO2YqOS75imdd0wJzl/oswNWXTlQtBwkChOR wsp4AD6bt+NSa0lBiDyRgZEQ/PFob41P+9mhuf0wGRGPCYIt1CiFUcvvEyjzMPiVCPiz 4Rj6l9CNsdhTa6SV04ApwqTNYdGcmB46HDpTj8JbW2ty8klr2iK6V+aMC7DMF1B3Xj3o 55s8Zt82s4EQpXSE9QLrlZdXQY14sbxYOTIrMTWOlVKertI8gmKYHthkscoha/EdFLPO ufPg== X-Gm-Message-State: AOAM530XrvhLDaBCE9usjSvzqE64Ct0cxIhYf0uAqPVXcE9v3RbGNcjA 6YPJkrtyyuRxA5ufMFyofshSXZTY X-Google-Smtp-Source: ABdhPJyllESxYWeAM5JjzN4GRT6v0ggPLeq9c6M6LqiDZoXfGXu/BUqoPoujPTCidiY0P60x6diIHw== X-Received: by 2002:a17:90a:d30e:: with SMTP id p14mr3534935pju.173.1596117010861; Thu, 30 Jul 2020 06:50:10 -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 q7sm1172941pfl.156.2020.07.30.06.50.09 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Jul 2020 06:50:09 -0700 (PDT) In-Reply-To: <20200308101445.GB28250@tuxteam.de> Content-Language: en-US Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=matt.wette@gmail.com; helo=mail-pl1-x630.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:16760 Archived-At: On 3/8/20 3:14 AM, tomas@tuxteam.de wrote: > Hi, > > I'm playing around with Nyacc: I found a first little use case > to get my feet wet. > > First of all, than you, Matt, for this impressive package. > > Shamelessly stolen from the minimal example, playground looks > roughly like this: > > #+begin_source scheme > (use-modules (nyacc lalr)) > (use-modules (nyacc lex)) > (use-modules (nyacc parse)) > > ;; to be used in some ($$ ...) actions: > (define (collect arg) (display arg)) > > (define my-grammar > (lalr-spec > (start my-file) > (grammar > (my-file > (elt-list)) > ;; more productions, calling out to ($$... collect) > (name > ($ident))))) > > (define mach (make-lalr-machine aq-grammar)) > (define mtab (lalr-match-table mach)) > (define gen-lexer (make-lexer-generator mtab)) > (define raw-parse (make-lalr-parser mach)) > (define (parse) (raw-parse (gen-lexer))) > (parse) > #+end_source > > So I defined some function =collect= which will be called from > actions in the grammar. > > My question is: where is the stuff resolved which is mentioned > in grammar actions? My first experiments indicate that it's > looked up at (module) top level, as if (grammar ...) greedily > weaved that in at compile time. > > My idea would be to (pre-) define a grammar and to exchange > the actions later as needed. Or would I have to re-define the > grammar whenever I change my mind about actions? > > Note that I'm still very much in exploratory mode: "you're > holding it wrong" would be a perfectly adequate answer, as > would be "your mumblings are pretty unintelligible" :-) > > Cheers & thanks > -- tomás Hi Tomas, (I apologize for the ascii spelling) You may be able to do what you want with the following: (define (parse)  (let ((raw-parser (make-lalr-parser)))    (raw-parser (gen-lexer))))