3 (or (boundp 'font-lock-variable-name-face
)
4 (setq font-lock-variable-name-face font-lock-type-face
))
6 (setq 4gl-font-lock-syntactic-keywords
8 ;; #{ }, #$hoge, #@foo are not comments
9 ("\\(#\\)[{$@]" 1 (1 . nil
))
10 ;; the last $', $", $` in the respective string is not variable
11 ;; the last ?', ?", ?` in the respective string is not ascii code
12 ("\\(^\\|[\[ \t\n<+\(,=]\\)\\(['\"`]\\)\\(\\\\.\\|\\2\\|[^'\"`\n\\\\]\\)*?\\\\?[?$]\\(\\2\\)"
15 ;; $' $" $` .... are variables
16 ;; ?' ?" ?` are ascii codes
17 ("\\(^\\|[^\\\\]\\)\\(\\\\\\\\\\)*[?$]\\([#\"'`]\\)" 3 (1 . nil
))
19 ("\\(^\\|[=(,~?:;<>]\\|\\(^\\|\\s \\)\\(if\\|elsif\\|unless\\|while\\|until\\|when\\|and\\|or\\|&&\\|||\\)\\|g?sub!?\\|scan\\|split!?\\)\\s *\\(/\\)[^/\n\\\\]*\\(\\\\.[^/\n\\\\]*\\)*\\(/\\)"
22 ("^\\(=\\)begin\\(\\s \\|$\\)" 1 (7 . nil
))
23 ("^\\(=\\)end\\(\\s \\|$\\)" 1 (7 . nil
))))
25 (cond ((featurep 'xemacs
)
26 (put '4gl-mode
'font-lock-defaults
27 '((4gl-font-lock-keywords)
30 (font-lock-syntactic-keywords
31 .
4gl-font-lock-syntactic-keywords
))))
33 (add-hook '4gl-mode-hook
35 (make-local-variable 'font-lock-defaults
)
36 (make-local-variable 'font-lock-keywords
)
37 (make-local-variable 'font-lock-syntax-table
)
38 (make-local-variable 'font-lock-syntactic-keywords
)
39 (setq font-lock-defaults
'((4gl-font-lock-keywords) nil nil
))
40 (setq font-lock-keywords
4gl-font-lock-keywords
)
41 (setq font-lock-syntax-table
4gl-font-lock-syntax-table
)
42 (setq font-lock-syntactic-keywords
4gl-font-lock-syntactic-keywords
)))))
44 (defun 4gl-font-lock-docs (limit)
45 (if (re-search-forward "^=begin\\(\\s \\|$\\)" limit t
)
50 (if (re-search-forward "^=end\\(\\s \\|$\\)" limit t
)
52 (set-match-data (list beg
(point)))
55 (defun 4gl-font-lock-maybe-docs (limit)
58 (if (and (re-search-backward "^=\\(begin\\|end\\)\\(\\s \\|$\\)" nil t
)
59 (string= (match-string 1) "begin"))
63 (if (and beg
(and (re-search-forward "^=\\(begin\\|end\\)\\(\\s \\|$\\)" nil t
)
64 (string= (match-string 1) "end")))
66 (set-match-data (list beg
(point)))
70 (defvar 4gl-font-lock-syntax-table
71 (let* ((tbl (copy-syntax-table 4gl-mode-syntax-table
)))
72 (modify-syntax-entry ?_
"w" tbl
)
75 (defun 4gl-font-lock-here-docs (limit)
76 (if (re-search-forward 4gl-here-doc-beg-re limit t
)
81 (if (re-search-forward (4gl-here-doc-end-match) nil t
)
83 (set-match-data (list beg
(point)))
86 (defun 4gl-font-lock-maybe-here-docs (limit)
89 (if (re-search-backward 4gl-here-doc-beg-re nil t
)
95 (let ((end-match (4gl-here-doc-end-match)))
96 (and (not (re-search-backward end-match beg t
))
97 (re-search-forward end-match nil t
))))
99 (set-match-data (list beg
(point)))
103 (defvar 4gl-font-lock-keywords
106 '("^\\s *def\\s +\\([^( \t\n]+\\)"
107 1 font-lock-function-name-face
)
110 "\\(^\\|[^_:.@$]\\|\\.\\.\\)\\b\\(defined\\?\\|\\("
153 '("\\(^\\|[^_:.@$]\\|\\.\\.\\)\\b\\(nil\\|self\\|true\\|false\\)\\>"
154 2 font-lock-variable-name-face
)
156 '("\\(\\$\\([^a-zA-Z0-9 \n]\\|[0-9]\\)\\)\\W"
157 1 font-lock-variable-name-face
)
158 '("\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+"
159 0 font-lock-variable-name-face
)
162 0 font-lock-comment-face t
)
163 '(4gl-font-lock-maybe-docs
164 0 font-lock-comment-face t
)
166 '(4gl-font-lock-here-docs
167 0 font-lock-string-face t
)
168 '(4gl-font-lock-maybe-here-docs
169 0 font-lock-string-face t
)
170 `(,4gl-here-doc-beg-re
171 0 font-lock-string-face t
)
172 ;; general delimited string
173 '("\\(^\\|[[ \t\n<+(,=]\\)\\(%[xrqQwW]?\\([^<[{(a-zA-Z0-9 \n]\\)[^\n\\\\]*\\(\\\\.[^\n\\\\]*\\)*\\(\\3\\)\\)"
174 (2 font-lock-string-face
))
176 '("\\(^\\|[^_]\\)\\b\\([A-Z]+\\(\\w\\|_\\)*\\)"
177 2 font-lock-type-face
)
179 '("\\(^\\|[^:]\\)\\(:\\([-+~]@?\\|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|\\[\\]=?\\|\\(\\w\\|_\\)+\\([!?=]\\|\\b_*\\)\\|#{[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\)\\)"
180 2 font-lock-reference-face
)
181 ;; expression expansion
182 '("#\\({[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\|\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+\\)"
183 0 font-lock-variable-name-face t
)
184 ;; warn lower camel case
185 ;'("\\<[a-z]+[a-z0-9]*[A-Z][A-Za-z0-9]*\\([!?]?\\|\\>\\)"
186 ; 0 font-lock-warning-face)
188 "*Additional expressions to highlight in 4gl mode."))