Stephen Leake <[email protected]> writes:

> I'm working on using the GPS indentation engine directly as a back-end
> for Emacs ada-mode.

The first version of this is ready for beta-testers (easier than I
thought :).

Some timing info:

using GNAT-gpl_2014/gnatcoll-1.7w-src/src/sqlite/gnatcoll-xref.adb
(7081 lines, 241060 chars) as a test file.

wisi timing:
(progn
    (ada-wisi-setup)
    (wisi-invalidate-cache)
    (time-it (lambda () (indent-region (point-min) (point-max))) 1))
    2.062000

(time-it (lambda () (indent-region (point-min) (point-max))) 1)
    0.531000

(progn
    (goto-char (point-max))
    (forward-line -3)
    (time-it 'indent-according-to-mode 10))
    0.001 seconds

ada-gps timing:
(time-it (lambda () (indent-region (point-min) (point-max))) 1)
    ~700 seconds? (I didn't actually wait for it)

(progn
    (goto-char (point-max))
    (forward-line -3)
    (time-it 'indent-according-to-mode 10))
    Total 1.857000 seconds; per iteration 0.185700


So after parsing, ada-wisi is faster at indenting single lines. And on
large files, ada-wisi is _much_ faster at indenting the whole file (it
only parses once; ada-gps parses the file to each line to indent each
line). But ada-gps is more useable for indenting large files after
editing.

In addition, ada-gps handles bad syntax _much_ more nicely (there must
be good error recovery in that parser).

Therefore the 'ada-gps' indentation engine uses ada-wisi for small
files, and ada-gps for large files. "large" is defined by
ada-gps-size-threshold; file size in chars.

Note that ada-gps does _not_ support the following ada-mode features,
because they all rely on the text properties set by the ada-wisi parser:

ada-fix-context-clause
ada-goto-declaration-start
ada-goto-declaration-end
ada-goto-declarative-region-start
ada-goto-end
ada-in-paramlist-p
ada-indent-statement
ada-make-subprogram-body
ada-next-statement-keyword
ada-prev-statement-keyword
ada-scan-paramlist
ada-which-function

It is possible to get additional semantic information out of the GPS
parser, so it might be possible to support at least some of this in this
mode. But that would _not_ be compatible with any of the code written
for ada-wisi, so it's a lot of work. I'll work on implementing the
ada-wisi parser in OpenToken Ada first, to see how fast that is.


I'm currently running all my indentation tests using ada-gps for all
files. So far I've identified some outright bugs in GPS; I'll be
reporting them to AdaCore (with "use Emacs ada-mode 5.0" as the
workaround :). I'll report other discrepancies here, to ask whether it
is worth changing ada-wisi to match.

I am _not_ signing up to fix indentation bugs in the GPS code!


To use ada-gps:

Get the source from ada-france monotone (see
http://stephe-leake.org/emacs/ada-mode/emacs-ada-mode.html#ada-france)
branch org.emacs.ada-mode.stephe-2

See ada-mode.texi node Install | ada_mode_gps_indent to compile some Ada
code.

Add (require 'ada-gps) to your ~/.emacs
 

Let me know how it goes!

-- 
-- Stephe

_______________________________________________
Emacs-ada-mode mailing list
[email protected]
http://host114.hostmonster.com/mailman/listinfo/emacs-ada-mode_stephe-leake.org

Reply via email to