aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Marshall1994-10-12 08:00:49 +0000
committerSimon Marshall1994-10-12 08:00:49 +0000
commit4cc584758377e80dea09c46a0582871ed273196d (patch)
tree1c69eee1354a4803f0647d4a5304e86898355882
parenta70332a1c7f97754e35d2c917205cedf69343729 (diff)
downloademacs-4cc584758377e80dea09c46a0582871ed273196d.tar.gz
emacs-4cc584758377e80dea09c46a0582871ed273196d.zip
* ada.el: (ada-mode-syntax-table): Made `-' and `\n' be comments.
(ada-font-lock-keywords-1, ada-font-lock-keywords-2, ada-font-lock-keywords): New variables. (ada-mode): Set font-lock-defaults.
-rw-r--r--lisp/ada.el90
1 files changed, 88 insertions, 2 deletions
diff --git a/lisp/ada.el b/lisp/ada.el
index 5e8458501cc..72d00257d78 100644
--- a/lisp/ada.el
+++ b/lisp/ada.el
@@ -41,7 +41,7 @@
41 (modify-syntax-entry ?* "." table) 41 (modify-syntax-entry ?* "." table)
42 (modify-syntax-entry ?/ "." table) 42 (modify-syntax-entry ?/ "." table)
43 (modify-syntax-entry ?+ "." table) 43 (modify-syntax-entry ?+ "." table)
44 (modify-syntax-entry ?- "." table) 44 (modify-syntax-entry ?- ". 12" table)
45 (modify-syntax-entry ?= "." table) 45 (modify-syntax-entry ?= "." table)
46 (modify-syntax-entry ?\& "." table) 46 (modify-syntax-entry ?\& "." table)
47 (modify-syntax-entry ?\| "." table) 47 (modify-syntax-entry ?\| "." table)
@@ -57,8 +57,92 @@
57 (modify-syntax-entry ?\; "." table) 57 (modify-syntax-entry ?\; "." table)
58 (modify-syntax-entry ?\' "." table) 58 (modify-syntax-entry ?\' "." table)
59 (modify-syntax-entry ?\" "\"" table) 59 (modify-syntax-entry ?\" "\"" table)
60 (modify-syntax-entry ?\n ">" table)
60 (setq ada-mode-syntax-table table)) 61 (setq ada-mode-syntax-table table))
61 62
63;; Strings are a real pain in Ada because both ' and " can appear in a
64;; non-string quote context (the former as an operator, the latter as a
65;; character string). We follow the least losing solution, in which only " is
66;; a string quote. Therefore a character string of the form '"' will throw
67;; fontification off on the wrong track.
68
69(defconst ada-font-lock-keywords-1
70 (list
71 ;;
72 ;; Function, package (body), pragma, procedure, task (body) plus name.
73 (list (concat "\\<\\("
74 "function\\|"
75 "p\\(ackage\\(\\|[ \t]+body\\)\\|r\\(agma\\|ocedure\\)\\)\\|"
76 "task\\(\\|[ \t]+body\\)"
77 "\\)\\>[ \t]*\\(\\sw+\\(\\.\\sw*\\)*\\)?")
78 '(1 font-lock-keyword-face) '(6 font-lock-function-name-face nil t)))
79 "For consideration as a value of `ada-font-lock-keywords'.
80This does fairly subdued highlighting.")
81
82(defconst ada-font-lock-keywords-2
83 (append ada-font-lock-keywords-1
84 (list
85 ;;
86 ;; Main keywords, except those treated specially below.
87 (concat "\\<\\("
88; ("abort" "abs" "abstract" "accept" "access" "aliased" "all"
89; "and" "array" "at" "begin" "case" "declare" "delay" "delta"
90; "digits" "do" "else" "elsif" "entry" "exception" "exit" "for"
91; "generic" "if" "is" "limited" "loop" "mod" "not"
92; "null" "or" "others" "private" "protected"
93; "range" "record" "rem" "renames" "requeue" "return" "reverse"
94; "select" "separate" "tagged" "task" "terminate" "then" "until"
95; "while" "xor")
96 "a\\(b\\(ort\\|s\\(\\|tract\\)\\)\\|cce\\(pt\\|ss\\)\\|"
97 "l\\(iased\\|l\\)\\|nd\\|rray\\|t\\)\\|begin\\|case\\|"
98 "d\\(e\\(clare\\|l\\(ay\\|ta\\)\\)\\|igits\\|o\\)\\|"
99 "e\\(ls\\(e\\|if\\)\\|ntry\\|x\\(ception\\|it\\)\\)\\|for\\|"
100 "generic\\|i[fs]\\|l\\(imited\\|oop\\)\\|mod\\|n\\(ot\\|ull\\)\\|"
101 "o\\(r\\|thers\\)\\|pr\\(ivate\\|otected\\)\\|"
102 "r\\(ange\\|e\\(cord\\|m\\|names\\|queue\\|turn\\|verse\\)\\)\\|"
103 "se\\(lect\\|parate\\)\\|"
104 "t\\(a\\(gged\\|sk\\)\\|erminate\\|hen\\)\\|until\\|while\\|xor"
105 "\\)\\>")
106 ;;
107 ;; Anything following end and not already fontified is a body name.
108 '("\\<\\(end\\)\\>[ \t]*\\(\\sw+\\)?"
109 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))
110; ;;
111; ;; Variable name plus optional keywords followed by a type name. Slow.
112; (list (concat "\\<\\(\\sw+\\)\\>[ \t]*:"
113; "[ \t]*\\(constant\\|in\\|in[ \t]+out\\|out\\)?[ \t]*"
114; "\\(\\sw+\\(\\.\\sw*\\)*\\)?")
115; '(1 font-lock-variable-name-face)
116; '(2 font-lock-keyword-face nil t) '(3 font-lock-type-face nil t))
117 ;;
118 ;; Optional keywords followed by a type name.
119 (list (concat ":[ \t]*\\<\\(constant\\|in\\|in[ \t]+out\\|out\\)\\>?[ \t]*"
120 "\\(\\sw+\\(\\.\\sw*\\)*\\)?")
121 '(1 font-lock-keyword-face nil t) '(2 font-lock-type-face nil t))
122 ;;
123 ;; Keywords followed by a type or function name.
124 (list (concat "\\<\\("
125 "new\\|of\\|subtype\\|type"
126 "\\)\\>[ \t]*\\(\\sw+\\(\\.\\sw*\\)*\\)?[ \t]*\\((\\)?")
127 '(1 font-lock-keyword-face)
128 '(2 (if (match-beginning 4)
129 font-lock-function-name-face
130 font-lock-type-face) nil t))
131 ;;
132 ;; Keywords followed by a reference.
133 (list (concat "\\<\\(goto\\|raise\\|use\\|when\\|with\\)\\>"
134 "[ \t]*\\(\\sw+\\(\\.\\sw*\\)*\\)?")
135 '(1 font-lock-keyword-face) '(2 font-lock-reference-face nil t))
136 ;;
137 ;; Goto tags.
138 '("<<\\(\\sw+\\(\\.\\sw*\\)*\\)>>" 1 font-lock-reference-face)
139 ))
140 "For consideration as a value of `ada-font-lock-keywords'.
141This does a lot more highlighting.")
142
143(defvar ada-font-lock-keywords ada-font-lock-keywords-1
144 "Additional expressions to highlight in Ada mode.")
145
62(defvar ada-mode-map nil 146(defvar ada-mode-map nil
63 "Keymap used in Ada mode.") 147 "Keymap used in Ada mode.")
64 148
@@ -106,7 +190,7 @@
106 (setq ada-mode-map map)) 190 (setq ada-mode-map map))
107 191
108(defvar ada-indent 4 "*Value is the number of columns to indent in Ada-Mode.") 192(defvar ada-indent 4 "*Value is the number of columns to indent in Ada-Mode.")
109 193
110;;;###autoload 194;;;###autoload
111(defun ada-mode () 195(defun ada-mode ()
112"This is a mode intended to support program development in Ada. 196"This is a mode intended to support program development in Ada.
@@ -169,6 +253,8 @@ Variable `ada-indent' controls the number of spaces for indent/undent."
169 (setq comment-indent-function 'c-comment-indent) 253 (setq comment-indent-function 'c-comment-indent)
170 (make-local-variable 'parse-sexp-ignore-comments) 254 (make-local-variable 'parse-sexp-ignore-comments)
171 (setq parse-sexp-ignore-comments t) 255 (setq parse-sexp-ignore-comments t)
256 (make-local-variable 'font-lock-defaults)
257 (setq font-lock-defaults '(ada-font-lock-keywords nil t ((?\_ . "w"))))
172 (run-hooks 'ada-mode-hook)) 258 (run-hooks 'ada-mode-hook))
173 259
174(defun ada-tabsize (s) 260(defun ada-tabsize (s)