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: Working around the limitations of SMIE Date: Wed, 09 Nov 2022 21:25:15 +0000 Message-ID: <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="35279"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 09 22:26:05 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 1ossaD-0008s0-3A for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 09 Nov 2022 22:26:05 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ossZY-0006Hd-Jt; Wed, 09 Nov 2022 16:25:24 -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 1ossZW-0006GY-VH for help-gnu-emacs@gnu.org; Wed, 09 Nov 2022 16:25:23 -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 1ossZV-000381-0u for help-gnu-emacs@gnu.org; Wed, 09 Nov 2022 16:25:22 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id E83B9240101 for ; Wed, 9 Nov 2022 22:25:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1668029118; bh=IfVr4lTRRUtgdinGjbHLRLEKOgqIpoZEq6KGsyVHCUc=; h=From:To:Subject:Date:From; b=bbn8pgCrU1jJCC3AUK6+sl+TousuOFYJNiCyB1PiRtZqCaVak7VLQVxlqJrb/v5L8 fTwkpkIvIoKFBp4oESh29iF3CYWJ1CvXaiyPLrE1IWgd+xsJcsMMdSo85yVxBZUvJq blGqTIs651SNKJQjBBQIvfDgQe/XvM3Xwn31Nde5TSH4HSpM0FTnNUeSEixDZ9LxGA dQCDIeMS578Pe70i0zjnAhcInA9qJdfhU7QVPiEKNspwbrVNciYNvw1YpVShlcz7o1 EKRpFEdVXt0xwfa5vAJNlZmxOFsrgk0VW4GpkwPOh0xIo/ARVHPINmGnXt4S+WFlsT ZOm+V10LbjOCg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4N6yg22SyWz9rxK for ; Wed, 9 Nov 2022 22:25:15 +0100 (CET) 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:140875 Archived-At: Hi, 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). My naive approach at defining a grammar was as follows: (defconst e2-grammar (smie-prec2->grammar (smie-bnf->prec2 '((id) (exp) (inst ("func" insts "end") ; <-- ("var" id ":" id) ("if" exp "then" insts "else" insts "end") ("if" exp "then" insts "end") ("while" exp "do" insts "end") ("return" exp) (id ":=" exp)) (insts (inst ";" insts) (inst))))) "SMIE grammar for e2.") Cannot express the fact that a return type, a non-terminal is followed by the rest of the body, another non-terminal. 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; because it tries to parse "while ... end return 0" as an instruction. I've been looking around the web for other major modes that use SMIE but couldn't find anything satisfying. I wonder if it is necessary to define a special token-function that generates whitespace tokens? I hope there is a better way.