• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/emacs-92/emacs/lisp/progmodes/

Lines Matching defs:awk

1 ;;; cc-awk.el --- AWK specific code within cc-mode.
6 ;; Author: Alan Mackenzie <acm@muc.de> (originally based on awk-mode.el)
34 ;; 3. Indentation calculation stuff ("c-awk-NL-prop text-property").
64 (defvar awk-mode-syntax-table
97 (defconst c-awk-esc-pair-re "\\\\\\(.\\|\n\\|\r\\|\\'\\)")
99 (defconst c-awk-non-eol-esc-pair-re "\\\\\\(.\\|\\'\\)")
101 (defconst c-awk-comment-without-nl "#.*")
104 (defconst c-awk-nl-or-eob "\\(\n\\|\r\\|\\'\\)")
109 (defconst c-awk-escaped-nl "\\\\[\n\r]"))
112 (defconst c-awk-escaped-nls* (concat "\\(" c-awk-escaped-nl "\\)*")))
114 ;; awk-font-lock-keywords.
115 ;; (defconst c-awk-escaped-nls*-with-space*
116 ;; (concat "\\(" c-awk-escaped-nls* "\\|" "[ \t]+" "\\)*"))
120 (defconst c-awk-escaped-nls*-with-space*
121 (concat "\\(" c-awk-escaped-nl "\\|" "[ \t]" "\\)*")))
123 ;; interspersed spaces and tabs. Used in awk-font-lock-keywords.
124 (defconst c-awk-blank-or-comment-line-re
130 (defconst c-awk-harmless-char-re "[^_#/\"\\\\\n\r]")
133 (defconst c-awk-harmless-_ "_\\([^\"]\\|\\'\\)")
135 (defconst c-awk-harmless-string*-re
136 (concat "\\(" c-awk-harmless-char-re "\\|" c-awk-esc-pair-re "\\|" c-awk-harmless-_ "\\)*"))
139 (defconst c-awk-harmless-string*-here-re
140 (concat "\\=" c-awk-harmless-string*-re))
143 (defconst c-awk-harmless-line-re
144 (concat c-awk-harmless-string*-re
145 "\\(" c-awk-comment-without-nl "\\)?" c-awk-nl-or-eob))
150 (defconst c-awk-harmless-lines+-here-re
151 (concat "\\=\\(" c-awk-harmless-line-re "\\)+"))
156 (defconst c-awk-string-ch-re "[^\"\\\n\r]")
158 (defconst c-awk-string-innards-re
159 (concat "\\(" c-awk-string-ch-re "\\|" c-awk-esc-pair-re "\\)*"))
161 (defconst c-awk-string-without-end-here-re
162 (concat "\\=_?\"" c-awk-string-innards-re))
165 (defconst c-awk-one-line-possibly-open-string-re
166 (concat "\"\\(" c-awk-string-ch-re "\\|" c-awk-non-eol-esc-pair-re "\\)*"
170 (defconst c-awk-regexp-normal-re "[^[/\\\n\r]")
172 (defconst c-awk-escaped-newlines*-re "\\(\\\\[\n\r]\\)*")
179 (defconst c-awk-regexp-char-class-re
182 (defconst c-awk-regexp-char-list-re
183 (concat "\\[" c-awk-escaped-newlines*-re "^?" c-awk-escaped-newlines*-re "]?"
184 "\\(" c-awk-esc-pair-re "\\|" c-awk-regexp-char-class-re
188 (defconst c-awk-regexp-one-line-possibly-open-char-list-re
189 (concat "\\[\\]?\\(" c-awk-non-eol-esc-pair-re "\\|" "[^]\n\r]" "\\)*"
193 (defconst c-awk-regexp-innards-re
194 (concat "\\(" c-awk-esc-pair-re "\\|" c-awk-regexp-char-list-re
195 "\\|" c-awk-regexp-normal-re "\\)*"))
197 (defconst c-awk-regexp-without-end-re
198 (concat "/" c-awk-regexp-innards-re))
200 (defconst c-awk-one-line-possibly-open-regexp-re
201 (concat "/\\(" c-awk-non-eol-esc-pair-re
202 "\\|" c-awk-regexp-one-line-possibly-open-char-list-re
203 "\\|" c-awk-regexp-normal-re "\\)*"
212 (defconst c-awk-neutral-re
219 (defconst c-awk-neutrals*-re
220 (concat "\\(" c-awk-neutral-re "\\)*"))
222 (defconst c-awk-var-num-ket-re "[]\)0-9a-zA-Z_$.\x80-\xff]+")
226 (defconst c-awk-div-sign-re
227 (concat c-awk-var-num-ket-re c-awk-neutrals*-re "/"))
233 (defconst c-awk-non-arith-op-bra-re
239 (defconst c-awk-regexp-sign-re
240 (concat c-awk-non-arith-op-bra-re c-awk-neutrals*-re "/"))
247 (defconst c-awk-_-harmless-nonws-char-re "[^#/\"\\\\\n\r \t]")
249 (defconst c-awk-one-line-non-syn-ws*-re
251 "\\(" c-awk-_-harmless-nonws-char-re "\\|"
252 c-awk-non-eol-esc-pair-re "\\|"
253 c-awk-one-line-possibly-open-string-re "\\|"
254 c-awk-one-line-possibly-open-regexp-re
270 ;; c-awk-calculate-NL-prop-prev-line, about 130 lines lower down.
273 ;; result in a text-property, c-awk-NL-prop, whose value for a line is set on
276 ;; required but not cached. The c-awk-NL-prop property should be thought of
285 ;; The valid values for c-awk-NL-prop are:
311 (defun c-awk-after-if-for-while-condition-p (&optional do-lim)
334 (defun c-awk-after-function-decl-param-list ()
349 (defun c-awk-after-continue-token ()
360 (defun c-awk-after-rbrace-or-statement-semicolon ()
376 (defun c-awk-back-to-contentful-text-or-NL-prop ()
378 ;; the c-awk-NL-prop text-property set; or (ii) non-ws text; or (iii) BOB.
379 ;; We return either the value of c-awk-NL-prop (in case (i)) or nil.
386 ;; this case, assume that the previous line's c-awk-NL-prop is a $.
398 (not (setq nl-prop (c-get-char-property (1- (point)) 'c-awk-NL-prop)))
403 ;; If we find such, set the c-awk-NL-prop on it, too
408 (c-put-char-property (1- (point)) 'c-awk-NL-prop nl-prop)
426 (defun c-awk-calculate-NL-prop-prev-line (&optional do-lim)
427 ;; Calculate and set the value of the c-awk-NL-prop on the immediately
437 ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM.
444 (nl-prop (c-awk-back-to-contentful-text-or-NL-prop)))
446 ;; line's c-awk-NL-prop) or (2) after contentful text on a line. At
453 ((or (c-awk-after-if-for-while-condition-p do-lim)
454 (c-awk-after-function-decl-param-list)
455 (c-awk-after-continue-token))
459 (not (c-awk-after-rbrace-or-statement-semicolon)))
465 (c-put-char-property (point) 'c-awk-NL-prop nl-prop)
469 ;; Set c-awk-NL-prop on each of these lines's EOL.
478 (c-put-char-property (1- (point)) 'c-awk-NL-prop nl-prop))
481 (defun c-awk-get-NL-prop-prev-line (&optional do-lim)
482 ;; Get the c-awk-NL-prop text-property from the previous line, calculating
484 ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM.
489 (or (c-get-char-property (c-point 'eopl) 'c-awk-NL-prop)
490 (c-awk-calculate-NL-prop-prev-line do-lim))))
492 (defun c-awk-get-NL-prop-cur-line (&optional do-lim)
493 ;; Get the c-awk-NL-prop text-property from the current line, calculating it
498 ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM.
507 (prog1 (c-awk-get-NL-prop-prev-line do-lim)
510 (defsubst c-awk-prev-line-incomplete-p (&optional do-lim)
512 ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM.
515 (memq (c-awk-get-NL-prop-prev-line do-lim) '(?\\ ?\{)))
517 (defsubst c-awk-cur-line-incomplete-p (&optional do-lim)
519 ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM.
522 (memq (c-awk-get-NL-prop-cur-line do-lim) '(?\\ ?\{)))
533 (defun c-awk-at-vsemi-p (&optional pos)
539 (search-forward-regexp c-awk-one-line-non-syn-ws*-re)
542 (while (and (eq (setq nl-prop (c-awk-get-NL-prop-cur-line)) ?\\)
544 (looking-at c-awk-blank-or-comment-line-re)))
547 (defun c-awk-vsemi-status-unknown-p ()
553 (not (c-get-char-property (c-point 'eol) 'c-awk-NL-prop)))
555 (defun c-awk-clear-NL-props (beg end)
557 ;; c-awk-NL-prop text property from beg to the end of the buffer (The END
564 (c-clear-char-properties beg (point-max) 'c-awk-NL-prop)))
566 (defun c-awk-unstick-NL-prop ()
567 ;; Ensure that the text property c-awk-NL-prop is "non-sticky". Without
569 ;; inherit any c-awk-NL-prop from the old newline. This would be a Bad
572 (not (assoc 'c-awk-NL-prop text-property-default-nonsticky)))
574 (cons '(c-awk-NL-prop . t) text-property-default-nonsticky))))
582 ;; (if (setq pl-prop (c-get-char-property (c-point 'eopl) 'c-awk-NL-prop))
585 ;; (if (setq cl-prop (c-get-char-property (c-point 'eol) 'c-awk-NL-prop))
588 ;(define-key awk-mode-map [?\C-c ?\r] 'NL-props) ; commented out, 2002/8/31
590 ;awk-mode-map isn't yet defined. :-(
599 ;; purpose of the function c-awk-set-syntax-table-properties and the myriad
613 (defun c-awk-beginning-of-logical-line (&optional pos)
630 (defun c-awk-end-of-logical-line (&optional pos)
653 (defun c-awk-set-string-regexp-syntax-table-properties (beg end)
661 ;; font from an entry in awk-font-lock-keywords.
686 (defun c-awk-syntax-tablify-string ()
694 (search-forward-regexp c-awk-string-without-end-here-re nil t) ; a (possibly unterminated) string
695 (c-awk-set-string-regexp-syntax-table-properties
705 (defun c-awk-syntax-tablify-/ (anchor anchor-state-/div)
723 (not (search-forward-regexp c-awk-regexp-sign-re (1+ /point) t))
724 (search-forward-regexp c-awk-div-sign-re (1+ /point) t))
730 (search-forward-regexp c-awk-regexp-without-end-re)
731 (c-awk-set-string-regexp-syntax-table-properties
741 (defun c-awk-set-syntax-table-properties (lim)
768 (c-awk-beginning-of-logical-line) ; ACM 2002/7/21. This is probably redundant.
773 (if (search-forward-regexp c-awk-harmless-lines+-here-re nil t)
777 (search-forward-regexp c-awk-harmless-string*-here-re nil t)
782 (c-awk-syntax-tablify-string)
783 (c-awk-syntax-tablify-/ anchor anchor-state-/div))))
791 (defvar c-awk-old-EOLL 0)
792 (make-variable-buffer-local 'c-awk-old-EOLL)
794 ;; in c-awk-before-change and used in c-awk-after-change.
796 (defun c-awk-before-change (beg end)
799 ;; and clears c-awk-NL-prop text properties from this point onwards.
804 (setq c-awk-old-EOLL (c-awk-end-of-logical-line end))
806 (c-awk-clear-NL-props end (point-max))))))
808 (defun c-awk-end-of-change-region (beg end old-len)
815 (max (+ (- c-awk-old-EOLL old-len) (- end beg))
816 (c-awk-end-of-logical-line end)))
818 (defun c-awk-after-change (beg end old-len)
830 (setq end (c-awk-end-of-change-region beg end old-len))
831 (c-awk-beginning-of-logical-line beg)
834 (c-awk-set-syntax-table-properties end)))))))
842 (defmacro c-awk-advise-fl-for-awk-region (function)
843 `(defadvice ,function (before get-awk-region activate)
846 (when (eq major-mode 'awk-mode)
848 (ad-set-arg 1 (c-awk-end-of-change-region
852 (ad-set-arg 0 (c-awk-beginning-of-logical-line (ad-get-arg 0)))))))
854 (c-awk-advise-fl-for-awk-region font-lock-after-change-function)
855 (c-awk-advise-fl-for-awk-region jit-lock-after-change)
856 (c-awk-advise-fl-for-awk-region lazy-lock-defer-rest-after-change)
857 (c-awk-advise-fl-for-awk-region lazy-lock-defer-line-after-change)
863 (defconst awk-font-lock-keywords
935 `(,(concat "\\(\\w\\|_\\)" c-awk-escaped-nls* "\\s "
936 c-awk-escaped-nls*-with-space* "(")
953 ;; The following three regexps differ from those earlier on in cc-awk.el in
956 (defconst c-awk-terminated-regexp-or-string-here-re "\\=\\s\"\\S\"*\\s\"")
959 (defconst c-awk-unterminated-regexp-or-string-here-re "\\=\\s|\\S|*$")
962 (defconst c-awk-harmless-pattern-characters*
963 (concat "\\([^{;#/\"\\\\\n\r]\\|" c-awk-esc-pair-re "\\)*"))
966 (defun c-awk-at-statement-end-p ()
975 (and (memq (c-awk-get-NL-prop-cur-line) '(?\$ ?\\))
978 (concat "[^ \t\n\r\\]" c-awk-escaped-nls*-with-space*
981 (defun c-awk-beginning-of-defun (&optional arg)
1007 (not (memq (c-awk-get-NL-prop-prev-line) '(?\$ ?\} ?\#)))))
1014 (not (memq (c-awk-get-NL-prop-prev-line) '(?\$ ?\} ?\#)))))
1019 (defun c-awk-forward-awk-pattern ()
1029 (search-forward-regexp c-awk-harmless-pattern-characters*)
1035 (if (c-awk-cur-line-incomplete-p)
1038 ((search-forward-regexp c-awk-terminated-regexp-or-string-here-re nil t))
1039 ((search-forward-regexp c-awk-unterminated-regexp-or-string-here-re nil t))
1042 (defun c-awk-end-of-defun1 ()
1046 (c-awk-forward-awk-pattern)
1051 (t (error "c-awk-end-of-defun1: Failure of c-awk-forward-awk-pattern")))
1054 (defun c-awk-beginning-of-defun-p ()
1060 (not (c-awk-prev-line-incomplete-p))))
1062 (defun c-awk-end-of-defun (&optional arg)
1068 no explicit action; see function `c-awk-beginning-of-defun'.
1085 (if (not (c-awk-beginning-of-defun-p))
1086 (when (not (c-awk-beginning-of-defun 1)) ; No bo-defun before point.
1088 (c-awk-beginning-of-defun -1))) ; if this fails, we're at EOB, tough!
1091 (c-awk-end-of-defun1)
1094 (c-awk-beginning-of-defun -1))))
1099 (c-awk-beginning-of-defun 1)
1101 (save-excursion (c-awk-end-of-defun1))))
1109 (cc-provide 'cc-awk) ; Changed from 'awk-mode, ACM 2002/5/21
1112 ;;; awk-mode.el ends here