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: define-language Date: Fri, 7 Aug 2020 14:46:41 -0700 Message-ID: References: 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="34849"; 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 Fri Aug 07 23:47:18 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 1k4ACq-0008uV-OZ for guile-user@m.gmane-mx.org; Fri, 07 Aug 2020 23:47:16 +0200 Original-Received: from localhost ([::1]:34798 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k4ACp-00013Z-NR for guile-user@m.gmane-mx.org; Fri, 07 Aug 2020 17:47:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43584) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k4ACN-00013O-FU for guile-user@gnu.org; Fri, 07 Aug 2020 17:46:47 -0400 Original-Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]:45438) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k4ACL-0003rB-Jj for guile-user@gnu.org; Fri, 07 Aug 2020 17:46:47 -0400 Original-Received: by mail-pf1-x42f.google.com with SMTP id f193so1782160pfa.12 for ; Fri, 07 Aug 2020 14:46:44 -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=Etw2iwqP2w5mvYxk9crTCTy4dCZy4N/NBYowcei5Q+Y=; b=vPXrflSBSusKOsdZnME+Hn9H2AzEpe3iKY4wxlaGAEy+sXclFR8vtQil00flpi+c2+ d72hvvdSmKYRrSX0b/6SDVH111olsoeZZCUdppXOkZanCZhI8f4ZT6l7EHgfzJ57i2vr 16wG4sVNvfFqUJ04lJa57UqwRidksp36tN43Ta8DRzmWMnYJUqy9DqhYqRAUmzQsi09+ l3yK3q2HOwoFS9cvQjnjBtKr+fvoWMZzLD+U60IyTnf7tNwD7kKM5yvW0WQc5bYKnNpJ 0PPEamL/O3aHPjgBFsO8Cm5kSAlQpItWOayB/YzwDYNMIq1c/uhMBWoNpZtpAlAx0fx6 4BrA== 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=Etw2iwqP2w5mvYxk9crTCTy4dCZy4N/NBYowcei5Q+Y=; b=RPZ0YAOfIQbGF3TLQzBDqJGftn24+Ky9iBiHETv2V/2mkU0WgqogyLJcq+KR3H1k2v INC6mkTBTOlKK1KLJp/+DO5WJQ/9gYSSgE39Xsr6uhdCNjGAUs1pT+kjSeuFbExkTx+i 4W4j7+7/A6E8WNjYl2ouyKYTxvKGgmbq4gT1LimCsm9PYi+GjOMLn8KN92HMV7Ndoe/w 0KPO3npplelhdyVMr7aQeCgOrg6bItlSNHW+bsJ3D8mWCGO+XO4OdjE2cBiF3mO4Whu/ 2yucYl4ZiPppKt54lNlz3YTjgDO4Beo7Ae/lpgmi2EssaTajl0GIXT7boIZmr7b+8FOs qs1g== X-Gm-Message-State: AOAM530Tn7XavHmGxsk+nOZJcj8+kks47S77Oj3dTEKzGo3xTkxNBKlF Ytfp1Hb7IEA2SIAcHpOSCXHNlUbF X-Google-Smtp-Source: ABdhPJwXJNNuwnSFNE8r+z+EagsCcr5UduLGGiYpIJg0ODsG+rlGFKzay7wXmcihd9QuijBnMYewmA== X-Received: by 2002:aa7:82d5:: with SMTP id f21mr14903640pfn.222.1596836803153; Fri, 07 Aug 2020 14:46:43 -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 e22sm11674917pgi.62.2020.08.07.14.46.42 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 07 Aug 2020 14:46:42 -0700 (PDT) In-Reply-To: Content-Language: en-US Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=matt.wette@gmail.com; helo=mail-pf1-x42f.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, URIBL_BLOCKED=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:16791 Archived-At: On 8/7/20 12:31 PM, Stephen Scheck wrote: > What is the right way to use `define-language`? The Guile manual says that > when using this form "the language will be added to the global language > set." I interpret that to mean that the `,language` meta-command switches > the REPL to use the newly-defined language, but it doesn't work: > > scheme@(guile-user)> (use-modules (system base language)) > scheme@(guile-user)> (define-language mylingua > #:title "Mylingua" > #:reader (lambda (port env) ...) > #:evaluator (lambda (x module) ...) > #:printer write) > scheme@(guile-user)> mylingua > $1 = #< name: mylingua title: "Mylingua" reader: # 1bfcd38 at :5:11 (port env)> printer: # #:optional _)> parser: #f compilers: () decompilers: () evaluator: > #:6:14 (x module)> joiner: #f > for-humans?: #t make-default-environment: # make-fresh-user-module ()> lowerer: #f analyzer: #f compiler-chooser: #f> > scheme@(guile-user)> ,language mylingua > While executing meta-command: > no such language mylingua I usually use a reader and compiler (something that compiles to tree-il). The important item to know is that the output of the reader is the input  for the compiler. I do have spec.scm files with evaluator but it's just the default I think. I don't remember what the evaluator does but guessing it processes input to the `eval' procedure. Check examples/language  and examples/language/nyacc/lang/ in https://download.savannah.gnu.org/project/nyacc or https://git.savannah.nongnu.org/cgit/nyacc.git/tree/  I include examples for a calculator (calc), javascript (nx-javascript), matlab (nx-mlang) and tcl (nx-tcl).  You can download and unpack the nyacc distribution. $ cd examples $ source env.sh $ guile guile> ,L nx-javascript .... nx-javascript@(guile-user)> var a = 1; nx-javascript@(guile-user)> a $1 = 1 nx-javascript@(guile-user)>