Emacs ada-mode homepage
- My latest version.
- Ada examples from the current Ada mode manual.
- The current Ada mode manual. The distribution contains this and an Emacs info version.
- My current patches to Ada mode; open for discussion about including in Emacs distribution.
- My bindings, settings, and hooks for using Ada mode; provided as an example.
- Utilities for automatically fixing errors reported by the gnat compiler; proposed addition to Ada mode.
I'm working on two new indentation/navigation engines; one based on
SMIE, the other on wisi. At the same time, I'm rewriting all of Ada
mode, to make everything more structured, and take full advantage of
the new indentation/navigation engines. Similarly for gpr mode.
SMIE uses an operator precendence parser. That is useful because it
can be run backwards, so we can find the statement start from any
point in the statement, using only local parsing. On the other hand,
it requires writing lots of language-specific code to refine the Ada
keywords into SMIE keywords that are unique. In effect, a lot of the
knowlege of the language grammar is embedded in the refining code.
The ada-smie indentation and navigation engine is working better
than ada-mode 4.0, so I'm declaring it ready for release. However,
there are still some indentation and navigation bugs (to be fixed in
ada-wisi), and there is still work to do on other parts of ada-mode.
Wisi uses a generalized LALR(1) parser, which requires parsing from
the start of the text. On the other hand, it allows embedding much
more information in the grammar, by specifying indentation information
to cache at each found keyword in the grammar actions. The only code
to write is then the indentation rules that use that cached
information; much simpler code than in the SMIE case. That will
make it easier to maintain in the future.
On the gripping hand, LALR grammars are finicky to write. In
particular, the Ada grammar presented in ARM Annex P is not
LALR(1); when compiled by the wisent grammar compiler, it reports many
shift/reduce and reduce/reduce conflicts. Some of the conflicts can be
eliminated by simple rewriting, but some cannot. So I've written a
generalized LALR(1) parser; it resolves the conflicts at parse time by
spawning another parser, and following both of the paths in the
confict, until one encounters an error. I also extended the OpenToken
grammar compiler to represent the conflict in the parser table , and
output a suitable Elisp source file. As a side benefit, OpenToken can
now generate Ada code (as well as Elisp code) from Bison style input
format. I also fixed two subtle bugs in OpenToken (that each took me a
month to find).
An important issue that I have not fully explored for the LALR
parser yet is how it will behave when it encounters invalid syntax,
which will occur while writing code. So far, the SMIE parser is quite
tolerant of invalid syntax, although it did require adding some error
handling code. I've also added some simple error handling code to the
generalized LALR parser, and it handles some of the tests.
I've implemented gpr-wisi, an indentation/navigation engine for
gpr-mode. The gpr grammar is far simpler than the Ada grammar, so it
does not have any conflict problems. The rest of gpr-mode is very
simple, so it is ready for release.
I've made a good start on ada-wisi, which will replace ada-smie (it
already indents conditional expressions better). It passes several of
the Ada indentation tests.
Things to do
Significant things left to implement, in priority order.
notes.text in the source code has more detailed info on these.
- automatically fix compiler errors - infrastructure there, slowly adding error messages (on-going)
- ada-wisi; generalized LALR(1) parser based indentation engine for Ada; in progress
- gnatprep symbols (already handles #if, needs $foo)
- mouse support
- context menus
- project files on Ada menu
- comp_cmd, make_cmd in project files
- update user manual
- improve ada-make-subrogram-body location algorithm
- ada-align-paramlist handle comments?
- ada-align-paramlist handle line wrap?
These are just zipped source files posted here when I feel like
I've reached a significant milestone. The
ada-france monotone repository has up-to-date code.
Unless otherwise noted, tested on:
- Emacs 24.3
- GNAT 7.1.1
- GNAT GPL 2012
- Debian testing
See below for installation instructions for GNAT GPL 2012 on
- Fixed several bugs in OpenToken related to handling empty
productions. All OpenToken test pass with GNAT 7.1.1, GNAT GPL 2012.
- Fixed a major bug in the wisi generalized parser; the pending
actions list was built in reverse order, and had the wrong structure for apply.
- Add more Ada grammar; more Ada indentation tests passing.
- Added workarounds in OpenToken for GNAT GPL 2012, fixed build
process for Debian testing. many OpenToken tests fail with GNAT
GPL 2012, but wisi-generate works, which is enough for Emacs Ada
- The structure stored in wisi cache text properties is
changed; it now stores both the token and the nonterminal
symbol (if any). This simplifies some of the indentation
- ada-wisi is now using the wisi parser, and passes more tests.
OpenToken is used as the grammar compiler; it can now read a Bison
style input file, and generate Elisp source code. Other stuff:
- ada-adjust-case-identifier enforces lowercase
- fixed align of 'at' in record representation clauses.
- more error messages handled in ada-gnat-fix-error
- ada-gnat-fix-error prompts user for alternate fixes to "is not visible" and "possible misspelling".
- ada-gnat-compilation-filter handles two secondary refs on one line.
- misc other bugs
- gpr-mode is finished, using the wisent parser. ada-wisi started,
handles ada_mode-generic_package.ads, some other test code. Got far
enough to know it will definitely be easier to maintain than
ada-smie. Other stuff:
- ada-fix-error is now an alist of hooks, so the user can
add local fixing functions.
- Added ada-show-references, to find all references to a
- test/Makefile moved to build/smie/Makefile, added build/wisi/Makefile
- better add-log integration for ada-mode
- fixed a bug in the wisent grammar compiler (the curse of
free software; you can fix it, and you have to fix it!)
- Started working on gpr-mode, using the wisent parser. There's
nothing in org.emacs.ada-mode yet, just stuff in
org.opentoken.stephe. I'm using Ada mode 5.0 to write the Ada code
to read a Bison input file and output OpenToken source code that
then outputs elisp for the parser tables. In the process, found and
fixed many Ada mode 5.0 bugs/missing features:
- Fixed bugs in ada-align, ada-find-other-file, ada-case-adjust, nested aggregates.
- Add ada-fix-error infrastructure, and several messages
(all that were handled in 4.01 need minor fixing for 5.0).
- Handle secondary file references in GNAT compiler messages (ada-show-secondary-error)
- improve ada-format-paramlist; handles in | out | in out | [not null] access [constant | protected]
- handle Ada quantified expressions. The only remaining 2012 syntax is aspects.
- Add ada-make-subprogram-body, ada-make-package-body
- Add ada-next/prev-statement-keyword; moves from 'if' to
'then' to 'else', or 'procedure' to 'is' to 'begin' etc.
- Ported back to Emacs 23.4; I'm using 24.3 pretests for development.
- Implemented project files, ada-goto-declaration, automatic
casing, format parameter list. New option ada-indent-comment-col-0.
Handle uppercase keywords. Fixed several bugs.
I've started using this for editing real Ada code. It's useable,
but there is a lot missing. Top on list is automatically fixing
compiler errors; it's amazing how much I miss that :).
- Tested against my GDS code, fixed all bugs found by that. See
test/test-indent-5.0.sh to run an indentation test on your code. For example, I run this as:
./test-indent-5.0.sh $GDS_ROOT/main_lynx_5/common/spacewire /tmp/gds_indent
And then review the results with the Emacs command
I found that a lot of my code did not follow Ada mode 4.01
indentation. In addition, I found several more bugs in Ada mode
4.01, that are fixed in Ada mode 5.0. So Ada mode 5.0 is not
strictly backward-compatible with Ada mode 4.01 for indentation, but
it is mostly compatible.
- Another significant clean up. Block and loop labels respect
ada-indent-label, comments meet ada-mode 4.01, cache bugs fixed.
- Significant clean up. Block statements, if statements now working.
- I've made a lot of progress in learning how SMIE works, and how
best to use it for Ada code. I've got a design that I believe is
stable; lately I've been tweaking and adding new syntax, rather
than redesigning every time I add something. Several of the
indentation test files pass!
So if other people are willing to help, now would be a good time
to start reading the code, and adding the missing features.
- I've played with Emacs SMIE (Simple Minded Indentation Engine,
((info "(elisp)SMIE Grammar"),
SMIE chapter in elisp manual)) for a few days, and it looks
I've stripped out most of the extended features of ada-mode,
and implemented a small subset of the final parser. I'm working
my way thru the indentation tests I have for ada-mode 4.01; so
far the first subtest almost passes (a protected type
declaration, in test/ada-mode.adb) :).
Install GNAT GPL 2012 on Debian
- Download GNAT GPL 2012
- cd ~
- tar zxf gnat-gpl-2012-i686-gnu-linux-libc2.3-bin.tar.gz
- cd gnat-2012-i686-gnu-linux-libc2.3-bin
I recommend installing to /opt/gnat/gpl-2012/.
- In ~/.bash_profile or similar, add:
There are several branches:
- Ada mode 5.0, with smie and wisi indentation engines for Ada, and a wisi
indentation engine for gpr.
- OpenToken extended to produce Elisp source for generalized LALR(1) parser, used by wisi
- Emacs DVC, a front end to several distributed control systems,
including monotone. See my introduction to
monotone with DVC
You can access ada-france read-only, or read-write. These commands
work with mtn 0.48 .. 1.0; you can use the equivalent URL in 1.0:
- anonymous (read only) access
mtn --db ~/monotone-dbs/ada-france.db db init
mtn --db ~/monotone-dbs/ada-france.db --key '' pull www.ada-france.org "org.emacs.*"
- read/write access requires a public key
- send output of 'mtn pubkey' to Ludovic Brenta ludovic at
ludovic dash brenta dot org
- He will add it to the appropriate structures (but he's busy,
and this is low priority, so please be patient).
- mtn --db ~/monotone-dbs/ada-france.db sync www.ada-france.org "org.emacs.*"
- If you are using DVC:
- mtn --db ~/monotone-dbs/ada-france.db automate sync --ticker=count "mtn://www.ada-france.org?org.emacs.*" >> ~/.dvc/sync.basic_io
mailing list, bugs
Subscribe to the Emacs
ada-mode mailing list
Please report bugs both here and to the Emacs bug list.
Put Package: emacs, ada-mode as the first line of the bug message.
my home page
Author : Stephen Leake
Last modified: Sun Feb 17 07:02:04 EST 2013