Georg Bauhaus <[email protected]> writes: > Am 24.07.2014 um 23:34 schrieb Stephen Leake <[email protected]>: > >> I won't spend too much time on this, if it proves complicated. Better >> to work on an FFI for Emacs, and then the Ada mode parser in Ada. Or on >> a parser in a separate process, as a first step. > > Regarding performance, maybe there is a comparatively simple > approach to handling large files with what we've got: > > The ingredients would be: > > 1 something alongside Emacs's paging mechanism, with a dedicated > "mini" parser that just divides the text into Ada compatible > pieces, by finding the (analogs of) page delimiters (no Ada > parsing required for the latter function). > > 2 a notion of parsing unit, so that the parser needs not > handle all of the file in the buffer, but can work withing > a "page". > > 3 file local variables for turning on the mechanism > > A (rare?) problem with 1 could be huge nested subprograms > that cannot suitably be divided.
It turns out that _no_ Ada compilation unit can be divided, at least if we keep all of the current indentation rules. That's why the simpler parser supported by SMIE was not successful for ada-mode. Since GNAT requires one compilation unit per file, there is nothing to be gained by this approach. A different approach that does hold promise is error recovery and partial parsing. The GPS parser apparently does this; it handles bad syntax nicely, and will stop parsing when it gets to the line being indented. Both of these methods require completing the currently open grammar sentences to finish the parse. Computing the shortest completion from any state is possible at grammar generation time; I have not seen an algorithm for that, but it seems straightforward. The GPS parser is hand-coded recursive descent, which makes error recovery simpler. I'm waiting until we get Emacs FFI working to implement this, since I don't want to write the error recovery in elisp. There are two styles of FFI currently under consideration, both with proof-of-concept implementations. So this might be available in the first Emacs 25 release. > But still, indentation could > be turned of with 3 if that's machine generated code, say, > that is not usually edited by humans. Yes. ada-mode 5.1.7/wisi 1.1.0 has `wisi-font-lock-size-threshold'; if a file character count is larger than that, no parsing is done for font-lock (ie syntax colorization). My development head renames that to `wisi-size-threshold', and does no parsing for ada-find-other-file as well. So just visiting a large file is not painful, but editing it still is. That could be extended to disable _all_ parsing, which would also disable indentation. -- -- Stephe _______________________________________________ Emacs-ada-mode mailing list [email protected] http://host114.hostmonster.com/mailman/listinfo/emacs-ada-mode_stephe-leake.org
