]> code.delx.au - gnu-emacs-elpa/blob - packages/ada-mode/ada-gnat-compile.el
Fix some quoting problems in doc strings
[gnu-emacs-elpa] / packages / ada-mode / ada-gnat-compile.el
1 ;; ada-gnat-compile.el --- Ada mode compiling functionality provided by 'gnat' -*- lexical-binding:t -*-
2 ;; Includes related functions, such as gnatprep support.
3 ;;
4 ;; These tools are all Ada-specific; use Makefiles for multi-language
5 ;; GNAT compilation tools.
6 ;;
7 ;; GNAT is provided by AdaCore; see http://libre.adacore.com/
8 ;;
9 ;;; Copyright (C) 2012 - 2015 Free Software Foundation, Inc.
10 ;;
11 ;; Author: Stephen Leake <stephen_leake@member.fsf.org>
12 ;; Maintainer: Stephen Leake <stephen_leake@member.fsf.org>
13 ;;
14 ;; This file is part of GNU Emacs.
15 ;;
16 ;; GNU Emacs is free software: you can redistribute it and/or modify
17 ;; it under the terms of the GNU General Public License as published by
18 ;; the Free Software Foundation, either version 3 of the License, or
19 ;; (at your option) any later version.
20 ;;
21 ;; GNU Emacs is distributed in the hope that it will be useful,
22 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;; GNU General Public License for more details.
25 ;;
26 ;; You should have received a copy of the GNU General Public License
27 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
28 ;;
29 ;;; Usage:
30 ;;
31 ;; Emacs should enter Ada mode automatically when you load an Ada
32 ;; file, based on the file extension.
33 ;;
34 ;; By default, ada-mode is configured to load this file, so nothing
35 ;; special needs to done to use it.
36
37 (require 'compile)
38 (require 'gnat-core)
39
40 ;;;;; code
41
42 ;;;; compiler message handling
43
44 (defun ada-gnat-compilation-filter ()
45 "Filter to add text properties to secondary file references.
46 For `compilation-filter-hook'."
47 (save-excursion
48 (goto-char compilation-filter-start)
49
50 ;; primary references are handled by font-lock functions; see
51 ;; `compilation-mode-font-lock-keywords'.
52 ;;
53 ;; compilation-filter might insert partial lines, or it might insert multiple lines
54 (goto-char (line-beginning-position))
55 (while (not (eobp))
56 ;; We don't want 'next-error' to always go to secondary
57 ;; references, so we _don't_ set 'compilation-message text
58 ;; property. Instead, we set 'ada-secondary-error, so
59 ;; `ada-goto-secondary-error' will handle it. We also set
60 ;; fonts, so the user can see the reference.
61
62 ;; typical secondary references look like:
63 ;;
64 ;; trivial_productions_test.adb:57:77: ==> in call to "Get" at \
65 ;; opentoken-token-enumerated-analyzer.ads:88, instance at line 41
66 ;;
67 ;; c:/foo/bar/lookahead_test.adb:379:14: found type access to "Standard.String" defined at line 379
68 ;;
69 ;; lookahead_test.ads:23:09: "Name" has been inherited from subprogram at aunit-simple_test_cases.ads:47
70 ;;
71 ;; lalr.adb:668:37: non-visible declaration at analyzer.ads:60, instance at parser.ads:38
72 ;;
73 ;; save the file from the primary reference, look for "*.ad?:nn", "at line nnn"
74
75 (let (file)
76 (when (looking-at "^\\(\\(.:\\)?[^ :\n]+\\):")
77 (setq file (match-string-no-properties 1)))
78
79 (skip-syntax-forward "^-"); space following primary reference
80
81 (while (search-forward-regexp "\\s-\\(\\([^[:blank:]]+\\.[[:alpha:]]+\\):\\([0-9]+\\)\\)"
82 (line-end-position) t)
83
84 (goto-char (match-end 0))
85 (with-silent-modifications
86 (compilation--put-prop 2 'font-lock-face compilation-info-face); file
87 (compilation--put-prop 3 'font-lock-face compilation-line-face); line
88 (put-text-property
89 (match-beginning 0) (match-end 0)
90 'ada-secondary-error
91 (list
92 (match-string-no-properties 2); file
93 (string-to-number (match-string-no-properties 3)); line
94 1)); column
95 ))
96
97 (when (search-forward-regexp "\\(at line \\)\\([0-9]+\\)" (line-end-position) t)
98 (with-silent-modifications
99 (compilation--put-prop 1 'font-lock-face compilation-info-face); "at line" instead of file
100 (compilation--put-prop 2 'font-lock-face compilation-line-face); line
101 (put-text-property
102 (match-beginning 1) (match-end 1)
103 'ada-secondary-error
104 (list
105 file
106 (string-to-number (match-string-no-properties 2)); line
107 1)); column
108 ))
109 (forward-line 1))
110 )
111 ))
112
113 (defun ada-gnat-debug-filter ()
114 ;; call ada-gnat-compilation-filter with `compilation-filter-start' bound
115 (interactive)
116 (beginning-of-line)
117 (let ((compilation-filter-start (point)))
118 (ada-gnat-compilation-filter)))
119
120 ;;;;; auto fix compilation errors
121
122 (defconst ada-gnat-quoted-name-regexp
123 "\"\\([a-zA-Z0-9_.']+\\)\""
124 "regexp to extract the quoted names in error messages")
125
126 (defconst ada-gnat-quoted-punctuation-regexp
127 "\"\\([,:;=()|]+\\)\""
128 "regexp to extract quoted punctuation in error messages")
129
130 (defvar ada-gnat-fix-error-hook nil
131 "For `ada-fix-error-alist'.")
132
133 (defun ada-gnat-misspelling ()
134 "Return correct spelling from current compiler error, if there are corrections offered.
135 Prompt user if more than one."
136 ;; wisi-output.adb:115:41: no selector "Productions" for type "RHS_Type" defined at wisi.ads:77
137 ;; wisi-output.adb:115:41: invalid expression in loop iterator
138 ;; wisi-output.adb:115:42: possible misspelling of "Production"
139 ;; wisi-output.adb:115:42: possible misspelling of "Production"
140 ;;
141 ;; column number can vary, so only check the line number
142
143 (let ((line (progn (beginning-of-line) (nth 1 (compilation--message->loc (ada-get-compilation-message)))))
144 done choices)
145 (while (not done)
146 (forward-line 1)
147 (setq done (or (not (ada-get-compilation-message))
148 (not (equal line (nth 1 (compilation--message->loc (ada-get-compilation-message)))))))
149 (when (and (not done)
150 (progn
151 (skip-syntax-forward "^-")
152 (forward-char 1)
153 (looking-at (concat "possible misspelling of " ada-gnat-quoted-name-regexp))))
154 (push (match-string 1) choices)))
155
156 ;; return correct spelling
157 (cond
158 ((= 0 (length choices))
159 nil)
160
161 ((= 1 (length choices))
162 (car choices))
163
164 (t ;; multiple choices
165 (completing-read "correct spelling: " choices))
166 )))
167
168 (defun ada-gnat-fix-error (_msg source-buffer _source-window)
169 "For `ada-gnat-fix-error-hook'."
170 (let ((start-pos (point))
171 message-column
172 result)
173 ;; Move to start of error message text
174 (skip-syntax-forward "^-")
175 (forward-char 1)
176 (setq message-column (current-column))
177
178 ;; recognize it, handle it
179 (setq
180 result
181 (unwind-protect
182 (cond
183 ;; It is tempting to define an alist of (MATCH . ACTION), but
184 ;; that is too hard to debug
185 ;;
186 ;; This list will get long, so let's impose some order.
187 ;;
188 ;; First expressions that start with a named regexp, alphabetical by variable name.
189 ;;
190 ;; Then expressions that start with a string, alphabetical by string.
191 ;;
192 ;; Then style errors.
193
194 ((looking-at (concat ada-gnat-quoted-name-regexp " is not visible"))
195 (let ((done nil)
196 (file-line-struct (progn (beginning-of-line) (ada-get-compilation-message)))
197 pos choices unit-name)
198 ;; next line may contain a reference to where ident is
199 ;; defined; if present, it will have been marked by
200 ;; ada-gnat-compilation-filter:
201 ;;
202 ;; gnatquery.adb:255:13: "Has_Element" is not visible
203 ;; gnatquery.adb:255:13: non-visible declaration at a-convec.ads:68, instance at gnatcoll-arg_lists.ads:157
204 ;; gnatquery.adb:255:13: non-visible declaration at a-coorse.ads:62, instance at gnatcoll-xref.ads:912
205 ;; gnatquery.adb:255:13: non-visible declaration at a-coorse.ads:62, instance at gnatcoll-xref.ads:799
206 ;; gnatquery.adb:255:13: non-visible declaration at gnatcoll-xref.ads:314
207 ;;
208 ;; or the next line may contain "multiple use clauses cause hiding"
209 ;;
210 ;; the lines after that may contain alternate matches;
211 ;; collect all, let user choose.
212 (forward-line 1)
213 (unless (looking-at ".* multiple use clauses cause hiding")
214 (while (not done)
215 (let ((limit (1- (line-end-position))))
216 ;; 1- because next compilation error is at next line beginning
217 (setq done (not
218 (and
219 (equal file-line-struct (ada-get-compilation-message))
220 (setq pos (next-single-property-change (point) 'ada-secondary-error nil limit))
221 (< pos limit))))
222 (when (not done)
223 (let* ((item (get-text-property pos 'ada-secondary-error))
224 (unit-file (nth 0 item))
225 (choice (ada-ada-name-from-file-name unit-file)))
226 (unless (member choice choices) (push choice choices))
227 (goto-char (1+ pos))
228 (goto-char (1+ (next-single-property-change (point) 'ada-secondary-error nil limit)))
229 (when (eolp) (forward-line 1))
230 ))
231 )));; unless while let
232
233 (setq unit-name
234 (cond
235 ((= 0 (length choices)) nil)
236 ((= 1 (length choices)) (car choices))
237 (t ;; multiple choices
238 (completing-read "package name: " choices))))
239
240 (when unit-name
241 (pop-to-buffer source-buffer)
242 ;; We either need to add a with_clause for a package, or
243 ;; prepend the package name here (or add a use clause, but I
244 ;; don't want to do that automatically).
245 ;;
246 ;; If we need to add a with_clause, unit-name may be only
247 ;; the prefix of the real package name, but in that case
248 ;; we'll be back after the next compile; no way to get the
249 ;; full package name (without the function/type name) now.
250 ;; Note that we can't use gnat find, because the code
251 ;; doesn't compile.
252 (cond
253 ((looking-at (concat unit-name "\\."))
254 (ada-fix-add-with-clause unit-name))
255 (t
256 (ada-fix-insert-unit-name unit-name)
257 (insert ".")))
258 t) ;; success, else nil => fail
259 ))
260
261 ((or (looking-at (concat ada-gnat-quoted-name-regexp " is undefined"))
262 (looking-at (concat ada-gnat-quoted-name-regexp " is not a predefined library unit")))
263 ;; We either need to add a with_clause for a package, or
264 ;; something is spelled wrong.
265 (save-excursion
266 (let ((unit-name (match-string 1))
267 (correct-spelling (ada-gnat-misspelling)))
268 (if correct-spelling
269 (progn
270 (pop-to-buffer source-buffer)
271 (search-forward unit-name)
272 (replace-match correct-spelling))
273
274 ;; else assume missing with
275 (pop-to-buffer source-buffer)
276 (ada-fix-add-with-clause unit-name))))
277 t)
278
279 ((looking-at (concat ada-gnat-quoted-name-regexp " not declared in " ada-gnat-quoted-name-regexp))
280 (save-excursion
281 (let ((child-name (match-string 1))
282 (correct-spelling (ada-gnat-misspelling)))
283 (if correct-spelling
284 (progn
285 (setq correct-spelling (match-string 1))
286 (pop-to-buffer source-buffer)
287 (search-forward child-name)
288 (replace-match correct-spelling))
289
290 ;; else guess that "child" is a child package, and extend the with_clause
291 (pop-to-buffer source-buffer)
292 (ada-fix-extend-with-clause child-name))))
293 t)
294
295 ((looking-at (concat ada-gnat-quoted-punctuation-regexp
296 " should be "
297 ada-gnat-quoted-punctuation-regexp))
298 (let ((bad (match-string-no-properties 1))
299 (good (match-string-no-properties 2)))
300 (pop-to-buffer source-buffer)
301 (looking-at bad)
302 (delete-region (match-beginning 0) (match-end 0))
303 (insert good))
304 t)
305
306 ;;;; strings
307 ((looking-at (concat "misspelling of " ada-gnat-quoted-name-regexp))
308 (let ((expected-name (match-string 1)))
309 (pop-to-buffer source-buffer)
310 (looking-at ada-name-regexp)
311 (delete-region (match-beginning 1) (match-end 1))
312 (insert expected-name))
313 t)
314
315 ((looking-at (concat "\"end " ada-name-regexp ";\" expected"))
316 (let ((expected-name (match-string 1)))
317 (pop-to-buffer source-buffer)
318 (if (looking-at (concat "end " ada-name-regexp ";"))
319 (progn
320 (goto-char (match-end 1)) ; just before ';'
321 (delete-region (match-beginning 1) (match-end 1)))
322 ;; else we have just 'end;'
323 (forward-word 1)
324 (insert " "))
325 (insert expected-name))
326 t)
327
328 ((looking-at (concat "\"end loop " ada-name-regexp ";\" expected"))
329 (let ((expected-name (match-string 1)))
330 (pop-to-buffer source-buffer)
331 (if (looking-at (concat "end loop " ada-name-regexp ";"))
332 (progn
333 (goto-char (match-end 1)) ; just before ';'
334 (delete-region (match-beginning 1) (match-end 1)))
335 ;; else we have just 'end loop;'
336 (forward-word 2)
337 (insert " "))
338 (insert expected-name))
339 t)
340
341 ((looking-at "expected an access type")
342 (progn
343 (set-buffer source-buffer)
344 (backward-char 1)
345 (when (looking-at "\\.all")
346 (delete-char 4)
347 t)))
348
349 ((looking-at (concat "expected \\(private \\)?type " ada-gnat-quoted-name-regexp))
350 (forward-line 1)
351 (move-to-column message-column)
352 (cond
353 ((looking-at "found type access")
354 (pop-to-buffer source-buffer)
355 (if (looking-at "'Access")
356 (kill-word 1)
357 (forward-word 1)
358 (insert ".all"))
359 t)
360 ((looking-at "found type .*_Access_Type")
361 ;; assume just need '.all'
362 (pop-to-buffer source-buffer)
363 (forward-word 1)
364 (insert ".all")
365 t)
366 ))
367
368 ((looking-at "extra \".\" ignored")
369 (set-buffer source-buffer)
370 (delete-char 1)
371 t)
372
373 ((looking-at (concat "keyword " ada-gnat-quoted-name-regexp " expected here"))
374 (let ((expected-keyword (match-string 1)))
375 (pop-to-buffer source-buffer)
376 (insert " " expected-keyword))
377 t)
378
379 ((looking-at "\\(?:possible \\)?missing \"with \\([a-zA-Z0-9_.]+\\);")
380 ;; also 'possible missing "with Ada.Text_IO; use Ada.Text_IO"' - ignoring the 'use'
381 (let ((package-name (match-string-no-properties 1)))
382 (pop-to-buffer source-buffer)
383 ;; Could check if prefix is already with'd, extend
384 ;; it. But no one has reported that case yet; this
385 ;; message only occurs for predefined Ada packages.
386 (ada-fix-add-with-clause package-name))
387 t)
388
389 ;; must be after above
390 ((looking-at "missing \"\\(.+\\)\"")
391 (let ((stuff (match-string-no-properties 1)))
392 (set-buffer source-buffer)
393 (insert (concat stuff)));; if missing ")", don't need space; otherwise do?
394 t)
395
396 ((looking-at "No legal interpretation for operator")
397 (forward-line 1)
398 (move-to-column message-column)
399 (looking-at (concat "use clause on " ada-gnat-quoted-name-regexp))
400 (let ((package (match-string 1)))
401 (pop-to-buffer source-buffer)
402 (ada-fix-add-use package))
403 t)
404
405 ((looking-at (concat "no selector " ada-gnat-quoted-name-regexp))
406 ;; Check next line for spelling error.
407 (save-excursion
408 (let ((unit-name (match-string 1))
409 (correct-spelling (ada-gnat-misspelling)))
410 (when correct-spelling
411 (pop-to-buffer source-buffer)
412 (search-forward unit-name)
413 (replace-match correct-spelling)
414 t))))
415
416 ((looking-at (concat "operator for \\(private \\)?type " ada-gnat-quoted-name-regexp))
417 (let ((type (match-string 2)))
418 (pop-to-buffer source-buffer)
419 (ada-goto-declarative-region-start)
420 (newline-and-indent)
421 (insert "use type " type ";"))
422 t)
423
424 ((looking-at "parentheses required for unary minus")
425 (set-buffer source-buffer)
426 (insert "(")
427 (forward-word 1)
428 (insert ")")
429 t)
430
431 ((looking-at "prefix of dereference must be an access type")
432 (pop-to-buffer source-buffer)
433 ;; point is after '.' in '.all'
434 (delete-region (- (point) 1) (+ (point) 3))
435 t)
436
437 ;;;; warnings
438 ((looking-at (concat "warning: " ada-gnat-quoted-name-regexp " is already use-visible"))
439 ;; just delete the 'use'; assume it's on a line by itself.
440 (pop-to-buffer source-buffer)
441 (beginning-of-line)
442 (delete-region (point) (progn (forward-line 1) (point)))
443 t)
444
445 ((looking-at (concat "warning: " ada-gnat-quoted-name-regexp " is not modified, could be declared constant"))
446 (pop-to-buffer source-buffer)
447 (search-forward ":")
448 (forward-comment (- (point-max) (point)))
449 ;; "aliased" must be before "constant", so check for it
450 (when (looking-at "aliased")
451 (forward-word 1)
452 (forward-char 1))
453 (insert "constant ")
454 t)
455
456 ((looking-at (concat "warning: constant " ada-gnat-quoted-name-regexp " is not referenced"))
457 (let ((constant (match-string 1)))
458 (pop-to-buffer source-buffer)
459 (end-of-line)
460 (newline-and-indent)
461 (insert "pragma Unreferenced (" constant ");"))
462 t)
463
464 ((looking-at (concat "warning: formal parameter " ada-gnat-quoted-name-regexp " is not referenced"))
465 (let ((param (match-string 1)))
466 (pop-to-buffer source-buffer)
467 (ada-goto-declarative-region-start)
468 (newline-and-indent)
469 (insert "pragma Unreferenced (" param ");"))
470 t)
471
472 ((looking-at (concat "warning: formal parameter " ada-gnat-quoted-name-regexp " is not modified"))
473 (let ((mode-regexp "\"\\([in out]+\\)\"")
474 new-mode
475 old-mode)
476 (forward-line 1)
477 (search-forward-regexp
478 (concat "mode could be " mode-regexp " instead of " mode-regexp))
479 (setq new-mode (match-string 1))
480 (setq old-mode (match-string 2))
481 (pop-to-buffer source-buffer)
482 (search-forward old-mode)
483 (replace-match new-mode)
484 (ada-align)
485 )
486 t)
487
488 ((or
489 (looking-at (concat "warning: no entities of " ada-gnat-quoted-name-regexp " are referenced$"))
490 (looking-at (concat "warning: unit " ada-gnat-quoted-name-regexp " is never instantiated$"))
491 (looking-at "warning: redundant with clause"))
492 ;; just delete the 'with'; assume it's on a line by itself.
493 (pop-to-buffer source-buffer)
494 (beginning-of-line)
495 (delete-region (point) (progn (forward-line 1) (point)))
496 t)
497
498 ((looking-at (concat "warning: variable " ada-gnat-quoted-name-regexp " is assigned but never read"))
499 (let ((param (match-string 1)))
500 (pop-to-buffer source-buffer)
501 (ada-goto-end) ;; leaves point before semicolon
502 (forward-char 1)
503 (newline-and-indent)
504 (insert "pragma Unreferenced (" param ");"))
505 t)
506
507 ((looking-at (concat "warning: unit " ada-gnat-quoted-name-regexp " is not referenced$"))
508 ;; just delete the 'with'; assume it's on a line by itself.
509 (pop-to-buffer source-buffer)
510 (beginning-of-line)
511 (delete-region (point) (progn (forward-line 1) (point)))
512 t)
513
514 ;;;; style errors
515 ((looking-at "(style) \".*\" in wrong column")
516 (set-buffer source-buffer)
517 (funcall indent-line-function)
518 t)
519
520 ((looking-at "(style) bad capitalization, mixed case required")
521 (set-buffer source-buffer)
522 (forward-word)
523 (ada-case-adjust-identifier)
524 t)
525
526 ((looking-at (concat "(style) bad casing of " ada-gnat-quoted-name-regexp))
527 (let ((correct (match-string-no-properties 1))
528 end)
529 ;; gnat leaves point on first bad character, but we need to replace the whole word
530 (set-buffer source-buffer)
531 (skip-syntax-backward "w_")
532 (setq end (point))
533 (skip-syntax-forward "w_")
534 (delete-region (point) end)
535 (insert correct))
536 t)
537
538 ((or
539 (looking-at "(style) bad column")
540 (looking-at "(style) bad indentation")
541 (looking-at "(style) incorrect layout"))
542 (set-buffer source-buffer)
543 (funcall indent-line-function)
544 t)
545
546 ((looking-at "(style) misplaced \"then\"")
547 (set-buffer source-buffer)
548 (delete-indentation)
549 t)
550
551 ((looking-at "(style) missing \"overriding\" indicator")
552 (set-buffer source-buffer)
553 (cond
554 ((looking-at "\\(procedure\\)\\|\\(function\\)")
555 (insert "overriding ")
556 t)
557 (t
558 nil)))
559
560 ((looking-at "(style) space not allowed")
561 (set-buffer source-buffer)
562 ;; Error places point on space. More than one trailing space
563 ;; should be fixed by delete-trailing-whitespace in
564 ;; before-save-hook, once the file is modified.
565 (delete-char 1)
566 t)
567
568 ((looking-at "(style) space required")
569 (set-buffer source-buffer)
570 (insert " ")
571 t)
572 )));; end of setq unwind-protect cond
573 (if result
574 t
575 (goto-char start-pos)
576 nil)
577 ))
578
579 ;;;;; setup
580
581 (defun ada-gnat-compile-select-prj ()
582 (setq ada-fix-error-hook 'ada-gnat-fix-error-hook)
583 (setq ada-prj-show-prj-path 'gnat-prj-show-prj-path)
584 (add-to-list 'completion-ignored-extensions ".ali") ;; gnat library files
585 (add-hook 'ada-syntax-propertize-hook 'ada-gnat-syntax-propertize)
586 (add-hook 'ada-syntax-propertize-hook 'gnatprep-syntax-propertize)
587
588 ;; There is no common convention for a file extension for gnatprep files.
589 ;;
590 ;; find error locations in .gpr files
591 (setq compilation-search-path (append compilation-search-path (ada-prj-get 'prj_dir)))
592
593 ;; must be after indentation engine setup, because that resets the
594 ;; indent function list.
595 (add-hook 'ada-mode-hook 'gnatprep-setup t)
596
597 (add-hook 'compilation-filter-hook 'ada-gnat-compilation-filter)
598
599 ;; ada-mode.el project file parser sets this to other compilers used
600 ;; in the project, so we only add here.
601 (add-to-list 'compilation-error-regexp-alist 'gnat)
602 )
603
604 (defun ada-gnat-compile-deselect-prj ()
605 (setq ada-fix-error-hook nil)
606 (setq completion-ignored-extensions (delete ".ali" completion-ignored-extensions))
607 (setq ada-syntax-propertize-hook (delq 'gnatprep-syntax-propertize ada-syntax-propertize-hook))
608 (setq ada-syntax-propertize-hook (delq 'ada-gnat-syntax-propertize ada-syntax-propertize-hook))
609
610 ;; don't need to delete from compilation-search-path; completely rewritten in ada-select-prj-file
611
612 (setq ada-mode-hook (delq 'gnatprep-setup ada-mode-hook))
613
614 (setq compilation-filter-hook (delete 'ada-gnat-compilation-filter compilation-filter-hook))
615 (setq compilation-error-regexp-alist (delete 'gnat compilation-error-regexp-alist))
616 )
617
618 (defun ada-gnat-compile ()
619 "Set Ada mode global vars to use `gnat' for compiling."
620 (add-to-list 'ada-prj-file-ext-extra "gpr")
621 (add-to-list 'ada-prj-parser-alist '("gpr" . gnat-parse-gpr))
622 (add-to-list 'ada-select-prj-compiler '(gnat . ada-gnat-compile-select-prj))
623 (add-to-list 'ada-deselect-prj-compiler '(gnat . ada-gnat-compile-deselect-prj))
624
625 (add-to-list 'ada-prj-parse-one-compiler (cons 'gnat 'gnat-prj-parse-emacs-one))
626 (add-to-list 'ada-prj-parse-final-compiler (cons 'gnat 'gnat-prj-parse-emacs-final))
627
628 (font-lock-add-keywords 'ada-mode
629 ;; gnatprep preprocessor line
630 (list (list "^[ \t]*\\(#.*\n\\)" '(1 font-lock-preprocessor-face t))))
631
632 (add-hook 'ada-gnat-fix-error-hook 'ada-gnat-fix-error))
633
634 (provide 'ada-gnat-compile)
635 (provide 'ada-compiler)
636
637 (ada-gnat-compile)
638
639 (add-to-list
640 'compilation-error-regexp-alist-alist
641 '(gnat
642 ;; typical:
643 ;; cards_package.adb:45:32: expected private type "System.Address"
644 ;;
645 ;; with full path Source_Reference pragma :
646 ;; d:/maphds/version_x/1773/sbs-abi-dll_lib.ads.gp:39:06: file "interfaces_c.ads" not found
647 ;;
648 ;; gnu cc1: (gnatmake can invoke the C compiler)
649 ;; foo.c:2: `TRUE' undeclared here (not in a function)
650 ;; foo.c:2 : `TRUE' undeclared here (not in a function)
651 "^\\(\\(.:\\)?[^ :\n]+\\):\\([0-9]+\\)\\s-?:?\\([0-9]+\\)?" 1 3 4))
652
653 (unless (default-value 'ada-compiler)
654 (set-default 'ada-compiler 'gnat))
655
656 ;; end of file