From: "Björn Lindqvist" <bjourne@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: help-gnu-emacs@gnu.org
Subject: Re: SMIE examples or guides
Date: Thu, 30 Jun 2016 13:27:38 +0200 [thread overview]
Message-ID: <CALG+76eiDW8xQ2mzwQDd1_Qfu5yJsBnrMTdW1cf8WHeyQAbbaQ@mail.gmail.com> (raw)
In-Reply-To: <jwvziq3ywm0.fsf-monnier+emacs@gnu.org>
I'm not sure I understand. There are just two indentation-dependent
tokens in my language; HELLO which increases indentation by four for
subsequent lines and BYE which decreases indentation by four for
subsequent lines. So yes, one, two, three is an arbitrary sequence and
it could have been:
HELLO three one
four ten BYE
eleven HELLO
twelve
BYE
instead. This is what is required even if it doesn't look like proper
indentation. :) In the real mode I'm working on (HELLO/BYE is a toy
example) it makes more sense.
2016-06-30 9:23 GMT+02:00 Stefan Monnier <monnier@iro.umontreal.ca>:
>> 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 <something>" 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 <monnier@iro.umontreal.ca>:
>>>> HELLO
>>>> HELLO foo BYE
>>>> HELLO
>>>> bla
>>>> net
>>>> neat
>>>> BYE
>>>> text more
>>>> more
>>>> BYE
>>>
>>> That's expected: the third HELLO...BYE is indented as an argument of
>>> the first. Similarly to:
>>>
>>> (table->method)
>>> (arg1,
>>> arg2
>>> )
>>>
>>> [ Read the above, thinking that "(" is like HELLO and ")" is like
>>> "BYE". ]
>>>
>>> Similarly, "net" and "neat" are treated as arguments to "bla".
>>>
>>> A quick fix to that part would be to add an indentation rule along the
>>> lines of
>>>
>>> (`(:elem . arg) 0)
>>>
>>> or alternatively
>>>
>>> (`(:list-intro . ,_) t)
>>>
>>> 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.
>>>
>>>> HELLO
>>>> bla
>>>> net
>>>> neat
>>>> BYE
>>>
>>> To get the BYE indented this way, a quick-fix could be to add a rule
>>> like
>>>
>>> (`(:before . "BYE") 4)
>>>
>>>
>>> -- Stefan
>>>
>>>
>
>
>> --
>> mvh/best regards Björn Lindqvist
--
mvh/best regards Björn Lindqvist
next prev parent reply other threads:[~2016-06-30 11:27 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-19 2:57 SMIE examples or guides Björn Lindqvist
2016-06-20 3:21 ` Stefan Monnier
2016-06-26 12:23 ` Björn Lindqvist
2016-06-27 8:31 ` Stefan Monnier
2016-06-27 12:32 ` Björn Lindqvist
2016-06-27 22:02 ` Stefan Monnier
2016-06-28 11:34 ` Björn Lindqvist
2016-06-28 21:42 ` Stefan Monnier
2016-06-28 22:30 ` Björn Lindqvist
2016-06-29 7:37 ` Stefan Monnier
2016-06-29 16:48 ` Björn Lindqvist
2016-06-30 7:23 ` Stefan Monnier
2016-06-30 11:27 ` Björn Lindqvist [this message]
2016-06-30 18:49 ` Stefan Monnier
2016-07-01 0:49 ` Björn Lindqvist
2016-07-01 7:13 ` Stefan Monnier
2016-07-01 19:28 ` Björn Lindqvist
2016-07-01 23:09 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CALG+76eiDW8xQ2mzwQDd1_Qfu5yJsBnrMTdW1cf8WHeyQAbbaQ@mail.gmail.com \
--to=bjourne@gmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.