From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: SMIE examples or guides Date: Thu, 30 Jun 2016 03:23:08 -0400 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1467271447 9758 80.91.229.3 (30 Jun 2016 07:24:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 30 Jun 2016 07:24:07 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: =?windows-1252?Q?Bj=F6rn?= Lindqvist Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jun 30 09:23:49 2016 Return-path: Envelope-to: geh-help-gnu-emacs@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 1bIWK9-0001Y0-46 for geh-help-gnu-emacs@m.gmane.org; Thu, 30 Jun 2016 09:23:45 +0200 Original-Received: from localhost ([::1]:47390 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIWK7-0003QK-Rp for geh-help-gnu-emacs@m.gmane.org; Thu, 30 Jun 2016 03:23:43 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55969) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIWJi-0003QE-0p for help-gnu-emacs@gnu.org; Thu, 30 Jun 2016 03:23:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bIWJe-0004rE-ON for help-gnu-emacs@gnu.org; Thu, 30 Jun 2016 03:23:17 -0400 Original-Received: from smtp-as-01-06.vtxnet.net ([194.38.175.135]:55757 helo=smtp-as-01.vtxnet.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIWJe-0004qt-Dn for help-gnu-emacs@gnu.org; Thu, 30 Jun 2016 03:23:14 -0400 Original-Received: from smtp-as-01.vtxnet.net (smtp-as-01-04.vtxnet.net [194.38.175.133]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-as-01.vtxnet.net (Postfix) with ESMTPS id B1F834C32D; Thu, 30 Jun 2016 09:23:11 +0200 (CEST) Original-Received: from smtp-pri-03.vtxnet.net (smtp-pri-03-1.vtxnet.net [212.147.62.147]) by smtp-as-01.vtxnet.net (Postfix) with ESMTP id 5DC2C4A195; Thu, 30 Jun 2016 09:23:09 +0200 (CEST) Original-Received: from fmsmemgm.homelinux.net (dyn.144-85-234-142.dsl.vtx.ch [144.85.234.142]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-pri-03.vtxnet.net (VTX Services SA) with ESMTP id 4B83968B7EC; Thu, 30 Jun 2016 09:23:09 +0200 (CEST) Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 72E45AE123; Thu, 30 Jun 2016 03:23:08 -0400 (EDT) In-Reply-To: (=?windows-1252?Q?=22Bj=F6rn?= Lindqvist"'s message of "Wed, 29 Jun 2016 18:48:32 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 194.38.175.135 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:110664 Archived-At: > I got it to work almost by experimenting with your suggestions. But it > appears to do some kind of automatic aligning I don't want: > > HELLO one > two > three > BYE If one, two, and three are an arbitrary sequence of <...> bracketed by HELLO and BYE, then the above looks like the proper indentation to me. > That should instead have been: > > HELLO one > two > three > BYE The indentation here looks wrong to me unless "one" is special in the sense that it's some kind of argument to HELLO and "two" and "three" are an arbitrary sequence of <...> bracketed by "HELLO " and "BYE". Which is it? And if it's the latter, how do you distinguish the separation between "one" and "two" (e.g. can the first line be something like "HELLO one two" where the "one two" is the argument to HELLO, and if so, how can you distinguish this case from the case where we have "HELLO one" and the subsequent "two" is part of the inner sequence)? Stefan > 2016-06-29 9:37 GMT+02:00 Stefan Monnier : >>> HELLO >>> HELLO foo BYE >>> HELLO >>> bla >>> net >>> neat >>> BYE >>> text more >>> more >>> BYE >>=20 >> That's expected: the third HELLO...BYE is indented as an argument of >> the first. Similarly to: >>=20 >> (table->method) >> (arg1, >> arg2 >> ) >>=20 >> [ Read the above, thinking that "(" is like HELLO and ")" is like >> "BYE". ] >>=20 >> Similarly, "net" and "neat" are treated as arguments to "bla". >>=20 >> A quick fix to that part would be to add an indentation rule along the >> lines of >>=20 >> (`(:elem . arg) 0) >>=20 >> or alternatively >>=20 >> (`(:list-intro . ,_) t) >>=20 >> Tho, if your language makes newlines significant (i.e. "bla\nnet" is not >> equivalent to "bla net"), then you might be better off changing the >> tokenizer (by providing appropriate :forward-token and :backward-token >> arguments to `smie-setup') so as to return an actual token for every >> newline encountered, after which you can add corresponding rules to >> the grammar. >>=20 >>> HELLO >>> bla >>> net >>> neat >>> BYE >>=20 >> To get the BYE indented this way, a quick-fix could be to add a rule >> like >>=20 >> (`(:before . "BYE") 4) >>=20 >>=20 >> -- Stefan >>=20 >>=20 > --=20 > mvh/best regards Bj=F6rn Lindqvist