From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.help Subject: Re: Working around the limitations of SMIE Date: Fri, 11 Nov 2022 16:20:35 +0000 Message-ID: <87zgcx1mzw.fsf@posteo.net> References: <874jv795xg.fsf@posteo.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35515"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier To: Stefan Monnier via Users list for the GNU Emacs text editor Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 11 17:21:26 2022 Return-path: Envelope-to: geh-help-gnu-emacs@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 1otWmS-0008tP-35 for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 11 Nov 2022 17:21:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otWlt-0006ao-7D; Fri, 11 Nov 2022 11:20:49 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otWlr-0006ZD-NU for help-gnu-emacs@gnu.org; Fri, 11 Nov 2022 11:20:47 -0500 Original-Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otWlm-0007eo-EF for help-gnu-emacs@gnu.org; Fri, 11 Nov 2022 11:20:45 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 8435C240104 for ; Fri, 11 Nov 2022 17:20:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1668183638; bh=E8+9A0K56nF0XIwfj6okIQD6G4wRKYooLRwAjbeiReI=; h=From:To:Cc:Subject:Date:From; b=WzoSZAdLyxTkj2uhIQkgrEeHNC9sC7coBbajeaS1xna4YIDb2feaD6cpTU10PfpEJ Y2EsERZHfOJHeAylyp0XcgfY3Co3lr/24bBG7sXaPqYwBVROnGS5RVUQH8O9p6JZ3I qVHaHE4ORb0HE+8NrolUtxSL13YbscKgKJxC86bAEutHfzQ47JStYn3NRL/F5OMlYA /xOiVelbekT2bcDzrQfQzmWatHhR4TJho4pY/CorDg9GB64gji8ruwBbkla+GOKyPr IjctMFyiUineffRYPaLcfr+EtzyldJEttvGlukpocNE+eWL8SjpYFhU06cRf8TXb5Q nYiTT/aSK0kvg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4N83pW47Qcz6tm9; Fri, 11 Nov 2022 17:20:35 +0100 (CET) In-Reply-To: (Stefan Monnier via Users list for the's message of "Thu, 10 Nov 2022 00:00:06 -0500") Received-SPF: pass client-ip=185.67.36.66; envelope-from=philipk@posteo.net; helo=mout02.posteo.de 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:140899 Archived-At: Stefan Monnier via Users list for the GNU Emacs text editor writes: >> I am writing a major mode for a little language I am using at >> university, and wanted to try using SMIE for indentation and all the >> other things. The issue I find myself confronted with is that functions >> are defined as in the following example: >> >> func funktion(x : int): float >> x := x * x; >> return x; >> end >> >> where there is no delimiter between the return type (float), and the >> rest of the body (such as "begin" or something like that). > > How is the separation between the function's return type and the > function's body defined? Is it based on the newline that follows the > type, or is the language constrained to have types that are > a single identifiers? The latter. This is the grammar production: functionDeclaration: ' func ' identifier '( ' ( parameterDeclaration ( ', ' parameterDeclaration ) * ) ? ') ' ( ': ' typeName ) ? block ' end ' ; >> Another issue I ran into with the above definition is that instructions >> are not indented correctly, as the above grammar doesn't express that in >> this language doesn't expect a semicolon after an end (just like C >> doesn't expect one after a "}"). So the result is that >> >> instead of: >> >> while y >= y1 do >> dummy := zeile(x1, x2, xstep, y); >> y := y - ystep; >> end >> return 0; >> >> I get: >> >> while y >= y1 do >> dummy := zeile(x1, x2, xstep, y); >> y := y - ystep; >> end >> return 0; > > Based on my experience, I suspect that the simplest solution for this is > to make "end" return 2 tokens (the "end" and then a ghost ";"). Funnily enough I had tried this out too, but I must have messed up somewhere because the result wasn't what I had intended. Thanks.