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: ruby-mide, SMIE and token priority Date: Wed, 06 Nov 2013 23:30:53 -0500 Message-ID: References: <527B069B.6020400@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1383798668 32659 80.91.229.3 (7 Nov 2013 04:31:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 7 Nov 2013 04:31:08 +0000 (UTC) Cc: emacs-devel To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 07 05:31:12 2013 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 1VeHFQ-0000wc-3E for ged-emacs-devel@m.gmane.org; Thu, 07 Nov 2013 05:31:12 +0100 Original-Received: from localhost ([::1]:37665 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VeHFP-0000Ab-Mb for ged-emacs-devel@m.gmane.org; Wed, 06 Nov 2013 23:31:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48858) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VeHFH-0000AS-0o for emacs-devel@gnu.org; Wed, 06 Nov 2013 23:31:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VeHF8-0007IT-Fo for emacs-devel@gnu.org; Wed, 06 Nov 2013 23:31:02 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:48133) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VeHF8-0007IN-BG for emacs-devel@gnu.org; Wed, 06 Nov 2013 23:30:54 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFFFxLzd/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLDiYSFBgNJIgeBsEtkQoDiGGcGYFegxU X-IPAS-Result: Av4EABK/CFFFxLzd/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLDiYSFBgNJIgeBsEtkQoDiGGcGYFegxU X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="37277728" Original-Received: from 69-196-188-221.dsl.teksavvy.com (HELO pastel.home) ([69.196.188.221]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 06 Nov 2013 23:30:53 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 1CAE960E3C; Wed, 6 Nov 2013 23:30:53 -0500 (EST) In-Reply-To: <527B069B.6020400@yandex.ru> (Dmitry Gutov's message of "Thu, 07 Nov 2013 05:18:51 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.182 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:165023 Archived-At: > bar.foo(tee) do > bar > end What is the AST corresponding to this code? I mean, is it a method call on "bar" with method "foo" and 2 arguments (tee and do...end)? I.e. (. bar foo tee (do-end bar))? > The problem seems to be that "." is considered the parent token of > "do". Probably because the left priority of "do" is not a number. SMIE parses it as (. bar (call foo tee (do-end bar))). > It would be more natural if the parent of "do" was ";" on the preceding > line, instead. You mean parse it as (call (. bar foo tee) (do-end bar))? > Is it at all possible to change the grammar this way? You'd probably have to use a trick similar to the " @ " used on the space between the method name and the multiple-args. > Or should we just handle this as a special case in the `ruby-smie-rules', > and in case of "do", instead of delegating to the parent, skip the parents > until we find ";"? Depends: the rule of thumb is that if you have to choose between "make the grammar match the AST" or "make the grammar match the indentation", then better choose "match the AST" and then adjust the indentation via the smie-rules. So if the indentation you want is indeed not faithful to the AST, then indeed it's better to fix it in smie-rules. But otherwise, if you can fix it in the grammar, then it's preferable. Stefan