all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Subject: Re: good "modern" example code for a programming-language mode?
Date: Wed, 16 Feb 2011 16:07:53 -0500	[thread overview]
Message-ID: <jwvpqqrhew0.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87oc6b29xa.fsf@engster.org> (David Engster's message of "Wed, 16 Feb 2011 17:58:41 +0100")

>> OTOH there is a clear connection between syntax and indentation.
> Yes, there is a connection, but it's only covering a certain amount of
> indentation cases, depending on the language. Let's take comments, for
> example. Just looking at the doc-string from c-lineup-C-comments, I
> wonder what a grammar could help you here?  Or indenting continuation
> lines; at least in Semantic those are usually dealt with in the lexer,
> so the grammar doesn't even "see" those. In the end, you're still
> looking around with some regexps to see where you're at.

Of course.  Note that the grammar does not have to be the same as the
one used by the compiler, so it may make continuation-line markers and
comments "visible" (tho it'd probably be difficult since those can
typically appear anywhere).

> This is really interesting. So you're generating something like
> c-offsets-alist from a grammar?

Kind of.

> C-like languages are an extreme case, for sure. I'm not saying a
> semantic analysis won't help. It is absolutely possible to use Semantic
> as an aid for indentation or highlighting (I use it for that in
> minimap.el, for example). I just wanted to make clear that it's not
> possible to base font-locking or indentation solely on Semantic, mainly
> because it doesn't parse the whole buffer (usually not even close).

Agreed.  Most of the issue is that Semantic is designed for other tasks,
so it made different trade-offs.  E.g. using it for font-lock could
prove problematic since the parser would then have to be run much
more eagerly.


        Stefan



  reply	other threads:[~2011-02-16 21:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-15  9:11 good "modern" example code for a programming-language mode? Miles Bader
2011-02-15 17:43 ` Stefan Monnier
2011-02-16  5:16   ` Miles Bader
2011-02-15 22:22 ` Michael Welsh Duggan
2011-02-16  0:47   ` Miles Bader
2011-02-16 10:19     ` David Engster
2011-02-16 13:59       ` Andy Moreton
2011-02-16 15:00         ` David Kastrup
2011-02-16 14:56       ` Stefan Monnier
2011-02-16 15:54         ` Tassilo Horn
2011-02-16 21:00           ` Stefan Monnier
2011-02-16 16:58         ` David Engster
2011-02-16 21:07           ` Stefan Monnier [this message]
2011-02-17  3:42       ` Miles Bader

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=jwvpqqrhew0.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    /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.