From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: SMIE implementation for the C-like languages Date: Wed, 11 Nov 2015 09:17:19 -0500 Message-ID: References: <87mvun7lnx.fsf@ap4y.me> <87611alen3.fsf@ap4y.me> <87twot5ogb.fsf@ap4y.me> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1447251485 14973 80.91.229.3 (11 Nov 2015 14:18:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 11 Nov 2015 14:18:05 +0000 (UTC) Cc: emacs-devel@gnu.org To: Arthur Evstifeev Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Nov 11 15:17:58 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZwWDK-0005I7-1J for ged-emacs-devel@m.gmane.org; Wed, 11 Nov 2015 15:17:30 +0100 Original-Received: from localhost ([::1]:40913 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwWDJ-0004mM-Dl for ged-emacs-devel@m.gmane.org; Wed, 11 Nov 2015 09:17:29 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58614) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwWDF-0004mF-Gv for emacs-devel@gnu.org; Wed, 11 Nov 2015 09:17:26 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZwWDB-0004o1-F6 for emacs-devel@gnu.org; Wed, 11 Nov 2015 09:17:25 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:42564) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwWDB-0004nQ-A3 for emacs-devel@gnu.org; Wed, 11 Nov 2015 09:17:21 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0AyFgA731xV/8uQWxdcgxCEAoVVu0CHSwQCAoE8OhMBAQEBAQEBgQpBBYNdAQEDAVYjBQsLDiYSFBgNJIg3CM8jAQEBBwIBH4s6hD5HB4QtBYwwkmeSFINZI2GBBYIwIIJ4AQEB X-IPAS-Result: A0AyFgA731xV/8uQWxdcgxCEAoVVu0CHSwQCAoE8OhMBAQEBAQEBgQpBBYNdAQEDAVYjBQsLDiYSFBgNJIg3CM8jAQEBBwIBH4s6hD5HB4QtBYwwkmeSFINZI2GBBYIwIIJ4AQEB X-IronPort-AV: E=Sophos;i="5.13,465,1427774400"; d="scan'208";a="177787523" Original-Received: from 23-91-144-203.cpe.pppoe.ca (HELO pastel.home) ([23.91.144.203]) by ironport2-out.teksavvy.com with ESMTP; 11 Nov 2015 09:17:20 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 004BC602A7; Wed, 11 Nov 2015 09:17:19 -0500 (EST) In-Reply-To: <87twot5ogb.fsf@ap4y.me> (Arthur Evstifeev's message of "Wed, 11 Nov 2015 14:12:20 +1300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:194059 Archived-At: >>> if true { >>> |bar >>> } [...] > I'm a bit suspicious about :list-intro 'if', :elem 'args' and that :elem > 'basic' was requested 2 times, especially if you compare against second > example I sent yesterday (which has a proper indentation). Without stepping through the rules-function to see where is what and comparing to the precise grammar you used, I can't tell you in detail if that's really necessary or not, but normally the above case will need to compute the virtual indentation of the "{" and this "{...}" probably looks like a sexp to SMIE, so SMIE sees the above as "KEYWORD(if) SEXP1 SEXP2", so the "SEXP1 SEXP1" may be a function call (SEXP1 being the function and SEXP2 the argument). >> That's because it tries to match "}" with an opening "if" (since your >> grammar states ("if" exp "{" insts "}") which implies that "{" is an >> infix terminal). > Yes that's true, but braces are also a part of the syntax table. That's right, so there are two conflicting "definitions" of what { and } do. I'm not surprised that SMIE doesn't deal well with such situations, because I'm myself not really sure how it should be handled. > Since smie allow any sequence of sexp anywhere, I think this code > block should be handled. But the smie-grammar refines the definition of "sexp" provided by the syntax-table, so it's not clear any more whether "{...}" is really a sexp or is only the second half of "if ... { ... }". > I'm not sure what is the best way to do that but maybe something like > a fallback logic to the syntax tables for such cases? I understand what you mean, but I don't know how to translate that into code, because once you look at it from the code's point of view, the requirements are often conflicting. >>> But it doesn't change behavior of the blinking: for the same if >>> construction blinking happens for the "if" token. Is there a different >>> way of altering this behavior? >> My guess would be that the default blinking code uses forward-sexp which >> goes through forward-sexp-function which SMIE sets up as well. Try set >> this var back to nil in swift-mode buffers, see if that helps. > I tried to reset forward-sexp-function and it works when I'm not > tokenizing braces. When braces handled in lexer, I'm getting "Mismatched > parenthesis" error similar to one of the previous examples. I suggest you report this as a bug as well, providing enough details to reproduce it. I don't know if it's indeed a bug or not, but we need to investigate in more details. Stefan