all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Arthur Evstifeev <mail@ap4y.me>
To: emacs-devel@gnu.org
Cc: monnier@iro.umontreal.ca
Subject: SMIE implementation for the C-like languages
Date: Mon, 09 Nov 2015 19:05:06 +1300	[thread overview]
Message-ID: <87mvun7lnx.fsf@ap4y.me> (raw)


I'm currently maintaining smie implementation for the Swift
language. Language itself is close to the family of C-like languages
with some differences to the language constructions. I'm looking for
some advice about applying smie to the languages that use braces as a
terminators for the code blocks.

1. As stated in documentation tokens that are defined in syntax table
don't have to be tokenised in lexer. I tried to go this way, but
encountered situations where defined grammars are not respected. It
seems that smie only tries to indent closer token with respect to the
opener, rather than parent token defined by grammar. As far as I
understand (after checking source code for
smie-indent-forward/backward-token) this is expected behavior. So I
decided to tokenise braces in lexer and it works for most of the cases,
but I encountered issues with paren blinking: in some situations
blinking fails with "Mismatched parenthesis". During some tests I
decided to change lexer rules for braces to return begin/end tokens
instead of braces. I noticed that smie still tries to indent "}" token
in some situations, specifically `:close-all . "}"`. This seem to be
related to blinking  problem during blinking we have. So my question is
what will be the semantically correct way of handling braces for the C-like
languages? And secondary question is it expected that smie tries to
indent tokens that are not returned by lexer?

2. As a sort of continuation of the previous problem, we are having
problem understanding what will be semantically correct way of defining
`sexp` for the smie based mode. At the moment we see a different
behavior between non-smie c++ mode (which is close to the Swift)
and something like ruby-mode. One of the contributers summarised
differences in this post
https://github.com/chrisbarrett/swift-mode/pull/117#issuecomment-154753070.
I personally think grammar based sexp provided by smie are extremely
useful, but they yield confusing results when it comes to blinking
parens. For example grammar for "if" from here:
https://github.com/chrisbarrett/swift-mode/blob/simplify_smie/swift-mode.el#L74-L129
works well for indentation and movements, but blinking on the close
("}") returns "if" token. So the question is it a right approach to use
braces as a tokens for the grammars for C-like languages or there is a
better way to support blinking and grammars at the same time?

Thank you,
Arthur



             reply	other threads:[~2015-11-09  6:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-09  6:05 Arthur Evstifeev [this message]
2015-11-09 15:23 ` SMIE implementation for the C-like languages Stefan Monnier
2015-11-10  3:25   ` Arthur Evstifeev
2015-11-10  4:12     ` Stefan Monnier
2015-11-11  1:12       ` Arthur Evstifeev
2015-11-11 14:17         ` Stefan Monnier
2015-11-13  2:10           ` Arthur Evstifeev
2015-11-18 23:14             ` Markus Triska
2015-11-19  3:00               ` Stefan Monnier
2015-11-11 15:59     ` 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=87mvun7lnx.fsf@ap4y.me \
    --to=mail@ap4y.me \
    --cc=emacs-devel@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.