[Top][All Lists]

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

Re: Emacs contributions, C and Lisp

From: Stephen Leake
Subject: Re: Emacs contributions, C and Lisp
Date: Tue, 25 Feb 2014 15:15:44 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (windows-nt)

Eli Zaretskii <address@hidden> writes:

>> From: David Kastrup <address@hidden>
>> Date: Tue, 25 Feb 2014 10:41:42 +0100
>> The "annotated syntax tree" question would become more relevant for
>> things like sourcecode highlighting.  But in the interest of usefully
>> fast feedback when editing, it would likely make more sense to let Emacs
>> do the highlighting with local rules on its own and only converse with
>> GCC when it becomes necessary to resolve ambiguities (like
>> declaration/expression distinctions): GCC can only make helpful
>> suggestions regarding the last time the source code was syntactically
>> correct, so most of the time Emacs will need to go ahead with _some_
>> idea anyway.
> Is it certain that we actually need a compiler for that?  Did someone
> investigate whether CEDET infrastructure is capable of doing something
> like that?  

I recently rewrote the Ada indentation engine, and tried to use the CEDET
infrastructure. It was not adequate, so I ended up writing a full parser
(it is similar to but more powerful than the CEDET lexer/parser).

Even so, I don't use that for completion, especially when looking for
the parameters of functions. As I pointed out in another email, AdaCore
provides 'gcc -fdump-xref', which dumps all the information needed for
that, and a tool 'gnatinspect' that interfaces nicely with Emacs to
retrieve it. I have not fully implemented completion in Emacs using
that, but AdaCore has in their editor GPS, so I know it's possible :).

> Since, as you point out, a compiler will probably choke on
> syntactically incorrect input, shouldn't we try to look elsewhere?

The current hippie-expand mechanisms offer completion on identifiers in
current buffers; beyond that, I don't see any solution other than to
rely on compiled code for completion, especially of parameters of functions.

> After all, we don't need to parse the source completely, only as much
> as needed for completion.

That's the same thing, as far as I can tell. You need even less info for
indentation, but I ended up needing a full file parse for that.

Actually, only a full "compilation unit" parse; in Ada that is normally
a full file. In C++ it would be a class or function definition. Still a
complete language parser.

-- Stephe

reply via email to

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