From: Stephen Leake <stephen_leake@stephe-leake.org>
To: emacs-devel <emacs-devel@gnu.org>
Subject: Re: A possible way for CC Mode to resolve its sluggishness
Date: Sun, 28 Apr 2019 09:32:25 -0800 [thread overview]
Message-ID: <86y33u6no6.fsf@stephe-leake.org> (raw)
In-Reply-To: <20190427135725.GB4822@ACM> (Alan Mackenzie's message of "Sat, 27 Apr 2019 13:57:25 +0000")
Alan Mackenzie <acm@muc.de> writes:
>> Maybe if we want to speed things up, we should consider a new parsing
>> engine (instead of parse-partial-sexp and syntax-tables) based maybe on
>> a DFA for the tokenizer and GLR parser on top. That might arguably be
>> more generally useful and easier to use (in the sense that one can more
>> or less follow the language spec when implementing the major mode).
>
> That would be a lot of design and a lot of work, and sounds like
> something from the distant rather than medium future.
ada-mode uses just that approach; the WisiToken parser generator reads a
bison-like description of the grammar, and generates a lexer and
error-correcting parser. Those run in an Emacs background process,
which also runs other code to process the AST and produce font and
indent info, which is sent back to Emacs.
It works very well for Ada code, and I've got a very preliminary version
working with Java. See http://www.nongnu.org/ada-mode/ for the latest
release.
C++ is definitely more of a challenge; you need to run the preprocessor,
at least. In another post Oscar says you would need a full C++
front-end; I can believe that. Still, the approach is similar; run the
C++ front-end (maybe the clang one?) in a background process, together
with code that computes the info needed by Emacs.
One possible problem is that the parser needs to handle huge syntax
errors; it will be called to compute indent when the user has entered a
partial statement and hit return. I don't know how good clang is with
error correction; I spent a lot of time making the WisiToken parser
handle such errors well.
> The indentation and font-lock routines would have to be rewritten
> for each mode using it.
Yes; I had to translate the elisp into Ada. Currently, I'm maintaining
both (to support people who don't want to or can't compile the
background process code), but at some point I'll probably drop the
elisp.
It is a huge redesign and implementation effort. I started this for Ada
in 2013 when it became clear that the earlier ad-hoc approach could not
handle Ada 95 and 2012 syntax, and it took several years (with several
detours along the way; Java will take much less time). I'm almost at the
point where I can delete the old ad-hoc ada-mode code from Emacs core.
--
-- Stephe
next prev parent reply other threads:[~2019-04-28 17:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-26 19:30 A possible way for CC Mode to resolve its sluggishness Alan Mackenzie
2019-04-26 19:53 ` Eli Zaretskii
2019-04-26 20:11 ` Alan Mackenzie
2019-04-27 2:10 ` Stefan Monnier
2019-04-27 3:34 ` Óscar Fuentes
2019-04-27 13:57 ` Alan Mackenzie
2019-04-28 17:32 ` Stephen Leake [this message]
2019-04-29 1:46 ` Stefan Monnier
2019-04-29 9:23 ` Alan Mackenzie
2019-04-29 12:19 ` 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=86y33u6no6.fsf@stephe-leake.org \
--to=stephen_leake@stephe-leake.org \
--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.