diff options
| author | Richard M. Stallman | 2003-10-20 23:30:05 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2003-10-20 23:30:05 +0000 |
| commit | b6c846d34180f39824bbb116ed51929cb2f13511 (patch) | |
| tree | ee7e8761a894f2972256fccedf93bbd44b9bc29e | |
| parent | e539d49b44c3791b5d01e2059041084b9c3ab728 (diff) | |
| download | emacs-b6c846d34180f39824bbb116ed51929cb2f13511.tar.gz emacs-b6c846d34180f39824bbb116ed51929cb2f13511.zip | |
Make major mode work with cc-mode-5.30+.
(antlr-c-init-language-vars): New function.
(antlr-mode): Use it with cc-mode before v5.29.
(antlr-c-common-init): Don't set some local vars here.
(antlr-mode): Set them here.
(antlr-c-forward-sws): New function alias.
(antlr-mode): Redefine with cc-mode before v5.30.
(antlr-skip-sexps): Use it.
(antlr-skip-exception-part): Ditto.
(antlr-skip-file-prelude): Ditto.
(antlr-outside-rule-p): Ditto.
(antlr-end-of-body): Ditto.
(antlr-option-kind): Ditto.
(antlr-insert-option-area): Ditto.
(antlr-file-dependencies): Ditto.
| -rw-r--r-- | lisp/progmodes/antlr-mode.el | 159 |
1 files changed, 93 insertions, 66 deletions
diff --git a/lisp/progmodes/antlr-mode.el b/lisp/progmodes/antlr-mode.el index 247ad2e90bd..f3a540fc491 100644 --- a/lisp/progmodes/antlr-mode.el +++ b/lisp/progmodes/antlr-mode.el | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | ;; Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. |
| 4 | ;; | 4 | ;; |
| 5 | ;; Author: Christoph.Wedler@sap.com | 5 | ;; Author: Christoph.Wedler@sap.com |
| 6 | ;; Keywords: languages | 6 | ;; Keywords: languages, ANTLR, code generator |
| 7 | ;; Version: (see `antlr-version' below) | 7 | ;; Version: (see `antlr-version' below) |
| 8 | ;; X-URL: http://antlr-mode.sourceforge.net/ | 8 | ;; X-URL: http://antlr-mode.sourceforge.net/ |
| 9 | 9 | ||
| @@ -55,6 +55,9 @@ | |||
| 55 | ;; * Probably. Show rules/dependencies for ANT like for Makefile (does ANT | 55 | ;; * Probably. Show rules/dependencies for ANT like for Makefile (does ANT |
| 56 | ;; support vocabularies and grammar inheritance?), I have to look at | 56 | ;; support vocabularies and grammar inheritance?), I have to look at |
| 57 | ;; jde-ant.el: http://jakarta.apache.org/ant/manual/OptionalTasks/antlr.html | 57 | ;; jde-ant.el: http://jakarta.apache.org/ant/manual/OptionalTasks/antlr.html |
| 58 | ;; * Probably. Make `indent-region' faster, especially in actions. ELP | ||
| 59 | ;; profiling in a class init action shows half the time is spent in | ||
| 60 | ;; `antlr-next-rule', the other half in `c-guess-basic-syntax'. | ||
| 58 | ;; * Unlikely. Sather as generated language with syntax highlighting etc/. | 61 | ;; * Unlikely. Sather as generated language with syntax highlighting etc/. |
| 59 | ;; Questions/problems: is sather-mode.el the standard mode for sather, is it | 62 | ;; Questions/problems: is sather-mode.el the standard mode for sather, is it |
| 60 | ;; still supported, what is its relationship to eiffel3.el? Requirement: | 63 | ;; still supported, what is its relationship to eiffel3.el? Requirement: |
| @@ -173,12 +176,23 @@ | |||
| 173 | 176 | ||
| 174 | ;; get rid of byte-compile warnings | 177 | ;; get rid of byte-compile warnings |
| 175 | (eval-when-compile ; required and optional libraries | 178 | (eval-when-compile ; required and optional libraries |
| 176 | (ignore-errors (require 'cc-mode)) | 179 | (require 'cc-mode) |
| 177 | (ignore-errors (require 'font-lock)) | 180 | (ignore-errors (require 'font-lock)) |
| 178 | (ignore-errors (require 'compile)) | 181 | (ignore-errors (require 'compile)) |
| 182 | ;;(ignore-errors (defun c-init-language-vars))) dangerous on Emacs! | ||
| 183 | ;;(ignore-errors (defun c-init-c-language-vars))) dangerous on Emacs! | ||
| 184 | ;;(ignore-errors (defun c-basic-common-init)) dangerous on Emacs! | ||
| 179 | (defvar outline-level) (defvar imenu-use-markers) | 185 | (defvar outline-level) (defvar imenu-use-markers) |
| 180 | (defvar imenu-create-index-function) | 186 | (defvar imenu-create-index-function)) |
| 181 | (ignore-errors (defun c-init-language-vars))) | 187 | |
| 188 | ;; We cannot use `c-forward-syntactic-ws' directly since it is a macro since | ||
| 189 | ;; cc-mode-5.30 => antlr-mode compiled with older cc-mode would fail (macro | ||
| 190 | ;; call) when used with newer cc-mode. Also, antlr-mode compiled with newer | ||
| 191 | ;; cc-mode would fail (undefined `c-forward-sws') when used with older cc-mode. | ||
| 192 | ;; Additional to the `defalias' below, we must set `antlr-c-forward-sws' to | ||
| 193 | ;; `c-forward-syntactic-ws' when `c-forward-sws' is not defined after requiring | ||
| 194 | ;; cc-mode. | ||
| 195 | (defalias 'antlr-c-forward-sws 'c-forward-sws) | ||
| 182 | 196 | ||
| 183 | 197 | ||
| 184 | ;;;;########################################################################## | 198 | ;;;;########################################################################## |
| @@ -193,7 +207,7 @@ | |||
| 193 | :link '(url-link "http://antlr-mode.sourceforge.net/") | 207 | :link '(url-link "http://antlr-mode.sourceforge.net/") |
| 194 | :prefix "antlr-") | 208 | :prefix "antlr-") |
| 195 | 209 | ||
| 196 | (defconst antlr-version "2.2b" | 210 | (defconst antlr-version "2.2c" |
| 197 | "ANTLR major mode version number. | 211 | "ANTLR major mode version number. |
| 198 | Check <http://antlr-mode.sourceforge.net/> for the newest.") | 212 | Check <http://antlr-mode.sourceforge.net/> for the newest.") |
| 199 | 213 | ||
| @@ -1190,7 +1204,7 @@ strings and actions/semantic predicates." | |||
| 1190 | Return position before the comments after the last expression." | 1204 | Return position before the comments after the last expression." |
| 1191 | (goto-char (or (ignore-errors-x (scan-sexps (point) count)) (point-max))) | 1205 | (goto-char (or (ignore-errors-x (scan-sexps (point) count)) (point-max))) |
| 1192 | (prog1 (point) | 1206 | (prog1 (point) |
| 1193 | (c-forward-syntactic-ws))) | 1207 | (antlr-c-forward-sws))) |
| 1194 | 1208 | ||
| 1195 | 1209 | ||
| 1196 | ;;;=========================================================================== | 1210 | ;;;=========================================================================== |
| @@ -1272,7 +1286,7 @@ header. If SKIP-COMMENT is non-nil, also skip the comment after that | |||
| 1272 | part." | 1286 | part." |
| 1273 | (let ((pos (point)) | 1287 | (let ((pos (point)) |
| 1274 | (class nil)) | 1288 | (class nil)) |
| 1275 | (c-forward-syntactic-ws) | 1289 | (antlr-c-forward-sws) |
| 1276 | (while (looking-at "options\\>\\|tokens\\>") | 1290 | (while (looking-at "options\\>\\|tokens\\>") |
| 1277 | (setq class t) | 1291 | (setq class t) |
| 1278 | (setq pos (antlr-skip-sexps 2))) | 1292 | (setq pos (antlr-skip-sexps 2))) |
| @@ -1298,7 +1312,7 @@ Hack: if SKIP-COMMENT is `header-only' only skip header and return | |||
| 1298 | position before the comment after the header." | 1312 | position before the comment after the header." |
| 1299 | (let* ((pos (point)) | 1313 | (let* ((pos (point)) |
| 1300 | (pos0 pos)) | 1314 | (pos0 pos)) |
| 1301 | (c-forward-syntactic-ws) | 1315 | (antlr-c-forward-sws) |
| 1302 | (if skip-comment (setq pos0 (point))) | 1316 | (if skip-comment (setq pos0 (point))) |
| 1303 | (while (looking-at "header\\>[ \t]*\\(\"\\)?") | 1317 | (while (looking-at "header\\>[ \t]*\\(\"\\)?") |
| 1304 | (setq pos (antlr-skip-sexps (if (match-beginning 1) 3 2)))) | 1318 | (setq pos (antlr-skip-sexps (if (match-beginning 1) 3 2)))) |
| @@ -1360,7 +1374,7 @@ Move to the beginning of the current rule if point is inside a rule." | |||
| 1360 | (let ((pos (point))) | 1374 | (let ((pos (point))) |
| 1361 | (antlr-next-rule -1 nil) | 1375 | (antlr-next-rule -1 nil) |
| 1362 | (let ((between (or (bobp) (< (point) pos)))) | 1376 | (let ((between (or (bobp) (< (point) pos)))) |
| 1363 | (c-forward-syntactic-ws) | 1377 | (antlr-c-forward-sws) |
| 1364 | (and between (> (point) pos) (goto-char pos))))) | 1378 | (and between (> (point) pos) (goto-char pos))))) |
| 1365 | 1379 | ||
| 1366 | 1380 | ||
| @@ -1420,7 +1434,7 @@ prefix arg MSG, move to `:'." | |||
| 1420 | (or (antlr-search-forward ":") (point-max)))) | 1434 | (or (antlr-search-forward ":") (point-max)))) |
| 1421 | (goto-char orig) | 1435 | (goto-char orig) |
| 1422 | (error msg)) | 1436 | (error msg)) |
| 1423 | (c-forward-syntactic-ws)))))) | 1437 | (antlr-c-forward-sws)))))) |
| 1424 | 1438 | ||
| 1425 | (defunx antlr-beginning-of-body () | 1439 | (defunx antlr-beginning-of-body () |
| 1426 | "Move to the first element after the `:' of the current rule." | 1440 | "Move to the first element after the `:' of the current rule." |
| @@ -1598,7 +1612,7 @@ This command might also set the mark like \\[set-mark-command] does, see | |||
| 1598 | 1612 | ||
| 1599 | (defun antlr-insert-option-interactive (arg) | 1613 | (defun antlr-insert-option-interactive (arg) |
| 1600 | "Interactive specification for `antlr-insert-option'. | 1614 | "Interactive specification for `antlr-insert-option'. |
| 1601 | Use prefix argument ARG to return \(LEVEL OPTION LOCATION)." | 1615 | Return \(LEVEL OPTION LOCATION)." |
| 1602 | (barf-if-buffer-read-only) | 1616 | (barf-if-buffer-read-only) |
| 1603 | (if arg (setq arg (prefix-numeric-value arg))) | 1617 | (if arg (setq arg (prefix-numeric-value arg))) |
| 1604 | (unless (memq arg '(nil 1 2 3 4)) | 1618 | (unless (memq arg '(nil 1 2 3 4)) |
| @@ -1627,7 +1641,7 @@ Use prefix argument ARG to return \(LEVEL OPTION LOCATION)." | |||
| 1627 | :active active)) | 1641 | :active active)) |
| 1628 | (sort (mapcar 'car (elt antlr-options-alists (1- level))) | 1642 | (sort (mapcar 'car (elt antlr-options-alists (1- level))) |
| 1629 | 'string-lessp)))) | 1643 | 'string-lessp)))) |
| 1630 | 1644 | ||
| 1631 | 1645 | ||
| 1632 | ;;;=========================================================================== | 1646 | ;;;=========================================================================== |
| 1633 | ;;; Insert option: determine section-kind | 1647 | ;;; Insert option: determine section-kind |
| @@ -1653,7 +1667,7 @@ like \(AREA \. PLACE), see `antlr-option-location'." | |||
| 1653 | (setq pos (antlr-skip-file-prelude 'header-only))) | 1667 | (setq pos (antlr-skip-file-prelude 'header-only))) |
| 1654 | ((not (eq level 3)) ; grammar or subrule options | 1668 | ((not (eq level 3)) ; grammar or subrule options |
| 1655 | (setq pos (point)) | 1669 | (setq pos (point)) |
| 1656 | (c-forward-syntactic-ws)) | 1670 | (antlr-c-forward-sws)) |
| 1657 | ((looking-at "^\\(private[ \t\n]\\|public[ \t\n]\\|protected[ \t\n]\\)?[ \t\n]*\\(\\(\\sw\\|\\s_\\)+\\)[ \t\n]*\\(!\\)?[ \t\n]*\\(\\[\\)?") | 1671 | ((looking-at "^\\(private[ \t\n]\\|public[ \t\n]\\|protected[ \t\n]\\)?[ \t\n]*\\(\\(\\sw\\|\\s_\\)+\\)[ \t\n]*\\(!\\)?[ \t\n]*\\(\\[\\)?") |
| 1658 | ;; rule options, with complete rule header | 1672 | ;; rule options, with complete rule header |
| 1659 | (goto-char (or (match-end 4) (match-end 3))) | 1673 | (goto-char (or (match-end 4) (match-end 3))) |
| @@ -1904,7 +1918,7 @@ For OLD, see `antlr-insert-option-do'." | |||
| 1904 | ;; stuff (no =, {, } or /) at point is not followed by ";" | 1918 | ;; stuff (no =, {, } or /) at point is not followed by ";" |
| 1905 | (insert ";") | 1919 | (insert ";") |
| 1906 | (backward-char))) | 1920 | (backward-char))) |
| 1907 | 1921 | ||
| 1908 | (defun antlr-insert-option-space (area old) | 1922 | (defun antlr-insert-option-space (area old) |
| 1909 | "Find appropriate place to insert option, insert newlines/spaces. | 1923 | "Find appropriate place to insert option, insert newlines/spaces. |
| 1910 | For AREA and OLD, see `antlr-insert-option-do'." | 1924 | For AREA and OLD, see `antlr-insert-option-do'." |
| @@ -1924,7 +1938,7 @@ For AREA and OLD, see `antlr-insert-option-do'." | |||
| 1924 | (setq orig (point)) | 1938 | (setq orig (point)) |
| 1925 | (goto-char orig))) | 1939 | (goto-char orig))) |
| 1926 | (skip-chars-forward " \t") | 1940 | (skip-chars-forward " \t") |
| 1927 | 1941 | ||
| 1928 | (if (looking-at "$\\|//") | 1942 | (if (looking-at "$\\|//") |
| 1929 | ;; just comment after point => skip (+ lines w/ same col comment) | 1943 | ;; just comment after point => skip (+ lines w/ same col comment) |
| 1930 | (let ((same (if (> (match-end 0) (match-beginning 0)) | 1944 | (let ((same (if (> (match-end 0) (match-beginning 0)) |
| @@ -1959,7 +1973,7 @@ Used by `antlr-insert-option-do'." | |||
| 1959 | (when (and antlr-options-auto-colon | 1973 | (when (and antlr-options-auto-colon |
| 1960 | (memq level '(3 4)) | 1974 | (memq level '(3 4)) |
| 1961 | (save-excursion | 1975 | (save-excursion |
| 1962 | (c-forward-syntactic-ws) | 1976 | (antlr-c-forward-sws) |
| 1963 | (if (eq (char-after (point)) ?\{) (antlr-skip-sexps 1)) | 1977 | (if (eq (char-after (point)) ?\{) (antlr-skip-sexps 1)) |
| 1964 | (not (eq (char-after (point)) ?\:)))) | 1978 | (not (eq (char-after (point)) ?\:)))) |
| 1965 | (insert "\n:") | 1979 | (insert "\n:") |
| @@ -2079,12 +2093,12 @@ its export vocabulary is used as an import vocabulary." | |||
| 2079 | (evocab (or default-vocab class)) | 2093 | (evocab (or default-vocab class)) |
| 2080 | (ivocab nil)) | 2094 | (ivocab nil)) |
| 2081 | (goto-char (match-end 0)) | 2095 | (goto-char (match-end 0)) |
| 2082 | (c-forward-syntactic-ws) | 2096 | (antlr-c-forward-sws) |
| 2083 | (while (looking-at "options\\>\\|\\(tokens\\)\\>") | 2097 | (while (looking-at "options\\>\\|\\(tokens\\)\\>") |
| 2084 | (if (match-beginning 1) | 2098 | (if (match-beginning 1) |
| 2085 | (antlr-skip-sexps 2) | 2099 | (antlr-skip-sexps 2) |
| 2086 | (goto-char (match-end 0)) | 2100 | (goto-char (match-end 0)) |
| 2087 | (c-forward-syntactic-ws) | 2101 | (antlr-c-forward-sws) |
| 2088 | ;; parse grammar option sections ------------------------------- | 2102 | ;; parse grammar option sections ------------------------------- |
| 2089 | (when (eq (char-after (point)) ?\{) | 2103 | (when (eq (char-after (point)) ?\{) |
| 2090 | (let* ((beg (1+ (point))) | 2104 | (let* ((beg (1+ (point))) |
| @@ -2341,7 +2355,7 @@ commentary with value `antlr-help-unknown-file-text' is added. The | |||
| 2341 | 2355 | ||
| 2342 | (defun antlr-indent-line () | 2356 | (defun antlr-indent-line () |
| 2343 | "Indent the current line as ANTLR grammar code. | 2357 | "Indent the current line as ANTLR grammar code. |
| 2344 | The indentation of non-comment lines are calculated by `c-basic-offset', | 2358 | The indentation of grammar lines are calculated by `c-basic-offset', |
| 2345 | multiplied by: | 2359 | multiplied by: |
| 2346 | - the level of the paren/brace/bracket depth, | 2360 | - the level of the paren/brace/bracket depth, |
| 2347 | - plus 0/2/1, depending on the position inside the rule: header, body, | 2361 | - plus 0/2/1, depending on the position inside the rule: header, body, |
| @@ -2484,20 +2498,46 @@ ANTLR's syntax and influences the auto indentation, see | |||
| 2484 | ;;; Mode entry | 2498 | ;;; Mode entry |
| 2485 | ;;;=========================================================================== | 2499 | ;;;=========================================================================== |
| 2486 | 2500 | ||
| 2501 | (defun antlr-c-init-language-vars () | ||
| 2502 | "Like `c-init-language-vars-for' when using cc-mode before v5.29." | ||
| 2503 | (let ((settings ; (cdr '(setq...)) will be optimized | ||
| 2504 | (if (eq antlr-language 'c++-mode) | ||
| 2505 | (cdr '(setq ;' from `c++-mode' v5.20, v5.28 | ||
| 2506 | c-keywords (c-identifier-re c-C++-keywords) | ||
| 2507 | c-conditional-key c-C++-conditional-key | ||
| 2508 | c-comment-start-regexp c-C++-comment-start-regexp | ||
| 2509 | c-class-key c-C++-class-key | ||
| 2510 | c-extra-toplevel-key c-C++-extra-toplevel-key | ||
| 2511 | c-access-key c-C++-access-key | ||
| 2512 | c-recognize-knr-p nil | ||
| 2513 | c-bitfield-key c-C-bitfield-key ; v5.28 | ||
| 2514 | )) | ||
| 2515 | (cdr '(setq ; from `java-mode' v5.20, v5.28 | ||
| 2516 | c-keywords (c-identifier-re c-Java-keywords) | ||
| 2517 | c-conditional-key c-Java-conditional-key | ||
| 2518 | c-comment-start-regexp c-Java-comment-start-regexp | ||
| 2519 | c-class-key c-Java-class-key | ||
| 2520 | c-method-key nil | ||
| 2521 | c-baseclass-key nil | ||
| 2522 | c-recognize-knr-p nil | ||
| 2523 | c-access-key c-Java-access-key ; v5.20 | ||
| 2524 | c-inexpr-class-key c-Java-inexpr-class-key ; v5.28 | ||
| 2525 | ))))) | ||
| 2526 | (while settings | ||
| 2527 | (when (boundp (car settings)) | ||
| 2528 | (ignore-errors | ||
| 2529 | (set (car settings) (eval (cadr settings))))) | ||
| 2530 | (setq settings (cddr settings))))) | ||
| 2531 | |||
| 2487 | (defun antlr-c-common-init () | 2532 | (defun antlr-c-common-init () |
| 2488 | "Like `c-common-init' except menu, auto-hungry and c-style stuff." | 2533 | "Like `c-basic-common-init' when using cc-mode before v5.30." |
| 2489 | ;; X/Emacs 20 only | 2534 | ;; X/Emacs 20 only |
| 2490 | (make-local-variable 'paragraph-start) | 2535 | (make-local-variable 'paragraph-start) |
| 2491 | (make-local-variable 'paragraph-separate) | 2536 | (make-local-variable 'paragraph-separate) |
| 2492 | (make-local-variable 'paragraph-ignore-fill-prefix) | 2537 | (make-local-variable 'paragraph-ignore-fill-prefix) |
| 2493 | (make-local-variable 'require-final-newline) | 2538 | (make-local-variable 'require-final-newline) |
| 2494 | (make-local-variable 'parse-sexp-ignore-comments) | 2539 | (make-local-variable 'parse-sexp-ignore-comments) |
| 2495 | (make-local-variable 'indent-line-function) | ||
| 2496 | (make-local-variable 'indent-region-function) | ||
| 2497 | (make-local-variable 'comment-start) | 2540 | (make-local-variable 'comment-start) |
| 2498 | (make-local-variable 'comment-end) | ||
| 2499 | (make-local-variable 'comment-column) | ||
| 2500 | (make-local-variable 'comment-start-skip) | ||
| 2501 | (make-local-variable 'comment-multi-line) | 2541 | (make-local-variable 'comment-multi-line) |
| 2502 | (make-local-variable 'outline-regexp) | 2542 | (make-local-variable 'outline-regexp) |
| 2503 | (make-local-variable 'outline-level) | 2543 | (make-local-variable 'outline-level) |
| @@ -2515,14 +2555,8 @@ ANTLR's syntax and influences the auto indentation, see | |||
| 2515 | (setq paragraph-start (concat page-delimiter "\\|$") | 2555 | (setq paragraph-start (concat page-delimiter "\\|$") |
| 2516 | paragraph-separate paragraph-start | 2556 | paragraph-separate paragraph-start |
| 2517 | paragraph-ignore-fill-prefix t | 2557 | paragraph-ignore-fill-prefix t |
| 2518 | require-final-newline t | ||
| 2519 | parse-sexp-ignore-comments t | 2558 | parse-sexp-ignore-comments t |
| 2520 | indent-line-function 'c-indent-line | ||
| 2521 | indent-region-function 'c-indent-region | ||
| 2522 | outline-regexp "[^#\n\^M]" | ||
| 2523 | outline-level 'c-outline-level | ||
| 2524 | comment-column 32 | 2559 | comment-column 32 |
| 2525 | comment-start-skip "/\\*+ *\\|// *" | ||
| 2526 | comment-multi-line nil | 2560 | comment-multi-line nil |
| 2527 | comment-line-break-function 'c-comment-line-break-function | 2561 | comment-line-break-function 'c-comment-line-break-function |
| 2528 | adaptive-fill-regexp nil | 2562 | adaptive-fill-regexp nil |
| @@ -2563,14 +2597,15 @@ the default language." | |||
| 2563 | (setq r nil))) ; no result yet | 2597 | (setq r nil))) ; no result yet |
| 2564 | (car r))) | 2598 | (car r))) |
| 2565 | 2599 | ||
| 2566 | |||
| 2567 | ;;;###autoload | 2600 | ;;;###autoload |
| 2568 | (defun antlr-mode () | 2601 | (defun antlr-mode () |
| 2569 | "Major mode for editing ANTLR grammar files. | 2602 | "Major mode for editing ANTLR grammar files. |
| 2570 | \\{antlr-mode-map}" | 2603 | \\{antlr-mode-map}" |
| 2571 | (interactive) | 2604 | (interactive) |
| 2572 | (c-initialize-cc-mode) ; required when depending on cc-mode | ||
| 2573 | (kill-all-local-variables) | 2605 | (kill-all-local-variables) |
| 2606 | (c-initialize-cc-mode) ; cc-mode is required | ||
| 2607 | (unless (fboundp 'c-forward-sws) ; see above | ||
| 2608 | (fset 'antlr-c-forward-sws 'c-forward-syntactic-ws)) | ||
| 2574 | ;; ANTLR specific ---------------------------------------------------------- | 2609 | ;; ANTLR specific ---------------------------------------------------------- |
| 2575 | (setq major-mode 'antlr-mode | 2610 | (setq major-mode 'antlr-mode |
| 2576 | mode-name "Antlr") | 2611 | mode-name "Antlr") |
| @@ -2597,42 +2632,34 @@ the default language." | |||
| 2597 | (concat "Antlr." | 2632 | (concat "Antlr." |
| 2598 | (cadr (assq antlr-language antlr-language-alist))))) | 2633 | (cadr (assq antlr-language antlr-language-alist))))) |
| 2599 | ;; indentation, for the C engine ------------------------------------------- | 2634 | ;; indentation, for the C engine ------------------------------------------- |
| 2600 | (antlr-c-common-init) | 2635 | (setq c-buffer-is-cc-mode antlr-language) |
| 2636 | (cond ((fboundp 'c-init-language-vars-for) ; cc-mode 5.30.5+ | ||
| 2637 | (c-init-language-vars-for antlr-language)) | ||
| 2638 | ((fboundp 'c-init-c-language-vars) ; cc-mode 5.30 to 5.30.4 | ||
| 2639 | (c-init-c-language-vars) ; not perfect, but OK | ||
| 2640 | (setq c-recognize-knr-p nil)) | ||
| 2641 | ((fboundp 'c-init-language-vars) ; cc-mode 5.29 | ||
| 2642 | (let ((init-fn 'c-init-language-vars)) | ||
| 2643 | (funcall init-fn))) ; is a function in v5.29 | ||
| 2644 | (t ; cc-mode upto 5.28 | ||
| 2645 | (antlr-c-init-language-vars))) ; do it myself | ||
| 2646 | (cond ((fboundp 'c-basic-common-init) ; cc-mode 5.30+ | ||
| 2647 | (c-basic-common-init antlr-language (or antlr-indent-style "gnu"))) | ||
| 2648 | (t | ||
| 2649 | (antlr-c-common-init))) | ||
| 2650 | (make-local-variable 'outline-regexp) | ||
| 2651 | (make-local-variable 'outline-level) | ||
| 2652 | (make-local-variable 'require-final-newline) | ||
| 2653 | (make-local-variable 'indent-line-function) | ||
| 2654 | (make-local-variable 'indent-region-function) | ||
| 2655 | (setq outline-regexp "[^#\n\^M]" | ||
| 2656 | outline-level 'c-outline-level) ; TODO: define own | ||
| 2657 | (setq require-final-newline t) | ||
| 2601 | (setq indent-line-function 'antlr-indent-line | 2658 | (setq indent-line-function 'antlr-indent-line |
| 2602 | indent-region-function nil) ; too lazy | 2659 | indent-region-function nil) ; too lazy |
| 2603 | (setq c-buffer-is-cc-mode antlr-language) | ||
| 2604 | (if (fboundp 'c-init-language-vars) | ||
| 2605 | (c-init-language-vars) ; cc-mode >= v5.29 | ||
| 2606 | (let ((settings ; (cdr '(setq...)) will be optimized | ||
| 2607 | (if (eq antlr-language 'c++-mode) | ||
| 2608 | (cdr '(setq ;' from `c++-mode' v5.20, v5.28 | ||
| 2609 | c-keywords (c-identifier-re c-C++-keywords) | ||
| 2610 | c-conditional-key c-C++-conditional-key | ||
| 2611 | c-comment-start-regexp c-C++-comment-start-regexp | ||
| 2612 | c-class-key c-C++-class-key | ||
| 2613 | c-extra-toplevel-key c-C++-extra-toplevel-key | ||
| 2614 | c-access-key c-C++-access-key | ||
| 2615 | c-recognize-knr-p nil | ||
| 2616 | c-bitfield-key c-C-bitfield-key ; v5.28 | ||
| 2617 | )) | ||
| 2618 | (cdr '(setq ; from `java-mode' v5.20, v5.28 | ||
| 2619 | c-keywords (c-identifier-re c-Java-keywords) | ||
| 2620 | c-conditional-key c-Java-conditional-key | ||
| 2621 | c-comment-start-regexp c-Java-comment-start-regexp | ||
| 2622 | c-class-key c-Java-class-key | ||
| 2623 | c-method-key nil | ||
| 2624 | c-baseclass-key nil | ||
| 2625 | c-recognize-knr-p nil | ||
| 2626 | c-access-key c-Java-access-key ; v5.20 | ||
| 2627 | c-inexpr-class-key c-Java-inexpr-class-key ; v5.28 | ||
| 2628 | ))))) | ||
| 2629 | (while settings | ||
| 2630 | (when (boundp (car settings)) | ||
| 2631 | (ignore-errors | ||
| 2632 | (set (car settings) (eval (cadr settings))))) | ||
| 2633 | (setq settings (cddr settings))))) | ||
| 2634 | (setq comment-start "// " | 2660 | (setq comment-start "// " |
| 2635 | comment-end "") | 2661 | comment-end "" |
| 2662 | comment-start-skip "/\\*+ *\\|// *") | ||
| 2636 | ;; various ----------------------------------------------------------------- | 2663 | ;; various ----------------------------------------------------------------- |
| 2637 | (make-local-variable 'font-lock-defaults) | 2664 | (make-local-variable 'font-lock-defaults) |
| 2638 | (setq font-lock-defaults antlr-font-lock-defaults) | 2665 | (setq font-lock-defaults antlr-font-lock-defaults) |