[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/progmodes/antlr-mode.el
From: |
Richard M. Stallman |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/progmodes/antlr-mode.el |
Date: |
Mon, 20 Oct 2003 19:30:06 -0400 |
Index: emacs/lisp/progmodes/antlr-mode.el
diff -c emacs/lisp/progmodes/antlr-mode.el:1.16
emacs/lisp/progmodes/antlr-mode.el:1.17
*** emacs/lisp/progmodes/antlr-mode.el:1.16 Mon Sep 1 11:45:34 2003
--- emacs/lisp/progmodes/antlr-mode.el Mon Oct 20 19:30:05 2003
***************
*** 3,9 ****
;; Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
;;
;; Author: address@hidden
! ;; Keywords: languages
;; Version: (see `antlr-version' below)
;; X-URL: http://antlr-mode.sourceforge.net/
--- 3,9 ----
;; Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
;;
;; Author: address@hidden
! ;; Keywords: languages, ANTLR, code generator
;; Version: (see `antlr-version' below)
;; X-URL: http://antlr-mode.sourceforge.net/
***************
*** 55,60 ****
--- 55,63 ----
;; * Probably. Show rules/dependencies for ANT like for Makefile (does ANT
;; support vocabularies and grammar inheritance?), I have to look at
;; jde-ant.el:
http://jakarta.apache.org/ant/manual/OptionalTasks/antlr.html
+ ;; * Probably. Make `indent-region' faster, especially in actions. ELP
+ ;; profiling in a class init action shows half the time is spent in
+ ;; `antlr-next-rule', the other half in `c-guess-basic-syntax'.
;; * Unlikely. Sather as generated language with syntax highlighting etc/.
;; Questions/problems: is sather-mode.el the standard mode for sather, is
it
;; still supported, what is its relationship to eiffel3.el? Requirement:
***************
*** 173,184 ****
;; get rid of byte-compile warnings
(eval-when-compile ; required and optional libraries
! (ignore-errors (require 'cc-mode))
(ignore-errors (require 'font-lock))
(ignore-errors (require 'compile))
(defvar outline-level) (defvar imenu-use-markers)
! (defvar imenu-create-index-function)
! (ignore-errors (defun c-init-language-vars)))
;;;;##########################################################################
--- 176,198 ----
;; get rid of byte-compile warnings
(eval-when-compile ; required and optional libraries
! (require 'cc-mode)
(ignore-errors (require 'font-lock))
(ignore-errors (require 'compile))
+ ;;(ignore-errors (defun c-init-language-vars))) dangerous on Emacs!
+ ;;(ignore-errors (defun c-init-c-language-vars))) dangerous on Emacs!
+ ;;(ignore-errors (defun c-basic-common-init)) dangerous on Emacs!
(defvar outline-level) (defvar imenu-use-markers)
! (defvar imenu-create-index-function))
!
! ;; We cannot use `c-forward-syntactic-ws' directly since it is a macro since
! ;; cc-mode-5.30 => antlr-mode compiled with older cc-mode would fail (macro
! ;; call) when used with newer cc-mode. Also, antlr-mode compiled with newer
! ;; cc-mode would fail (undefined `c-forward-sws') when used with older
cc-mode.
! ;; Additional to the `defalias' below, we must set `antlr-c-forward-sws' to
! ;; `c-forward-syntactic-ws' when `c-forward-sws' is not defined after
requiring
! ;; cc-mode.
! (defalias 'antlr-c-forward-sws 'c-forward-sws)
;;;;##########################################################################
***************
*** 193,199 ****
:link '(url-link "http://antlr-mode.sourceforge.net/")
:prefix "antlr-")
! (defconst antlr-version "2.2b"
"ANTLR major mode version number.
Check <http://antlr-mode.sourceforge.net/> for the newest.")
--- 207,213 ----
:link '(url-link "http://antlr-mode.sourceforge.net/")
:prefix "antlr-")
! (defconst antlr-version "2.2c"
"ANTLR major mode version number.
Check <http://antlr-mode.sourceforge.net/> for the newest.")
***************
*** 1190,1196 ****
Return position before the comments after the last expression."
(goto-char (or (ignore-errors-x (scan-sexps (point) count)) (point-max)))
(prog1 (point)
! (c-forward-syntactic-ws)))
;;;===========================================================================
--- 1204,1210 ----
Return position before the comments after the last expression."
(goto-char (or (ignore-errors-x (scan-sexps (point) count)) (point-max)))
(prog1 (point)
! (antlr-c-forward-sws)))
;;;===========================================================================
***************
*** 1272,1278 ****
part."
(let ((pos (point))
(class nil))
! (c-forward-syntactic-ws)
(while (looking-at "options\\>\\|tokens\\>")
(setq class t)
(setq pos (antlr-skip-sexps 2)))
--- 1286,1292 ----
part."
(let ((pos (point))
(class nil))
! (antlr-c-forward-sws)
(while (looking-at "options\\>\\|tokens\\>")
(setq class t)
(setq pos (antlr-skip-sexps 2)))
***************
*** 1298,1304 ****
position before the comment after the header."
(let* ((pos (point))
(pos0 pos))
! (c-forward-syntactic-ws)
(if skip-comment (setq pos0 (point)))
(while (looking-at "header\\>[ \t]*\\(\"\\)?")
(setq pos (antlr-skip-sexps (if (match-beginning 1) 3 2))))
--- 1312,1318 ----
position before the comment after the header."
(let* ((pos (point))
(pos0 pos))
! (antlr-c-forward-sws)
(if skip-comment (setq pos0 (point)))
(while (looking-at "header\\>[ \t]*\\(\"\\)?")
(setq pos (antlr-skip-sexps (if (match-beginning 1) 3 2))))
***************
*** 1360,1366 ****
(let ((pos (point)))
(antlr-next-rule -1 nil)
(let ((between (or (bobp) (< (point) pos))))
! (c-forward-syntactic-ws)
(and between (> (point) pos) (goto-char pos)))))
--- 1374,1380 ----
(let ((pos (point)))
(antlr-next-rule -1 nil)
(let ((between (or (bobp) (< (point) pos))))
! (antlr-c-forward-sws)
(and between (> (point) pos) (goto-char pos)))))
***************
*** 1420,1426 ****
(or (antlr-search-forward ":") (point-max))))
(goto-char orig)
(error msg))
! (c-forward-syntactic-ws))))))
(defunx antlr-beginning-of-body ()
"Move to the first element after the `:' of the current rule."
--- 1434,1440 ----
(or (antlr-search-forward ":") (point-max))))
(goto-char orig)
(error msg))
! (antlr-c-forward-sws))))))
(defunx antlr-beginning-of-body ()
"Move to the first element after the `:' of the current rule."
***************
*** 1598,1604 ****
(defun antlr-insert-option-interactive (arg)
"Interactive specification for `antlr-insert-option'.
! Use prefix argument ARG to return \(LEVEL OPTION LOCATION)."
(barf-if-buffer-read-only)
(if arg (setq arg (prefix-numeric-value arg)))
(unless (memq arg '(nil 1 2 3 4))
--- 1612,1618 ----
(defun antlr-insert-option-interactive (arg)
"Interactive specification for `antlr-insert-option'.
! Return \(LEVEL OPTION LOCATION)."
(barf-if-buffer-read-only)
(if arg (setq arg (prefix-numeric-value arg)))
(unless (memq arg '(nil 1 2 3 4))
***************
*** 1627,1633 ****
:active active))
(sort (mapcar 'car (elt antlr-options-alists (1- level)))
'string-lessp))))
!
;;;===========================================================================
;;; Insert option: determine section-kind
--- 1641,1647 ----
:active active))
(sort (mapcar 'car (elt antlr-options-alists (1- level)))
'string-lessp))))
!
;;;===========================================================================
;;; Insert option: determine section-kind
***************
*** 1653,1659 ****
(setq pos (antlr-skip-file-prelude 'header-only)))
((not (eq level 3)) ; grammar or subrule options
(setq pos (point))
! (c-forward-syntactic-ws))
((looking-at "^\\(private[ \t\n]\\|public[ \t\n]\\|protected[
\t\n]\\)?[ \t\n]*\\(\\(\\sw\\|\\s_\\)+\\)[ \t\n]*\\(!\\)?[ \t\n]*\\(\\[\\)?")
;; rule options, with complete rule header
(goto-char (or (match-end 4) (match-end 3)))
--- 1667,1673 ----
(setq pos (antlr-skip-file-prelude 'header-only)))
((not (eq level 3)) ; grammar or subrule options
(setq pos (point))
! (antlr-c-forward-sws))
((looking-at "^\\(private[ \t\n]\\|public[ \t\n]\\|protected[
\t\n]\\)?[ \t\n]*\\(\\(\\sw\\|\\s_\\)+\\)[ \t\n]*\\(!\\)?[ \t\n]*\\(\\[\\)?")
;; rule options, with complete rule header
(goto-char (or (match-end 4) (match-end 3)))
***************
*** 1904,1910 ****
;; stuff (no =, {, } or /) at point is not followed by ";"
(insert ";")
(backward-char)))
!
(defun antlr-insert-option-space (area old)
"Find appropriate place to insert option, insert newlines/spaces.
For AREA and OLD, see `antlr-insert-option-do'."
--- 1918,1924 ----
;; stuff (no =, {, } or /) at point is not followed by ";"
(insert ";")
(backward-char)))
!
(defun antlr-insert-option-space (area old)
"Find appropriate place to insert option, insert newlines/spaces.
For AREA and OLD, see `antlr-insert-option-do'."
***************
*** 1924,1930 ****
(setq orig (point))
(goto-char orig)))
(skip-chars-forward " \t")
!
(if (looking-at "$\\|//")
;; just comment after point => skip (+ lines w/ same col comment)
(let ((same (if (> (match-end 0) (match-beginning 0))
--- 1938,1944 ----
(setq orig (point))
(goto-char orig)))
(skip-chars-forward " \t")
!
(if (looking-at "$\\|//")
;; just comment after point => skip (+ lines w/ same col comment)
(let ((same (if (> (match-end 0) (match-beginning 0))
***************
*** 1959,1965 ****
(when (and antlr-options-auto-colon
(memq level '(3 4))
(save-excursion
! (c-forward-syntactic-ws)
(if (eq (char-after (point)) ?\{) (antlr-skip-sexps 1))
(not (eq (char-after (point)) ?\:))))
(insert "\n:")
--- 1973,1979 ----
(when (and antlr-options-auto-colon
(memq level '(3 4))
(save-excursion
! (antlr-c-forward-sws)
(if (eq (char-after (point)) ?\{) (antlr-skip-sexps 1))
(not (eq (char-after (point)) ?\:))))
(insert "\n:")
***************
*** 2079,2090 ****
(evocab (or default-vocab class))
(ivocab nil))
(goto-char (match-end 0))
! (c-forward-syntactic-ws)
(while (looking-at "options\\>\\|\\(tokens\\)\\>")
(if (match-beginning 1)
(antlr-skip-sexps 2)
(goto-char (match-end 0))
! (c-forward-syntactic-ws)
;; parse grammar option sections -------------------------------
(when (eq (char-after (point)) ?\{)
(let* ((beg (1+ (point)))
--- 2093,2104 ----
(evocab (or default-vocab class))
(ivocab nil))
(goto-char (match-end 0))
! (antlr-c-forward-sws)
(while (looking-at "options\\>\\|\\(tokens\\)\\>")
(if (match-beginning 1)
(antlr-skip-sexps 2)
(goto-char (match-end 0))
! (antlr-c-forward-sws)
;; parse grammar option sections -------------------------------
(when (eq (char-after (point)) ?\{)
(let* ((beg (1+ (point)))
***************
*** 2341,2347 ****
(defun antlr-indent-line ()
"Indent the current line as ANTLR grammar code.
! The indentation of non-comment lines are calculated by `c-basic-offset',
multiplied by:
- the level of the paren/brace/bracket depth,
- plus 0/2/1, depending on the position inside the rule: header, body,
--- 2355,2361 ----
(defun antlr-indent-line ()
"Indent the current line as ANTLR grammar code.
! The indentation of grammar lines are calculated by `c-basic-offset',
multiplied by:
- the level of the paren/brace/bracket depth,
- plus 0/2/1, depending on the position inside the rule: header, body,
***************
*** 2484,2503 ****
;;; Mode entry
;;;===========================================================================
(defun antlr-c-common-init ()
! "Like `c-common-init' except menu, auto-hungry and c-style stuff."
;; X/Emacs 20 only
(make-local-variable 'paragraph-start)
(make-local-variable 'paragraph-separate)
(make-local-variable 'paragraph-ignore-fill-prefix)
(make-local-variable 'require-final-newline)
(make-local-variable 'parse-sexp-ignore-comments)
- (make-local-variable 'indent-line-function)
- (make-local-variable 'indent-region-function)
(make-local-variable 'comment-start)
- (make-local-variable 'comment-end)
- (make-local-variable 'comment-column)
- (make-local-variable 'comment-start-skip)
(make-local-variable 'comment-multi-line)
(make-local-variable 'outline-regexp)
(make-local-variable 'outline-level)
--- 2498,2543 ----
;;; Mode entry
;;;===========================================================================
+ (defun antlr-c-init-language-vars ()
+ "Like `c-init-language-vars-for' when using cc-mode before v5.29."
+ (let ((settings ; (cdr '(setq...)) will be optimized
+ (if (eq antlr-language 'c++-mode)
+ (cdr '(setq ;' from `c++-mode' v5.20, v5.28
+ c-keywords (c-identifier-re c-C++-keywords)
+ c-conditional-key c-C++-conditional-key
+ c-comment-start-regexp c-C++-comment-start-regexp
+ c-class-key c-C++-class-key
+ c-extra-toplevel-key c-C++-extra-toplevel-key
+ c-access-key c-C++-access-key
+ c-recognize-knr-p nil
+ c-bitfield-key c-C-bitfield-key ; v5.28
+ ))
+ (cdr '(setq ; from `java-mode' v5.20, v5.28
+ c-keywords (c-identifier-re c-Java-keywords)
+ c-conditional-key c-Java-conditional-key
+ c-comment-start-regexp c-Java-comment-start-regexp
+ c-class-key c-Java-class-key
+ c-method-key nil
+ c-baseclass-key nil
+ c-recognize-knr-p nil
+ c-access-key c-Java-access-key ; v5.20
+ c-inexpr-class-key c-Java-inexpr-class-key ; v5.28
+ )))))
+ (while settings
+ (when (boundp (car settings))
+ (ignore-errors
+ (set (car settings) (eval (cadr settings)))))
+ (setq settings (cddr settings)))))
+
(defun antlr-c-common-init ()
! "Like `c-basic-common-init' when using cc-mode before v5.30."
;; X/Emacs 20 only
(make-local-variable 'paragraph-start)
(make-local-variable 'paragraph-separate)
(make-local-variable 'paragraph-ignore-fill-prefix)
(make-local-variable 'require-final-newline)
(make-local-variable 'parse-sexp-ignore-comments)
(make-local-variable 'comment-start)
(make-local-variable 'comment-multi-line)
(make-local-variable 'outline-regexp)
(make-local-variable 'outline-level)
***************
*** 2515,2528 ****
(setq paragraph-start (concat page-delimiter "\\|$")
paragraph-separate paragraph-start
paragraph-ignore-fill-prefix t
- require-final-newline t
parse-sexp-ignore-comments t
- indent-line-function 'c-indent-line
- indent-region-function 'c-indent-region
- outline-regexp "[^#\n\^M]"
- outline-level 'c-outline-level
comment-column 32
- comment-start-skip "/\\*+ *\\|// *"
comment-multi-line nil
comment-line-break-function 'c-comment-line-break-function
adaptive-fill-regexp nil
--- 2555,2562 ----
***************
*** 2563,2576 ****
(setq r nil))) ; no result yet
(car r)))
-
;;;###autoload
(defun antlr-mode ()
"Major mode for editing ANTLR grammar files.
\\{antlr-mode-map}"
(interactive)
- (c-initialize-cc-mode) ; required when depending on cc-mode
(kill-all-local-variables)
;; ANTLR specific ----------------------------------------------------------
(setq major-mode 'antlr-mode
mode-name "Antlr")
--- 2597,2611 ----
(setq r nil))) ; no result yet
(car r)))
;;;###autoload
(defun antlr-mode ()
"Major mode for editing ANTLR grammar files.
\\{antlr-mode-map}"
(interactive)
(kill-all-local-variables)
+ (c-initialize-cc-mode) ; cc-mode is required
+ (unless (fboundp 'c-forward-sws) ; see above
+ (fset 'antlr-c-forward-sws 'c-forward-syntactic-ws))
;; ANTLR specific ----------------------------------------------------------
(setq major-mode 'antlr-mode
mode-name "Antlr")
***************
*** 2597,2638 ****
(concat "Antlr."
(cadr (assq antlr-language antlr-language-alist)))))
;; indentation, for the C engine -------------------------------------------
! (antlr-c-common-init)
(setq indent-line-function 'antlr-indent-line
indent-region-function nil) ; too lazy
- (setq c-buffer-is-cc-mode antlr-language)
- (if (fboundp 'c-init-language-vars)
- (c-init-language-vars) ; cc-mode >= v5.29
- (let ((settings ; (cdr '(setq...)) will be optimized
- (if (eq antlr-language 'c++-mode)
- (cdr '(setq ;' from `c++-mode' v5.20, v5.28
- c-keywords (c-identifier-re c-C++-keywords)
- c-conditional-key c-C++-conditional-key
- c-comment-start-regexp c-C++-comment-start-regexp
- c-class-key c-C++-class-key
- c-extra-toplevel-key c-C++-extra-toplevel-key
- c-access-key c-C++-access-key
- c-recognize-knr-p nil
- c-bitfield-key c-C-bitfield-key ; v5.28
- ))
- (cdr '(setq ; from `java-mode' v5.20, v5.28
- c-keywords (c-identifier-re c-Java-keywords)
- c-conditional-key c-Java-conditional-key
- c-comment-start-regexp c-Java-comment-start-regexp
- c-class-key c-Java-class-key
- c-method-key nil
- c-baseclass-key nil
- c-recognize-knr-p nil
- c-access-key c-Java-access-key ; v5.20
- c-inexpr-class-key c-Java-inexpr-class-key ; v5.28
- )))))
- (while settings
- (when (boundp (car settings))
- (ignore-errors
- (set (car settings) (eval (cadr settings)))))
- (setq settings (cddr settings)))))
(setq comment-start "// "
! comment-end "")
;; various -----------------------------------------------------------------
(make-local-variable 'font-lock-defaults)
(setq font-lock-defaults antlr-font-lock-defaults)
--- 2632,2665 ----
(concat "Antlr."
(cadr (assq antlr-language antlr-language-alist)))))
;; indentation, for the C engine -------------------------------------------
! (setq c-buffer-is-cc-mode antlr-language)
! (cond ((fboundp 'c-init-language-vars-for) ; cc-mode 5.30.5+
! (c-init-language-vars-for antlr-language))
! ((fboundp 'c-init-c-language-vars) ; cc-mode 5.30 to 5.30.4
! (c-init-c-language-vars) ; not perfect, but OK
! (setq c-recognize-knr-p nil))
! ((fboundp 'c-init-language-vars) ; cc-mode 5.29
! (let ((init-fn 'c-init-language-vars))
! (funcall init-fn))) ; is a function in v5.29
! (t ; cc-mode upto 5.28
! (antlr-c-init-language-vars))) ; do it myself
! (cond ((fboundp 'c-basic-common-init) ; cc-mode 5.30+
! (c-basic-common-init antlr-language (or antlr-indent-style "gnu")))
! (t
! (antlr-c-common-init)))
! (make-local-variable 'outline-regexp)
! (make-local-variable 'outline-level)
! (make-local-variable 'require-final-newline)
! (make-local-variable 'indent-line-function)
! (make-local-variable 'indent-region-function)
! (setq outline-regexp "[^#\n\^M]"
! outline-level 'c-outline-level) ; TODO: define own
! (setq require-final-newline t)
(setq indent-line-function 'antlr-indent-line
indent-region-function nil) ; too lazy
(setq comment-start "// "
! comment-end ""
! comment-start-skip "/\\*+ *\\|// *")
;; various -----------------------------------------------------------------
(make-local-variable 'font-lock-defaults)
(setq font-lock-defaults antlr-font-lock-defaults)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] Changes to emacs/lisp/progmodes/antlr-mode.el,
Richard M. Stallman <=