emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: good "modern" example code for a programming-language mode?


From: Stefan Monnier
Subject: Re: good "modern" example code for a programming-language mode?
Date: Wed, 16 Feb 2011 16:07:53 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

>> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]