From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: ruby-mide, SMIE and token priority Date: Thu, 07 Nov 2013 15:10:59 +0200 Message-ID: <527B9163.3020102@yandex.ru> References: <527B069B.6020400@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1383829884 21075 80.91.229.3 (7 Nov 2013 13:11:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 7 Nov 2013 13:11:24 +0000 (UTC) Cc: emacs-devel To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 07 14:11:29 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 1VePMt-0005k1-8m for ged-emacs-devel@m.gmane.org; Thu, 07 Nov 2013 14:11:27 +0100 Original-Received: from localhost ([::1]:40161 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VePMs-0004Ko-Pw for ged-emacs-devel@m.gmane.org; Thu, 07 Nov 2013 08:11:26 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50318) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VePMi-0004Ji-5v for emacs-devel@gnu.org; Thu, 07 Nov 2013 08:11:24 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VePMV-0005GY-Bg for emacs-devel@gnu.org; Thu, 07 Nov 2013 08:11:16 -0500 Original-Received: from mail-ea0-x22e.google.com ([2a00:1450:4013:c01::22e]:59962) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VePMV-0005GM-4K for emacs-devel@gnu.org; Thu, 07 Nov 2013 08:11:03 -0500 Original-Received: by mail-ea0-f174.google.com with SMTP id n15so262813ead.5 for ; Thu, 07 Nov 2013 05:11:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=uD5CZz1IxXWMct3dbU2Eux2o1UyfDqBshlHCBOirgEo=; b=e46+tFVpEH7KCNap9038cX8UFaKUzAKpQoPEC8VKgWba6DhPs6KdX9iqmMm4VbOYlk 6PMI2kfUThJOJ7MS7BnO2ONGP7ZL2bQ9Ye9yeBpQFLLQ4sgZF4KgSFdAOT+RUUPDdCUZ jaY3pvsVkMR9XH2JM/O3BdcjnnN74hCdz7aHefO57v93MuC/kx01fNkVSTqpwWqIzxs8 K/mfmUbVT1jxZUaBCr8HA3MLU8WpYJ8Rp0iiaA2rhtVTubScyGT0vJH4XfxzXQpHgtWU YS830GMINpqRkGaZvRMBafkQTed97RSJ5X7h3vjWyA+RLvGIrDLmI9f3UP9rvG+s8Yle pfDA== X-Received: by 10.14.177.68 with SMTP id c44mr826917eem.9.1383829862250; Thu, 07 Nov 2013 05:11:02 -0800 (PST) Original-Received: from [192.168.10.48] (93-245-142.netrun.cytanet.com.cy. [93.109.245.142]) by mx.google.com with ESMTPSA id w6sm9054490eeo.12.2013.11.07.05.11.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 07 Nov 2013 05:11:01 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c01::22e 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:165033 Archived-At: On 07.11.2013 06:30, Stefan Monnier wrote: >> 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))? More or less, yes. "bar" could also be a method, but the structure would be the same. >> 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))? Guess so. The argument in favor of doing it this way is the grammar is already a bit skewed toward indentation (for example, " @ " has higher priority than "."), but that's likely something to be fixed, too. >> 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. Ah, okay. Sounds not very efficient, performance-wise. >> 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. Let's try this way, then.