(defvar ada-mode-extra-prefix "\C-c\C-q"
"Prefix key to access `ada-mode-extra-map' functions.")
-(defvar ada-mode-abbrev-table nil
+(define-abbrev-table 'ada-mode-abbrev-table ()
"Local abbrev table for Ada mode.")
-(define-abbrev-table 'ada-mode-abbrev-table ())
-
-(defvar ada-mode-syntax-table nil
- "Syntax table to be used for editing Ada source code.")
-
-(defvar ada-mode-symbol-syntax-table nil
- "Syntax table for Ada, where `_' is a word constituent.")
(eval-when-compile
;; These values are used in eval-when-compile expressions.
;; better is available on XEmacs.
;;-------------------------------------------------------------------------
-(defun ada-create-syntax-table ()
- "Create the two syntax tables use in the Ada mode.
-The standard table declares `_' as a symbol constituent, the second one
-declares it as a word constituent."
- (interactive)
- (setq ada-mode-syntax-table (make-syntax-table))
-
- ;; define string brackets (`%' is alternative string bracket, but
- ;; almost never used as such and throws font-lock and indentation
- ;; off the track.)
- (modify-syntax-entry ?% "$" ada-mode-syntax-table)
- (modify-syntax-entry ?\" "\"" ada-mode-syntax-table)
-
- (modify-syntax-entry ?: "." ada-mode-syntax-table)
- (modify-syntax-entry ?\; "." ada-mode-syntax-table)
- (modify-syntax-entry ?& "." ada-mode-syntax-table)
- (modify-syntax-entry ?\| "." ada-mode-syntax-table)
- (modify-syntax-entry ?+ "." ada-mode-syntax-table)
- (modify-syntax-entry ?* "." ada-mode-syntax-table)
- (modify-syntax-entry ?/ "." ada-mode-syntax-table)
- (modify-syntax-entry ?= "." ada-mode-syntax-table)
- (modify-syntax-entry ?< "." ada-mode-syntax-table)
- (modify-syntax-entry ?> "." ada-mode-syntax-table)
- (modify-syntax-entry ?$ "." ada-mode-syntax-table)
- (modify-syntax-entry ?\[ "." ada-mode-syntax-table)
- (modify-syntax-entry ?\] "." ada-mode-syntax-table)
- (modify-syntax-entry ?\{ "." ada-mode-syntax-table)
- (modify-syntax-entry ?\} "." ada-mode-syntax-table)
- (modify-syntax-entry ?. "." ada-mode-syntax-table)
- (modify-syntax-entry ?\\ "." ada-mode-syntax-table)
- (modify-syntax-entry ?\' "." ada-mode-syntax-table)
-
- ;; a single hyphen is punctuation, but a double hyphen starts a comment
- (modify-syntax-entry ?- ". 12" ada-mode-syntax-table)
-
- ;; See the comment above on grammar related function for the special
- ;; setup for '#'.
- (if (featurep 'xemacs)
- (modify-syntax-entry ?# "<" ada-mode-syntax-table)
- (modify-syntax-entry ?# "$" ada-mode-syntax-table))
-
- ;; and \f and \n end a comment
- (modify-syntax-entry ?\f "> " ada-mode-syntax-table)
- (modify-syntax-entry ?\n "> " ada-mode-syntax-table)
-
- ;; define what belongs in Ada symbols
- (modify-syntax-entry ?_ "_" ada-mode-syntax-table)
-
- ;; define parentheses to match
- (modify-syntax-entry ?\( "()" ada-mode-syntax-table)
- (modify-syntax-entry ?\) ")(" ada-mode-syntax-table)
-
- (setq ada-mode-symbol-syntax-table (copy-syntax-table ada-mode-syntax-table))
- (modify-syntax-entry ?_ "w" ada-mode-symbol-syntax-table)
- )
+(defvar ada-mode-syntax-table
+ (let ((st (make-syntax-table)))
+ ;; Define string brackets (`%' is alternative string bracket, but
+ ;; almost never used as such and throws font-lock and indentation
+ ;; off the track.)
+ (modify-syntax-entry ?% "$" st)
+ (modify-syntax-entry ?\" "\"" st)
+
+ (modify-syntax-entry ?: "." st)
+ (modify-syntax-entry ?\; "." st)
+ (modify-syntax-entry ?& "." st)
+ (modify-syntax-entry ?\| "." st)
+ (modify-syntax-entry ?+ "." st)
+ (modify-syntax-entry ?* "." st)
+ (modify-syntax-entry ?/ "." st)
+ (modify-syntax-entry ?= "." st)
+ (modify-syntax-entry ?< "." st)
+ (modify-syntax-entry ?> "." st)
+ (modify-syntax-entry ?$ "." st)
+ (modify-syntax-entry ?\[ "." st)
+ (modify-syntax-entry ?\] "." st)
+ (modify-syntax-entry ?\{ "." st)
+ (modify-syntax-entry ?\} "." st)
+ (modify-syntax-entry ?. "." st)
+ (modify-syntax-entry ?\\ "." st)
+ (modify-syntax-entry ?\' "." st)
+
+ ;; A single hyphen is punctuation, but a double hyphen starts a comment.
+ (modify-syntax-entry ?- ". 12" st)
+
+ ;; See the comment above on grammar related function for the special
+ ;; setup for '#'.
+ (modify-syntax-entry ?# (if (featurep 'xemacs) "<" "$") st)
+
+ ;; And \f and \n end a comment.
+ (modify-syntax-entry ?\f "> " st)
+ (modify-syntax-entry ?\n "> " st)
+
+ ;; Define what belongs in Ada symbols.
+ (modify-syntax-entry ?_ "_" st)
+
+ ;; Define parentheses to match.
+ (modify-syntax-entry ?\( "()" st)
+ (modify-syntax-entry ?\) ")(" st)
+ st)
+ "Syntax table to be used for editing Ada source code.")
+
+(defvar ada-mode-symbol-syntax-table
+ (let ((st (make-syntax-table ada-mode-syntax-table)))
+ (modify-syntax-entry ?_ "w" st)
+ st)
+ "Syntax table for Ada, where `_' is a word constituent.")
;; Support of special characters in XEmacs (see the comments at the beginning
;; of the section on Grammar related functions).
(if ada-popup-key
(define-key ada-mode-map ada-popup-key 'ada-popup-menu))
- ;; Support for Abbreviations (the user still need to "M-x abbrev-mode"
+ ;; Support for Abbreviations (the user still needs to "M-x abbrev-mode").
(setq local-abbrev-table ada-mode-abbrev-table)
;; Support for which-function mode
(let ((lastk last-command-event))
(with-syntax-table ada-mode-symbol-syntax-table
- (cond ((or (eq lastk ?\n)
- (eq lastk ?\r))
- ;; horrible kludge
+ (cond ((memq lastk '(?\n ?\r))
+ ;; Horrible kludge.
(insert " ")
(ada-adjust-case)
;; horrible dekludge
(interactive)
(let ((end (save-excursion (skip-syntax-forward "w") (point)))
(begin (save-excursion (skip-syntax-backward "w") (point))))
- (modify-syntax-entry ?_ "_")
- (capitalize-region begin end)
- (modify-syntax-entry ?_ "w")))
+ (capitalize-region begin end)))
(defun ada-adjust-case-region (from to)
"Adjust the case of all words in the region between FROM and TO.
(unwind-protect
(with-syntax-table ada-mode-symbol-syntax-table
- ;; This need to be done here so that the advice is not always
+ ;; This needs to be done here so that the advice is not always
;; activated (this might interact badly with other modes)
(if (featurep 'xemacs)
(ad-activate 'parse-partial-sexp t))
If BACKWARD is non-nil, jump to the beginning of the previous word.
Return the new position of point or nil if not found."
(let ((match-cons nil)
- (orgpoint (point))
- (old-syntax (char-to-string (char-syntax ?_))))
- (modify-syntax-entry ?_ "w")
+ (orgpoint (point)))
(unless backward
- (skip-syntax-forward "w"))
+ (skip-syntax-forward "w_"))
(if (setq match-cons
- (ada-search-ignore-string-comment "\\w" backward nil t))
+ (ada-search-ignore-string-comment "\\sw\\|\\s_" backward nil t))
;;
;; move to the beginning of the word found
;;
(progn
(goto-char (car match-cons))
- (skip-syntax-backward "w")
+ (skip-syntax-backward "w_")
(point))
;;
;; if not found, restore old position of point
;;
(goto-char orgpoint)
- 'nil)
- (modify-syntax-entry ?_ old-syntax))
- )
+ 'nil)))
(defun ada-check-matching-start (keyword)
(ada-create-keymap)
(ada-create-menu)
-;; Create the syntax tables, but do not activate them
-(ada-create-syntax-table)
-
;; Add the default extensions (and set up speedbar)
(ada-add-extensions ".ads" ".adb")
;; This two files are generated by GNAT when running with -gnatD
"Keyword-regexp for font-lock level >= 3.")
(defconst f90-procedures-re
- (concat "\\<"
+ (concat "\\_<"
(regexp-opt
'("abs" "achar" "acos" "adjustl" "adjustr" "aimag" "aint"
"all" "allocated" "anint" "any" "asin" "associated"
Set the match data so that subexpression 1,2 are the TYPE, and
type-name parts, respectively."
(let (found l)
- (while (and (re-search-forward "\\<\\(\\(?:end[ \t]*\\)?type\\)\\>[ \t]*"
+ (while (and (re-search-forward "\\_<\\(\\(?:end[ \t]*\\)?type\\)\\_>[ \t]*"
limit t)
(not (setq found
(progn
(setq l (match-data))
- (unless (looking-at "\\(is\\>\\|(\\)")
- (when (if (looking-at "\\(\\sw+\\)")
+ (unless (looking-at "\\(is\\_>\\|(\\)")
+ (when (if (looking-at "\\(\\(?:\\sw\\|\\s_\\)+\\)")
(goto-char (match-end 0))
(re-search-forward
- "[ \t]*::[ \t]*\\(\\sw+\\)"
+ "[ \t]*::[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)"
(line-end-position) t))
;; 0 is wrong, but we don't use it.
(set-match-data
(defvar f90-font-lock-keywords-1
(list
;; Special highlighting of "module procedure".
- '("\\<\\(module[ \t]*procedure\\)\\>\\([^()\n]*::\\)?[ \t]*\\([^&!\n]*\\)"
+ '("\\_<\\(module[ \t]*procedure\\)\\_>\\([^()\n]*::\\)?[ \t]*\\([^&!\n]*\\)"
(1 font-lock-keyword-face) (3 font-lock-function-name-face nil t))
;; Highlight definition of derived type.
-;;; '("\\<\\(\\(?:end[ \t]*\\)?type\\)\\>\\([^()\n]*::\\)?[ \t]*\\(\\sw+\\)"
+;;; '("\\_<\\(\\(?:end[ \t]*\\)?type\\)\\_>\\([^()\n]*::\\)?[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)"
;;; (1 font-lock-keyword-face) (3 font-lock-function-name-face))
'(f90-typedef-matcher
(1 font-lock-keyword-face) (2 font-lock-function-name-face))
;; F2003. Prevent operators being highlighted as functions.
- '("\\<\\(\\(?:end[ \t]*\\)?interface[ \t]*\\(?:assignment\\|operator\\|\
+ '("\\_<\\(\\(?:end[ \t]*\\)?interface[ \t]*\\(?:assignment\\|operator\\|\
read\\|write\\)\\)[ \t]*(" (1 font-lock-keyword-face t))
;; Other functions and declarations. Named interfaces = F2003.
;; F2008: end submodule submodule_name.
- '("\\<\\(\\(?:end[ \t]*\\)?\\(program\\|\\(?:sub\\)?module\\|\
+ '("\\_<\\(\\(?:end[ \t]*\\)?\\(program\\|\\(?:sub\\)?module\\|\
function\\|associate\\|subroutine\\|interface\\)\\|use\\|call\\)\
-\\>[ \t]*\\(\\sw+\\)?"
+\\_>[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)?"
(1 font-lock-keyword-face) (3 font-lock-function-name-face nil t))
;; F2008: submodule (parent_name) submodule_name.
- '("\\<\\(submodule\\)\\>[ \t]*([^)\n]+)[ \t]*\\(\\sw+\\)?"
+ '("\\_<\\(submodule\\)\\_>[ \t]*([^)\n]+)[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)?"
(1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))
;; F2003.
- '("\\<\\(use\\)[ \t]*,[ \t]*\\(\\(?:non_\\)?intrinsic\\)[ \t]*::[ \t]*\
-\\(\\sw+\\)"
+ '("\\_<\\(use\\)[ \t]*,[ \t]*\\(\\(?:non_\\)?intrinsic\\)[ \t]*::[ \t]*\
+\\(\\(?:\\sw\\|\\s_\\)+\\)"
(1 font-lock-keyword-face) (2 font-lock-keyword-face)
(3 font-lock-function-name-face))
- "\\<\\(\\(end[ \t]*\\)?block[ \t]*data\\|contains\\)\\>"
+ "\\_<\\(\\(end[ \t]*\\)?block[ \t]*data\\|contains\\)\\_>"
;; "abstract interface" is F2003.
- '("\\<abstract[ \t]*interface\\>" (0 font-lock-keyword-face t)))
+ '("\\_<abstract[ \t]*interface\\_>" (0 font-lock-keyword-face t)))
"This does fairly subdued highlighting of comments and function calls.")
;; NB not explicitly handling this, yet it seems to work.
;; Matcher functions must return nil only when there are no more
;; matches within the search range.
(let (found l)
- (while (and (re-search-forward "\\<\\(type\\|class\\)[ \t]*(" limit t)
+ (while (and (re-search-forward "\\_<\\(type\\|class\\)[ \t]*(" limit t)
(not
(setq found
(condition-case nil
(when
(re-search-forward
;; type (foo) bar, qux
- (if (looking-at "\\sw+")
+ (if (looking-at "\\(?:\\sw\\|\\s_\\)+")
"\\([^&!\n]+\\)"
;; type (foo), stuff :: bar, qux
"::[ \t]*\\([^&!\n]+\\)")
;; integer( kind=1 ) function foo()
;; thanks to the happy accident described above.
;; Not anchored, so don't need to worry about "pure" etc.
- '("\\<\\(\\(real\\|integer\\|c\\(haracter\\|omplex\\)\\|\
+ '("\\_<\\(\\(real\\|integer\\|c\\(haracter\\|omplex\\)\\|\
logical\\|double[ \t]*precision\\|\
-\\(?:type\\|class\\)[ \t]*([ \t]*\\sw+[ \t]*)\\)[ \t]*\\)\
-\\(function\\)\\>[ \t]*\\(\\sw+\\)[ \t]*\\(([^&!\n]*)\\)"
+\\(?:type\\|class\\)[ \t]*([ \t]*\\(?:\\sw\\|\\s_\\)+[ \t]*)\\)[ \t]*\\)\
+\\(function\\)\\_>[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)[ \t]*\\(([^&!\n]*)\\)"
(1 font-lock-type-face t) (4 font-lock-keyword-face t)
(5 font-lock-function-name-face t) (6 'default t))
;; enum (F2003; must be followed by ", bind(C)").
- '("\\<\\(enum\\)[ \t]*," (1 font-lock-keyword-face))
+ '("\\_<\\(enum\\)[ \t]*," (1 font-lock-keyword-face))
;; end do, enum (F2003), if, select, where, and forall constructs.
;; block, critical (F2008).
;; Note that "block data" may get somewhat mixed up with F2008 blocks,
;; but since the former is obsolete I'm not going to worry about it.
- '("\\<\\(end[ \t]*\\(do\\|if\\|enum\\|select\\|forall\\|where\\|\
-block\\|critical\\)\\)\\>\
-\\([ \t]+\\(\\sw+\\)\\)?"
+ '("\\_<\\(end[ \t]*\\(do\\|if\\|enum\\|select\\|forall\\|where\\|\
+block\\|critical\\)\\)\\_>\
+\\([ \t]+\\(\\(?:\\sw\\|\\s_\\)+\\)\\)?"
(1 font-lock-keyword-face) (3 font-lock-constant-face nil t))
- '("^[ \t0-9]*\\(\\(\\sw+\\)[ \t]*:[ \t]*\\)?\\(\\(if\\|\
+ '("^[ \t0-9]*\\(\\(\\(?:\\sw\\|\\s_\\)+\\)[ \t]*:[ \t]*\\)?\\(\\(if\\|\
do\\([ \t]*while\\)?\\|select[ \t]*\\(?:case\\|type\\)\\|where\\|\
-forall\\|block\\|critical\\)\\)\\>"
+forall\\|block\\|critical\\)\\)\\_>"
(2 font-lock-constant-face nil t) (3 font-lock-keyword-face))
;; Implicit declaration.
- '("\\<\\(implicit\\)[ \t]*\\(real\\|integer\\|c\\(haracter\\|omplex\\)\
+ '("\\_<\\(implicit\\)[ \t]*\\(real\\|integer\\|c\\(haracter\\|omplex\\)\
\\|enumerator\\|procedure\\|\
-logical\\|double[ \t]*precision\\|type[ \t]*(\\sw+)\\|none\\)[ \t]*"
+logical\\|double[ \t]*precision\\|type[ \t]*(\\(?:\\sw\\|\\s_\\)+)\\|none\\)[ \t]*"
(1 font-lock-keyword-face) (2 font-lock-type-face))
- '("\\<\\(namelist\\|common\\)[ \t]*\/\\(\\sw+\\)?\/"
+ '("\\_<\\(namelist\\|common\\)[ \t]*\/\\(\\(?:\\sw\\|\\s_\\)+\\)?\/"
(1 font-lock-keyword-face) (2 font-lock-constant-face nil t))
- "\\<else\\([ \t]*if\\|where\\)?\\>"
+ "\\_<else\\([ \t]*if\\|where\\)?\\_>"
'("\\(&\\)[ \t]*\\(!\\|$\\)" (1 font-lock-keyword-face))
- "\\<\\(then\\|continue\\|format\\|include\\|stop\\|return\\)\\>"
- '("\\<\\(exit\\|cycle\\)[ \t]*\\(\\sw+\\)?\\>"
+ "\\_<\\(then\\|continue\\|format\\|include\\|stop\\|return\\)\\_>"
+ '("\\_<\\(exit\\|cycle\\)[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)?\\_>"
(1 font-lock-keyword-face) (2 font-lock-constant-face nil t))
- '("\\<\\(case\\)[ \t]*\\(default\\|(\\)" . 1)
+ '("\\_<\\(case\\)[ \t]*\\(default\\|(\\)" . 1)
;; F2003 "class default".
- '("\\<\\(class\\)[ \t]*default" . 1)
+ '("\\_<\\(class\\)[ \t]*default" . 1)
;; F2003 "type is" in a "select type" block.
- '("\\<\\(\\(type\\|class\\)[ \t]*is\\)[ \t]*(" (1 font-lock-keyword-face t))
- '("\\<\\(do\\|go[ \t]*to\\)\\>[ \t]*\\([0-9]+\\)"
+ '("\\_<\\(\\(type\\|class\\)[ \t]*is\\)[ \t]*(" (1 font-lock-keyword-face t))
+ '("\\_<\\(do\\|go[ \t]*to\\)\\_>[ \t]*\\([0-9]+\\)"
(1 font-lock-keyword-face) (2 font-lock-constant-face))
;; Line numbers (lines whose first character after number is letter).
'("^[ \t]*\\([0-9]+\\)[ \t]*[a-z]+" (1 font-lock-constant-face t))
;; Override eg for "#include".
- '("^#[ \t]*\\w+" (0 font-lock-preprocessor-face t)
- ("\\<defined\\>" nil nil (0 font-lock-preprocessor-face)))
+ '("^#[ \t]*\\(?:\\sw\\|\\s_\\)+" (0 font-lock-preprocessor-face t)
+ ("\\_<defined\\_>" nil nil (0 font-lock-preprocessor-face)))
'("^#" ("\\(&&\\|||\\)" nil nil (0 font-lock-constant-face t)))
- '("^#[ \t]*define[ \t]+\\(\\w+\\)(" (1 font-lock-function-name-face))
- '("^#[ \t]*define[ \t]+\\(\\w+\\)" (1 font-lock-variable-name-face))
+ '("^#[ \t]*define[ \t]+\\(\\(?:\\sw\\|\\s_\\)+\\)(" (1 font-lock-function-name-face))
+ '("^#[ \t]*define[ \t]+\\(\\(?:\\sw\\|\\s_\\)+\\)" (1 font-lock-variable-name-face))
'("^#[ \t]*include[ \t]+\\(<.+>\\)" (1 font-lock-string-face))))
"Highlights declarations, do-loops and other constructs.")
;; FIXME why isn't this font-lock-builtin-face, which
;; otherwise we hardly use, as in fortran.el?
(list f90-procedures-re '(1 font-lock-keyword-face keep))
- "\\<real\\>" ; avoid overwriting real defs
+ "\\_<real\\_>" ; avoid overwriting real defs
;; As an attribute, but not as an optional argument.
- '("\\<\\(asynchronous\\)[ \t]*[^=]" . 1)))
+ '("\\_<\\(asynchronous\\)[ \t]*[^=]" . 1)))
"Highlights all F90 keywords and intrinsic procedures.")
(defvar f90-font-lock-keywords-4
(let ((table (make-syntax-table)))
(modify-syntax-entry ?\! "<" table) ; begin comment
(modify-syntax-entry ?\n ">" table) ; end comment
- ;; FIXME: This goes against the convention: it should be "_".
- (modify-syntax-entry ?_ "w" table) ; underscore in names
+ (modify-syntax-entry ?_ "_" table) ; underscore in names
(modify-syntax-entry ?\' "\"" table) ; string quote
(modify-syntax-entry ?\" "\"" table) ; string quote
;; FIXME: We used to set ` to word syntax for the benefit of abbrevs, but
"enum" "associate"
;; F2008.
"submodule" "block" "critical"))
- "\\)\\>")
+ "\\)\\_>")
"Regexp potentially indicating a \"block\" of F90 code.")
(defconst f90-program-block-re
(defconst f90-end-if-re
(concat "end[ \t]*"
(regexp-opt '("if" "select" "where" "forall") 'paren)
- "\\>")
+ "\\_>")
"Regexp matching the end of an IF, SELECT, WHERE, FORALL block.")
(defconst f90-end-type-re
- "end[ \t]*\\(type\\|enum\\|interface\\|block[ \t]*data\\)\\>"
+ "end[ \t]*\\(type\\|enum\\|interface\\|block[ \t]*data\\)\\_>"
"Regexp matching the end of a TYPE, ENUM, INTERFACE, BLOCK DATA section.")
(defconst f90-end-associate-re
- "end[ \t]*associate\\>"
+ "end[ \t]*associate\\_>"
"Regexp matching the end of an ASSOCIATE block.")
;; This is for a TYPE block, not a variable of derived TYPE.
;; type, stuff :: word
;; type, bind(c) :: word
;; NOT "type ("
- "\\<\\(type\\)\\>\\(?:\\(?:[^()\n]*\\|\
-.*,[ \t]*bind[ \t]*([ \t]*c[ \t]*)[ \t]*\\)::\\)?[ \t]*\\(\\sw+\\)"
+ "\\_<\\(type\\)\\_>\\(?:\\(?:[^()\n]*\\|\
+.*,[ \t]*bind[ \t]*([ \t]*c[ \t]*)[ \t]*\\)::\\)?[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)"
"Regexp matching the definition of a derived type.")
(defconst f90-typeis-re
- "\\<\\(class\\|type\\)[ \t]*is[ \t]*("
+ "\\_<\\(class\\|type\\)[ \t]*is[ \t]*("
"Regexp matching a CLASS/TYPE IS statement.")
(defconst f90-no-break-re
\f
;; Hideshow support.
(defconst f90-end-block-re
- (concat "^[ \t0-9]*\\<end[ \t]*"
+ (concat "^[ \t0-9]*\\_<end[ \t]*"
(regexp-opt '("do" "if" "forall" "function" "interface"
"module" "program" "select" "subroutine"
"type" "where" "enum" "associate" "submodule"
"block" "critical") t)
- "\\>")
+ "\\_>")
"Regexp matching the end of an F90 \"block\", from the line start.
Used in the F90 entry in `hs-special-modes-alist'.")
(concat
"^[ \t0-9]*" ; statement number
"\\(\\("
- "\\(\\sw+[ \t]*:[ \t]*\\)?" ; structure label
+ "\\(\\(?:\\sw\\|\\s_\\)+[ \t]*:[ \t]*\\)?" ; structure label
"\\(do\\|select[ \t]*\\(case\\|type\\)\\|"
;; See comments in fortran-start-block-re for the problems of IF.
"if[ \t]*(\\(.*\\|"
- ".*\n\\([^if]*\\([^i].\\|.[^f]\\|.\\>\\)\\)\\)\\<then\\|"
+ ".*\n\\([^if]*\\([^i].\\|.[^f]\\|.\\_>\\)\\)\\)\\_<then\\|"
;; Distinguish WHERE block from isolated WHERE.
"\\(where\\|forall\\)[ \t]*(.*)[ \t]*\\(!\\|$\\)\\)\\)"
"\\|"
"type[ \t,]\\("
"[^i(!\n\"\& \t]\\|" ; not-i(
"i[^s!\n\"\& \t]\\|" ; i not-s
- "is\\sw\\)\\|"
+ "is\\(?:\\sw\\|\\s_\\)\\)\\|"
;; "abstract interface" is F2003; "submodule" is F2008.
"program\\|\\(?:abstract[ \t]*\\)?interface\\|\\(?:sub\\)?module\\|"
;; "enum", but not "enumerator".
(not (setq found
(save-excursion
(goto-char (match-end 0))
- (unless (looking-at "\\(is\\>\\|(\\)")
- (or (looking-at "\\(\\sw+\\)")
+ (unless (looking-at "\\(is\\_>\\|(\\)")
+ (or (looking-at "\\(\\(?:\\sw\\|\\s_\\)+\\)")
(re-search-forward
- "[ \t]*::[ \t]*\\(\\sw+\\)"
+ "[ \t]*::[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)"
(line-end-position) t))))))))
found))
(not-n "[^n!\n\"\& \t]") (not-d "[^d!\n\"\& \t]")
;; (not-ib "[^i(!\n\"\& \t]") (not-s "[^s!\n\"\& \t]")
)
- (list
- '(nil "^[ \t0-9]*program[ \t]+\\(\\sw+\\)" 1)
- '("Submodules" "^[ \t0-9]*submodule[ \t]*([^)\n]+)[ \t]*\
-\\(\\sw+\\)[ \t]*\\(!\\|$\\)" 1)
- '("Modules" "^[ \t0-9]*module[ \t]+\\(\\sw+\\)[ \t]*\\(!\\|$\\)" 1)
- (list "Types" 'f90-imenu-type-matcher 1)
- ;; Does not handle: "type[, stuff] :: foo".
-;;; (format "^[ \t0-9]*type[ \t]+\\(\\(%s\\|i%s\\|is\\sw\\)\\sw*\\)"
-;;; not-ib not-s)
-;;; 1)
- ;; Can't get the subexpression numbers to match in the two branches.
-;;; (format "^[ \t0-9]*type\\([ \t]*,.*\\(::\\)[ \t]*\\(\\sw+\\)\\|[ \t]+\\(\\(%s\\|i%s\\|is\\sw\\)\\sw*\\)\\)" not-ib not-s)
-;;; 3)
- (list
- "Procedures"
- (concat
- "^[ \t0-9]*"
- "\\("
- ;; At least three non-space characters before function/subroutine.
- ;; Check that the last three non-space characters do not spell E N D.
- "[^!\"\&\n]*\\("
- not-e good-char good-char "\\|"
- good-char not-n good-char "\\|"
- good-char good-char not-d "\\)"
- "\\|"
- ;; Less than three non-space characters before function/subroutine.
- good-char "?" good-char "?"
- "\\)"
- "[ \t]*\\(function\\|subroutine\\)[ \t]+\\(\\sw+\\)")
- 4)))
+ `((nil "^[ \t0-9]*program[ \t]+\\(\\(?:\\sw\\|\\s_\\)+\\)" 1)
+ ("Submodules" "^[ \t0-9]*submodule[ \t]*([^)\n]+)[ \t]*\
+\\(\\(?:\\sw\\|\\s_\\)+\\)[ \t]*\\(!\\|$\\)" 1)
+ ("Modules" "^[ \t0-9]*module[ \t]+\\(\\(?:\\sw\\|\\s_\\)+\\)[ \t]*\\(!\\|$\\)" 1)
+ '("Types" f90-imenu-type-matcher 1)
+ ;; Does not handle: "type[, stuff] :: foo".
+ ;;(format "^[ \t0-9]*type[ \t]+\\(\\(%s\\|i%s\\|is\\(?:\\sw\\|\\s_\\)\\)\\(?:\\sw\\|\\s_\\)*\\)"
+ ;; not-ib not-s)
+ ;;1)
+ ;; Can't get the subexpression numbers to match in the two branches.
+ ;; FIXME: Now with \(?N:..\) we can get the numbers to match!
+ ;;(format "^[ \t0-9]*type\\([ \t]*,.*\\(::\\)[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)\\|[ \t]+\\(\\(%s\\|i%s\\|is\\(?:\\sw\\|\\s_\\)\\)\\(?:\\sw\\|\\s_\\)*\\)\\)" not-ib not-s)
+ ;;3)
+ ("Procedures"
+ ,(concat
+ "^[ \t0-9]*"
+ "\\("
+ ;; At least three non-space characters before function/subroutine.
+ ;; Check that the last three non-space characters do not spell E N D.
+ "[^!\"\&\n]*\\("
+ not-e good-char good-char "\\|"
+ good-char not-n good-char "\\|"
+ good-char good-char not-d "\\)"
+ "\\|"
+ ;; Less than three non-space characters before function/subroutine.
+ good-char "?" good-char "?"
+ "\\)"
+ "[ \t]*\\(function\\|subroutine\\)[ \t]+\\(\\(?:\\sw\\|\\s_\\)+\\)")
+ 4)))
"Value for `imenu-generic-expression' in F90 mode.")
(defun f90-add-imenu-menu ()
whether to blink the matching beginning (default 'blink).
`f90-auto-keyword-case'
Automatic change of case of keywords (default nil).
- The possibilities are 'downcase-word, 'upcase-word, 'capitalize-word.
+ The possibilities are `downcase-word', `upcase-word', `capitalize-word'.
`f90-leave-line-no'
Do not left-justify line numbers (default nil).
(defsubst f90-looking-at-do ()
"Return (\"do\" NAME) if a do statement starts after point.
NAME is nil if the statement has no label."
- (if (looking-at "\\(\\(\\sw+\\)[ \t]*:\\)?[ \t]*\\(do\\)\\>")
+ (if (looking-at "\\(\\(\\(?:\\sw\\|\\s_\\)+\\)[ \t]*:\\)?[ \t]*\\(do\\)\\_>")
(list (match-string 3) (match-string 2))))
(defsubst f90-looking-at-select-case ()
"Return (\"select\" NAME) if a select statement starts after point.
NAME is nil if the statement has no label."
- (if (looking-at "\\(\\(\\sw+\\)[ \t]*:\\)?[ \t]*\
+ (if (looking-at "\\(\\(\\(?:\\sw\\|\\s_\\)+\\)[ \t]*:\\)?[ \t]*\
\\(select\\)[ \t]*\\(case\\|type\\)[ \t]*(")
(list (match-string 3) (match-string 2))))
"Return (\"if\" NAME) if an if () then statement starts after point.
NAME is nil if the statement has no label."
(save-excursion
- (when (looking-at "\\(\\(\\sw+\\)[ \t]*:\\)?[ \t]*\\(if\\)\\>")
+ (when (looking-at "\\(\\(\\(?:\\sw\\|\\s_\\)+\\)[ \t]*:\\)?[ \t]*\\(if\\)\\_>")
(let ((struct (match-string 3))
(label (match-string 2))
(pos (scan-lists (point) 1 0)))
(and pos (goto-char pos))
(skip-chars-forward " \t")
- (if (or (looking-at "then\\>")
+ (if (or (looking-at "then\\_>")
(when (f90-line-continued)
(f90-next-statement)
(skip-chars-forward " \t0-9&")
- (looking-at "then\\>")))
+ (looking-at "then\\_>")))
(list struct label))))))
;; FIXME label?
(defsubst f90-looking-at-associate ()
"Return (\"associate\") if an associate block starts after point."
- (if (looking-at "\\<\\(associate\\)[ \t]*(")
+ (if (looking-at "\\_<\\(associate\\)[ \t]*(")
(list (match-string 1))))
(defsubst f90-looking-at-critical ()
"Return (KIND NAME) if a critical or block block starts after point."
- (if (looking-at "\\(\\(\\sw+\\)[ \t]*:\\)?[ \t]*\\(critical\\|block\\)\\>")
+ (if (looking-at "\\(\\(\\(?:\\sw\\|\\s_\\)+\\)[ \t]*:\\)?[ \t]*\\(critical\\|block\\)\\_>")
(let ((struct (match-string 3))
(label (match-string 2)))
(if (or (not (string-equal "block" struct))
(save-excursion
(skip-chars-forward " \t")
- (not (looking-at "data\\>"))))
+ (not (looking-at "data\\_>"))))
(list struct label)))))
(defsubst f90-looking-at-end-critical ()
"Return non-nil if a critical or block block ends after point."
- (if (looking-at "end[ \t]*\\(critical\\|block\\)\\>")
+ (if (looking-at "end[ \t]*\\(critical\\|block\\)\\_>")
(or (not (string-equal "block" (match-string 1)))
(save-excursion
(skip-chars-forward " \t")
- (not (looking-at "data\\>"))))))
+ (not (looking-at "data\\_>"))))))
(defsubst f90-looking-at-where-or-forall ()
"Return (KIND NAME) if a where or forall block starts after point.
NAME is nil if the statement has no label."
(save-excursion
- (when (looking-at "\\(\\(\\sw+\\)[ \t]*:\\)?[ \t]*\
-\\(where\\|forall\\)\\>")
+ (when (looking-at "\\(\\(\\(?:\\sw\\|\\s_\\)+\\)[ \t]*:\\)?[ \t]*\
+\\(where\\|forall\\)\\_>")
(let ((struct (match-string 3))
(label (match-string 2))
(pos (scan-lists (point) 1 0)))
NAME is non-nil only for type and certain interfaces."
(cond
((save-excursion
- (and (looking-at "\\<type\\>[ \t]*")
+ (and (looking-at "\\_<type\\_>[ \t]*")
(goto-char (match-end 0))
- (not (looking-at "\\(is\\>\\|(\\)"))
- (or (looking-at "\\(\\sw+\\)")
- (re-search-forward "[ \t]*::[ \t]*\\(\\sw+\\)"
+ (not (looking-at "\\(is\\_>\\|(\\)"))
+ (or (looking-at "\\(\\(?:\\sw\\|\\s_\\)+\\)")
+ (re-search-forward "[ \t]*::[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)"
(line-end-position) t))))
(list "type" (match-string 1)))
;;; ((and (not (looking-at f90-typeis-re))
;;; (looking-at f90-type-def-re))
;;; (list (match-string 1) (match-string 2)))
- ((looking-at "\\<\\(interface\\)\\>[ \t]*")
+ ((looking-at "\\_<\\(interface\\)\\_>[ \t]*")
(list (match-string 1)
(save-excursion
(goto-char (match-end 0))
(if (or (looking-at "\\(operator\\|assignment\\|read\\|\
write\\)[ \t]*([^)\n]*)")
- (looking-at "\\sw+"))
+ (looking-at "\\(?:\\sw\\|\\s_\\)+"))
(match-string 0)))))
- ((looking-at "\\(enum\\|block[ \t]*data\\)\\>")
+ ((looking-at "\\(enum\\|block[ \t]*data\\)\\_>")
(list (match-string 1) nil))
- ((looking-at "abstract[ \t]*\\(interface\\)\\>")
+ ((looking-at "abstract[ \t]*\\(interface\\)\\_>")
(list (match-string 1) nil))))
(defsubst f90-looking-at-program-block-start ()
"Return (KIND NAME) if a program block with name NAME starts after point."
;;;NAME is nil for an un-named main PROGRAM block."
(cond
- ((looking-at "\\(program\\)[ \t]+\\(\\sw+\\)\\>")
+ ((looking-at "\\(program\\)[ \t]+\\(\\(?:\\sw\\|\\s_\\)+\\)\\_>")
(list (match-string 1) (match-string 2)))
- ((and (not (looking-at "module[ \t]*procedure\\>"))
- (looking-at "\\(module\\)[ \t]+\\(\\sw+\\)\\>"))
+ ((and (not (looking-at "module[ \t]*procedure\\_>"))
+ (looking-at "\\(module\\)[ \t]+\\(\\(?:\\sw\\|\\s_\\)+\\)\\_>"))
(list (match-string 1) (match-string 2)))
- ((looking-at "\\(submodule\\)[ \t]*([^)\n]+)[ \t]*\\(\\sw+\\)\\>")
+ ((looking-at "\\(submodule\\)[ \t]*([^)\n]+)[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)\\_>")
(list (match-string 1) (match-string 2)))
((and (not (looking-at "end[ \t]*\\(function\\|subroutine\\)"))
(looking-at "[^!'\"\&\n]*\\(function\\|subroutine\\)[ \t]+\
-\\(\\sw+\\)"))
+\\(\\(?:\\sw\\|\\s_\\)+\\)"))
(list (match-string 1) (match-string 2)))))
;; Following will match an un-named main program block; however
;; one needs to check if there is an actual PROGRAM statement after
\\(?:assignment\\|operator\\|read\\|write\\)[ \t]*([^)\n]*)\\)")
(list (match-string 1) (match-string 2)))
((looking-at (concat "end[ \t]*" f90-blocks-re
- "?\\([ \t]+\\(\\sw+\\)\\)?\\>"))
+ "?\\([ \t]+\\(\\(?:\\sw\\|\\s_\\)+\\)\\)?\\_>"))
(list (match-string 1) (match-string 3)))))
(defsubst f90-comment-indent ()
(not (or (looking-at "end")
(looking-at "\\(do\\|if\\|else\\(if\\|where\\)?\
\\|select[ \t]*\\(case\\|type\\)\\|case\\|where\\|forall\\|\
-block\\|critical\\)\\>")
+block\\|critical\\)\\_>")
(looking-at "\\(program\\|\\(?:sub\\)?module\\|\
-\\(?:abstract[ \t]*\\)?interface\\|block[ \t]*data\\)\\>")
- (looking-at "\\(contains\\|\\sw+[ \t]*:\\)")
+\\(?:abstract[ \t]*\\)?interface\\|block[ \t]*data\\)\\_>")
+ (looking-at "\\(contains\\|\\(?:\\sw\\|\\s_\\)+[ \t]*:\\)")
(looking-at f90-type-def-re)
(re-search-forward "\\(function\\|subroutine\\)"
(line-end-position) t)))))
(setq icol (- icol f90-associate-indent)))
((f90-looking-at-end-critical)
(setq icol (- icol f90-critical-indent)))
- ((looking-at "end[ \t]*do\\>")
+ ((looking-at "end[ \t]*do\\_>")
(setq icol (- icol f90-do-indent))))
(end-of-line))
icol)))
(cond ((or (looking-at f90-else-like-re)
(looking-at f90-end-if-re))
(setq icol (- icol f90-if-indent)))
- ((looking-at "end[ \t]*do\\>")
+ ((looking-at "end[ \t]*do\\_>")
(setq icol (- icol f90-do-indent)))
((looking-at f90-end-type-re)
(setq icol (- icol f90-type-indent)))
(setq start-list (cons start-this start-list) ; not add-to-list!
count (1+ count)))
((looking-at (concat "end[ \t]*" f90-blocks-re
- "[ \t]*\\(\\sw+\\)?"))
+ "[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)?"))
(setq end-type (match-string 1)
end-label (match-string 2)
count (1- count))
(skip-chars-forward " \t0-9")
(cond ((or (f90-in-string) (f90-in-comment)))
((looking-at (concat "end[ \t]*" f90-blocks-re
- "[ \t]*\\(\\sw+\\)?"))
+ "[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)?"))
(setq end-list (cons (list (match-string 1) (match-string 2))
end-list)
count (1+ count)))
(car end-struct) (cadr end-struct))))
(setq ind-b
(cond ((looking-at f90-end-if-re) f90-if-indent)
- ((looking-at "end[ \t]*do\\>") f90-do-indent)
+ ((looking-at "end[ \t]*do\\_>") f90-do-indent)
((looking-at f90-end-type-re) f90-type-indent)
((looking-at f90-end-associate-re)
f90-associate-indent)
"Non-nil means consider the underscore character `_' as part of word.
An identifier containing underscores is then treated as a single word in
select and move operations. All parts of an identifier separated by underscore
-are treated as single words otherwise.
-
-NOTE: Activate the new setting in a VHDL buffer by using the menu entry
- \"Activate Options\"."
+are treated as single words otherwise."
:type 'boolean
- :set (lambda (variable value)
- (vhdl-custom-set variable value 'vhdl-mode-syntax-table-init))
:group 'vhdl-misc)
+(make-obsolete-variable 'vhdl-underscore-is-part-of-word
+ 'superword-mode "24.4")
(defgroup vhdl-related nil
(progn (set-buffer (create-file-buffer ,file-name))
(setq file-opened t)
(vhdl-insert-file-contents ,file-name)
+ ;; FIXME: This modifies a global syntax-table!
(modify-syntax-entry ?\- ". 12" (syntax-table))
(modify-syntax-entry ?\n ">" (syntax-table))
(modify-syntax-entry ?\^M ">" (syntax-table))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Syntax table
-(defvar vhdl-mode-syntax-table nil
+(defvar vhdl-mode-syntax-table
+ (let ((st (make-syntax-table)))
+ ;; define punctuation
+ (modify-syntax-entry ?\# "." st)
+ (modify-syntax-entry ?\$ "." st)
+ (modify-syntax-entry ?\% "." st)
+ (modify-syntax-entry ?\& "." st)
+ (modify-syntax-entry ?\' "." st)
+ (modify-syntax-entry ?\* "." st)
+ (modify-syntax-entry ?\+ "." st)
+ (modify-syntax-entry ?\. "." st)
+ (modify-syntax-entry ?\/ "." st)
+ (modify-syntax-entry ?\: "." st)
+ (modify-syntax-entry ?\; "." st)
+ (modify-syntax-entry ?\< "." st)
+ (modify-syntax-entry ?\= "." st)
+ (modify-syntax-entry ?\> "." st)
+ (modify-syntax-entry ?\\ "." st)
+ (modify-syntax-entry ?\| "." st)
+ ;; define string
+ (modify-syntax-entry ?\" "\"" st)
+ ;; define underscore
+ (modify-syntax-entry ?\_ (if vhdl-underscore-is-part-of-word "w" "_") st)
+ ;; a single hyphen is punctuation, but a double hyphen starts a comment
+ (modify-syntax-entry ?\- ". 12" st)
+ ;; and \n and \^M end a comment
+ (modify-syntax-entry ?\n ">" st)
+ (modify-syntax-entry ?\^M ">" st)
+ ;; define parentheses to match
+ (modify-syntax-entry ?\( "()" st)
+ (modify-syntax-entry ?\) ")(" st)
+ (modify-syntax-entry ?\[ "(]" st)
+ (modify-syntax-entry ?\] ")[" st)
+ (modify-syntax-entry ?\{ "(}" st)
+ (modify-syntax-entry ?\} "){" st)
+ st)
"Syntax table used in `vhdl-mode' buffers.")
-(defvar vhdl-mode-ext-syntax-table nil
+(defvar vhdl-mode-ext-syntax-table
+ ;; Extended syntax table including '_' (for simpler search regexps).
+ (let ((st (copy-syntax-table vhdl-mode-syntax-table)))
+ (modify-syntax-entry ?_ "w" st)
+ st)
"Syntax table extended by `_' used in `vhdl-mode' buffers.")
-(defun vhdl-mode-syntax-table-init ()
- "Initialize `vhdl-mode-syntax-table'."
- (setq vhdl-mode-syntax-table (make-syntax-table))
- ;; define punctuation
- (modify-syntax-entry ?\# "." vhdl-mode-syntax-table)
- (modify-syntax-entry ?\$ "." vhdl-mode-syntax-table)
- (modify-syntax-entry ?\% "." vhdl-mode-syntax-table)
- (modify-syntax-entry ?\& "." vhdl-mode-syntax-table)
- (modify-syntax-entry ?\' "." vhdl-mode-syntax-table)
- (modify-syntax-entry ?\* "." vhdl-mode-syntax-table)
- (modify-syntax-entry ?\+ "." vhdl-mode-syntax-table)
- (modify-syntax-entry ?\. "." vhdl-mode-syntax-table)
- (modify-syntax-entry ?\/ "." vhdl-mode-syntax-table)
- (modify-syntax-entry ?\: "." vhdl-mode-syntax-table)
- (modify-syntax-entry ?\; "." vhdl-mode-syntax-table)
- (modify-syntax-entry ?\< "." vhdl-mode-syntax-table)
- (modify-syntax-entry ?\= "." vhdl-mode-syntax-table)
- (modify-syntax-entry ?\> "." vhdl-mode-syntax-table)
- (modify-syntax-entry ?\\ "." vhdl-mode-syntax-table)
- (modify-syntax-entry ?\| "." vhdl-mode-syntax-table)
- ;; define string
- (modify-syntax-entry ?\" "\"" vhdl-mode-syntax-table)
- ;; define underscore
- (when vhdl-underscore-is-part-of-word
- (modify-syntax-entry ?\_ "w" vhdl-mode-syntax-table))
- ;; a single hyphen is punctuation, but a double hyphen starts a comment
- (modify-syntax-entry ?\- ". 12" vhdl-mode-syntax-table)
- ;; and \n and \^M end a comment
- (modify-syntax-entry ?\n ">" vhdl-mode-syntax-table)
- (modify-syntax-entry ?\^M ">" vhdl-mode-syntax-table)
- ;; define parentheses to match
- (modify-syntax-entry ?\( "()" vhdl-mode-syntax-table)
- (modify-syntax-entry ?\) ")(" vhdl-mode-syntax-table)
- (modify-syntax-entry ?\[ "(]" vhdl-mode-syntax-table)
- (modify-syntax-entry ?\] ")[" vhdl-mode-syntax-table)
- (modify-syntax-entry ?\{ "(}" vhdl-mode-syntax-table)
- (modify-syntax-entry ?\} "){" vhdl-mode-syntax-table)
- ;; extended syntax table including '_' (for simpler search regexps)
- (setq vhdl-mode-ext-syntax-table (copy-syntax-table vhdl-mode-syntax-table))
- (modify-syntax-entry ?_ "w" vhdl-mode-ext-syntax-table))
-
-;; initialize syntax table for VHDL Mode
-(vhdl-mode-syntax-table-init)
-
(defvar vhdl-syntactic-context nil
"Buffer local variable containing syntactic analysis list.")
(make-variable-buffer-local 'vhdl-syntactic-context)