unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Nikolay Kudryavtsev <nikolay.kudryavtsev@gmail.com>
Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: Re: SMIE grammar for C-style function expressions
Date: Mon, 27 Sep 2021 22:34:36 -0400	[thread overview]
Message-ID: <jwvbl4dzb85.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <8c6fc2a9-1086-c026-459d-1e703563ae1d@gmail.com> (Nikolay Kudryavtsev's message of "Mon, 27 Sep 2021 17:39:47 +0300")

> With this in mind, I still have a very basic case that I don't think I 100%
> grok, so I've decided to ask here. The case is this: what's the proper way
> to describe SMIE grammar for C-style functions? I remember Stefan talking
> that he has a prototype SMIE C implementation, but I don't think he ever
> published it.
>
> To explain, a C-style function definition grammar looks something like this:
>
> f n ( a ) { s }

Could you clarify what you mean by "describe"?

SMIE does not concern itself with trying to detect syntax errors, so
nothing of the above seems hard at all: it should "just work" without
any special effort (just make sure SMIE knows that "(" matches ")" and
"{" matches "}" and that's it).

[ I'd expect more difficulty when you consider sequences of such
declarations, as in:

    f n1 ( a1 ) { s1 }
    f n2 ( a2 ) { s2 }

where there's no clear separator.  In such cases the better option
usually involves treating `f` as an infix separator (rather than
a prefix).  ]

Maybe the problem you're seeing has to do with having specific
indentation rules inside the `s` part, maybe?  If so, the problem is
better solved in the SMIE indentation rules than in the SMIE grammar.


        Stefan




  parent reply	other threads:[~2021-09-28  2:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-27 14:39 SMIE grammar for C-style function expressions Nikolay Kudryavtsev
2021-09-27 18:41 ` Filipp Gunbin
2021-09-27 19:36   ` Nikolay Kudryavtsev
2021-09-28  2:34 ` Stefan Monnier [this message]
2021-09-28 11:47   ` Nikolay Kudryavtsev
2021-09-28 13:07     ` Stefan Monnier
2021-09-28 18:12       ` Nikolay Kudryavtsev
2021-09-28 18:45         ` 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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvbl4dzb85.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=help-gnu-emacs@gnu.org \
    --cc=nikolay.kudryavtsev@gmail.com \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).