annotate lisp/progmodes/cc-awk.el @ 93745:e8f312e6ec32

(Fassoc_string): Tweak docstring.
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 05 Apr 2008 21:03:47 +0000
parents 78cb7fb87a03
children 7aad137aaf4e 1e3a407766b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1 ;;; cc-awk.el --- AWK specific code within cc-mode.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
2
74372
cf3e4c6cd4c3 Fix Copyright format.
Glenn Morris <rgm@gnu.org>
parents: 71764
diff changeset
3 ;; Copyright (C) 1988, 1994, 1996, 2000, 2001, 2002, 2003, 2004, 2005,
79717
a1342e6e097a Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 78487
diff changeset
4 ;; 2006, 2007, 2008 Free Software Foundation, Inc.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
5
62641
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 52401
diff changeset
6 ;; Author: Alan Mackenzie <acm@muc.de> (originally based on awk-mode.el)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
7 ;; Maintainer: FSF
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
8 ;; Keywords: AWK, cc-mode, unix, languages
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
9
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
11
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
78234
c1ec1c8a8d2e Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 77081
diff changeset
14 ;; the Free Software Foundation; either version 3, or (at your option)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
15 ;; any later version.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
16
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
20 ;; GNU General Public License for more details.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
21
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
23 ;; along with this program; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63517
diff changeset
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63517
diff changeset
25 ;; Boston, MA 02110-1301, USA.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
26
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
27 ;;; Commentary:
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
28
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
29 ;; This file contains (most of) the adaptations to cc-mode required for the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
30 ;; integration of AWK Mode.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
31 ;; It is organised thusly, the sections being separated by page breaks:
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
32 ;; 1. The AWK Mode syntax table.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
33 ;; 2. Regular expressions for analysing AWK code.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
34 ;; 3. Indentation calculation stuff ("c-awk-NL-prop text-property").
71754
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
35 ;; 4. Syntax-table property/font-locking stuff, including the
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
36 ;; font-lock-keywords setting.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
37 ;; 5. The AWK Mode before/after-change-functions.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
38 ;; 6. AWK Mode specific versions of commands like beginning-of-defun.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
39 ;; The AWK Mode keymap, abbreviation table, and the mode function itself are
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
40 ;; in cc-mode.el.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
41
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
42 ;;; Code:
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
43
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
44 (eval-when-compile
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
45 (let ((load-path
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
46 (if (and (boundp 'byte-compile-dest-file)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
47 (stringp byte-compile-dest-file))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
48 (cons (file-name-directory byte-compile-dest-file) load-path)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
49 load-path)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
50 (load "cc-bytecomp" nil t)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
51
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
52 (cc-require 'cc-defs)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
53
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
54 ;; Silence the byte compiler.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
55 (cc-bytecomp-defvar font-lock-mode) ; Checked with boundp before use.
80155
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
56 (cc-bytecomp-defvar c-new-BEG)
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
57 (cc-bytecomp-defvar c-new-END)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
58
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
59 ;; Some functions in cc-engine that are used below. There's a cyclic
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
60 ;; dependency so it can't be required here. (Perhaps some functions
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
61 ;; could be moved to cc-engine to avoid it.)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
62 (cc-bytecomp-defun c-backward-token-1)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
63 (cc-bytecomp-defun c-beginning-of-statement-1)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
64 (cc-bytecomp-defun c-backward-sws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
65
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
66 (defvar awk-mode-syntax-table
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
67 (let ((st (make-syntax-table)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
68 (modify-syntax-entry ?\\ "\\" st)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
69 (modify-syntax-entry ?\n "> " st)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
70 (modify-syntax-entry ?\r "> " st)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
71 (modify-syntax-entry ?\f "> " st)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
72 (modify-syntax-entry ?\# "< " st)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
73 ;; / can delimit regexes or be a division operator. By default we assume
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
74 ;; that it is a division sign, and fix the regexp operator cases with
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
75 ;; `font-lock-syntactic-keywords'.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
76 (modify-syntax-entry ?/ "." st) ; ACM 2002/4/27.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
77 (modify-syntax-entry ?* "." st)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
78 (modify-syntax-entry ?+ "." st)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
79 (modify-syntax-entry ?- "." st)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
80 (modify-syntax-entry ?= "." st)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
81 (modify-syntax-entry ?% "." st)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
82 (modify-syntax-entry ?< "." st)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
83 (modify-syntax-entry ?> "." st)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
84 (modify-syntax-entry ?& "." st)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
85 (modify-syntax-entry ?| "." st)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
86 (modify-syntax-entry ?_ "_" st)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
87 (modify-syntax-entry ?\' "." st)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
88 st)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
89 "Syntax table in use in AWK Mode buffers.")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
90
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
91
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
92 ;; This section defines regular expressions used in the analysis of AWK code.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
93
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
94 ;; N.B. In the following regexps, an EOL is either \n OR \r. This is because
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
95 ;; Emacs has in the past used \r to mark hidden lines in some fashion (and
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
96 ;; maybe still does).
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
97
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
98 (defconst c-awk-esc-pair-re "\\\\\\(.\\|\n\\|\r\\|\\'\\)")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
99 ;; Matches any escaped (with \) character-pair, including an escaped newline.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
100 (defconst c-awk-non-eol-esc-pair-re "\\\\\\(.\\|\\'\\)")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
101 ;; Matches any escaped (with \) character-pair, apart from an escaped newline.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
102 (defconst c-awk-comment-without-nl "#.*")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
103 ;; Matches an AWK comment, not including the terminating NL (if any). Note
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
104 ;; that the "enclosing" (elisp) regexp must ensure the # is real.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
105 (defconst c-awk-nl-or-eob "\\(\n\\|\r\\|\\'\\)")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
106 ;; Matches a newline, or the end of buffer.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
107
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
108 ;; "Space" regular expressions.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
109 (eval-and-compile
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
110 (defconst c-awk-escaped-nl "\\\\[\n\r]"))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
111 ;; Matches an escaped newline.
71764
77752270b25a (c-awk-escaped-nls*): Use eval-and-compile to avoid compilation error.
Chong Yidong <cyd@stupidchicken.com>
parents: 71754
diff changeset
112 (eval-and-compile
77752270b25a (c-awk-escaped-nls*): Use eval-and-compile to avoid compilation error.
Chong Yidong <cyd@stupidchicken.com>
parents: 71754
diff changeset
113 (defconst c-awk-escaped-nls* (concat "\\(" c-awk-escaped-nl "\\)*")))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
114 ;; Matches a possibly empty sequence of escaped newlines. Used in
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
115 ;; awk-font-lock-keywords.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
116 ;; (defconst c-awk-escaped-nls*-with-space*
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
117 ;; (concat "\\(" c-awk-escaped-nls* "\\|" "[ \t]+" "\\)*"))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
118 ;; The above RE was very slow. It's runtime was doubling with each additional
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
119 ;; space :-( Reformulate it as below:
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
120 (eval-and-compile
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
121 (defconst c-awk-escaped-nls*-with-space*
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
122 (concat "\\(" c-awk-escaped-nl "\\|" "[ \t]" "\\)*")))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
123 ;; Matches a possibly empty sequence of escaped newlines with optional
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
124 ;; interspersed spaces and tabs. Used in awk-font-lock-keywords.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
125 (defconst c-awk-blank-or-comment-line-re
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
126 (concat "[ \t]*\\(#\\|\\\\?$\\)"))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
127 ;; Matche (the tail of) a line containing at most either a comment or an
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
128 ;; escaped EOL.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
129
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
130 ;; REGEXPS FOR "HARMLESS" STRINGS/LINES.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
131 (defconst c-awk-harmless-char-re "[^_#/\"\\\\\n\r]")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
132 ;; Matches any character but a _, #, /, ", \, or newline. N.B. _" starts a
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
133 ;; localisation string in gawk 3.1
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
134 (defconst c-awk-harmless-_ "_\\([^\"]\\|\\'\\)")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
135 ;; Matches an underline NOT followed by ".
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
136 (defconst c-awk-harmless-string*-re
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
137 (concat "\\(" c-awk-harmless-char-re "\\|" c-awk-esc-pair-re "\\|" c-awk-harmless-_ "\\)*"))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
138 ;; Matches a (possibly empty) sequence of chars without unescaped /, ", \,
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
139 ;; #, or newlines.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
140 (defconst c-awk-harmless-string*-here-re
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
141 (concat "\\=" c-awk-harmless-string*-re))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
142 ;; Matches the (possibly empty) sequence of chars without unescaped /, ", \,
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
143 ;; at point.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
144 (defconst c-awk-harmless-line-re
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
145 (concat c-awk-harmless-string*-re
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
146 "\\(" c-awk-comment-without-nl "\\)?" c-awk-nl-or-eob))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
147 ;; Matches (the tail of) an AWK \"logical\" line not containing an unescaped
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
148 ;; " or /. "logical" means "possibly containing escaped newlines". A comment
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
149 ;; is matched as part of the line even if it contains a " or a /. The End of
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
150 ;; buffer is also an end of line.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
151 (defconst c-awk-harmless-lines+-here-re
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
152 (concat "\\=\\(" c-awk-harmless-line-re "\\)+"))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
153 ;; Matches a sequence of (at least one) \"harmless-line\" at point.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
154
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
155
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
156 ;; REGEXPS FOR AWK STRINGS.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
157 (defconst c-awk-string-ch-re "[^\"\\\n\r]")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
158 ;; Matches any character which can appear unescaped in a string.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
159 (defconst c-awk-string-innards-re
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
160 (concat "\\(" c-awk-string-ch-re "\\|" c-awk-esc-pair-re "\\)*"))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
161 ;; Matches the inside of an AWK string (i.e. without the enclosing quotes).
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
162 (defconst c-awk-string-without-end-here-re
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
163 (concat "\\=_?\"" c-awk-string-innards-re))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
164 ;; Matches an AWK string at point up to, but not including, any terminator.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
165 ;; A gawk 3.1+ string may look like _"localisable string".
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
166 (defconst c-awk-one-line-possibly-open-string-re
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
167 (concat "\"\\(" c-awk-string-ch-re "\\|" c-awk-non-eol-esc-pair-re "\\)*"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
168 "\\(\"\\|\\\\?$\\|\\'\\)"))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
169
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
170 ;; REGEXPS FOR AWK REGEXPS.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
171 (defconst c-awk-regexp-normal-re "[^[/\\\n\r]")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
172 ;; Matches any AWK regexp character which doesn't require special analysis.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
173 (defconst c-awk-escaped-newlines*-re "\\(\\\\[\n\r]\\)*")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
174 ;; Matches a (possibly empty) sequence of escaped newlines.
62641
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 52401
diff changeset
175
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 52401
diff changeset
176 ;; NOTE: In what follows, "[asdf]" in a regexp will be called a "character
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 52401
diff changeset
177 ;; list", and "[:alpha:]" inside a character list will be known as a
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 52401
diff changeset
178 ;; "character class". These terms for these things vary between regexp
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 52401
diff changeset
179 ;; descriptions .
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
180 (defconst c-awk-regexp-char-class-re
62641
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 52401
diff changeset
181 "\\[:[a-z]+:\\]")
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 52401
diff changeset
182 ;; Matches a character class spec (e.g. [:alpha:]).
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 52401
diff changeset
183 (defconst c-awk-regexp-char-list-re
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
184 (concat "\\[" c-awk-escaped-newlines*-re "^?" c-awk-escaped-newlines*-re "]?"
62641
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 52401
diff changeset
185 "\\(" c-awk-esc-pair-re "\\|" c-awk-regexp-char-class-re
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 52401
diff changeset
186 "\\|" "[^]\n\r]" "\\)*" "\\(]\\|$\\)"))
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 52401
diff changeset
187 ;; Matches a regexp char list, up to (but not including) EOL if the ] is
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
188 ;; missing.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
189 (defconst c-awk-regexp-one-line-possibly-open-char-list-re
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
190 (concat "\\[\\]?\\(" c-awk-non-eol-esc-pair-re "\\|" "[^]\n\r]" "\\)*"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
191 "\\(]\\|\\\\?$\\|\\'\\)"))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
192 ;; Matches the head (or all) of a regexp char class, up to (but not
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
193 ;; including) the first EOL.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
194 (defconst c-awk-regexp-innards-re
62641
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 52401
diff changeset
195 (concat "\\(" c-awk-esc-pair-re "\\|" c-awk-regexp-char-list-re
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
196 "\\|" c-awk-regexp-normal-re "\\)*"))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
197 ;; Matches the inside of an AWK regexp (i.e. without the enclosing /s)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
198 (defconst c-awk-regexp-without-end-re
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
199 (concat "/" c-awk-regexp-innards-re))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
200 ;; Matches an AWK regexp up to, but not including, any terminating /.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
201 (defconst c-awk-one-line-possibly-open-regexp-re
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
202 (concat "/\\(" c-awk-non-eol-esc-pair-re
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
203 "\\|" c-awk-regexp-one-line-possibly-open-char-list-re
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
204 "\\|" c-awk-regexp-normal-re "\\)*"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
205 "\\(/\\|\\\\?$\\|\\'\\)"))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
206 ;; Matches as much of the head of an AWK regexp which fits on one line,
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
207 ;; possibly all of it.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
208
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
209 ;; REGEXPS used for scanning an AWK buffer in order to decide IF A '/' IS A
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
210 ;; REGEXP OPENER OR A DIVISION SIGN. By "state" in the following is meant
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
211 ;; whether a '/' at the current position would by a regexp opener or a
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
212 ;; division sign.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
213 (defconst c-awk-neutral-re
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
214 ; "\\([{}@` \t]\\|\\+\\+\\|--\\|\\\\.\\)+") ; changed, 2003/6/7
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
215 "\\([{}@` \t]\\|\\+\\+\\|--\\|\\\\.\\)")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
216 ;; A "neutral" char(pair). Doesn't change the "state" of a subsequent /.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
217 ;; This is space/tab, braces, an auto-increment/decrement operator or an
80054
6c2c7b785da9 *** empty log message ***
Juanma Barranquero <lekktu@gmail.com>
parents: 79942
diff changeset
218 ;; escaped character. Or one of the (invalid) characters @ or `. But NOT an
62641
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 52401
diff changeset
219 ;; end of line (even if escaped).
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
220 (defconst c-awk-neutrals*-re
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
221 (concat "\\(" c-awk-neutral-re "\\)*"))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
222 ;; A (possibly empty) string of neutral characters (or character pairs).
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
223 (defconst c-awk-var-num-ket-re "[]\)0-9a-zA-Z_$.\x80-\xff]+")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
224 ;; Matches a char which is a constituent of a variable or number, or a ket
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
225 ;; (i.e. closing bracKET), round or square. Assume that all characters \x80 to
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
226 ;; \xff are "letters".
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
227 (defconst c-awk-div-sign-re
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
228 (concat c-awk-var-num-ket-re c-awk-neutrals*-re "/"))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
229 ;; Will match a piece of AWK buffer ending in / which is a division sign, in
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
230 ;; a context where an immediate / would be a regexp bracket. It follows a
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
231 ;; variable or number (with optional intervening "neutral" characters). This
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
232 ;; will only work when there won't be a preceding " or / before the sought /
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
233 ;; to foul things up.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
234 (defconst c-awk-non-arith-op-bra-re
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
235 "[[\(&=:!><,?;'~|]")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
236 ;; Matches an openeing BRAcket ,round or square, or any operator character
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
237 ;; apart from +,-,/,*,%. For the purpose at hand (detecting a / which is a
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
238 ;; regexp bracket) these arith ops are unnecessary and a pain, because of "++"
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
239 ;; and "--".
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
240 (defconst c-awk-regexp-sign-re
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
241 (concat c-awk-non-arith-op-bra-re c-awk-neutrals*-re "/"))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
242 ;; Will match a piece of AWK buffer ending in / which is an opening regexp
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
243 ;; bracket, in a context where an immediate / would be a division sign. This
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
244 ;; will only work when there won't be a preceding " or / before the sought /
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
245 ;; to foul things up.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
246
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
247 ;; REGEXPS USED FOR FINDING THE POSITION OF A "virtual semicolon"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
248 (defconst c-awk-_-harmless-nonws-char-re "[^#/\"\\\\\n\r \t]")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
249 ;;;; NEW VERSION! (which will be restricted to the current line)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
250 (defconst c-awk-one-line-non-syn-ws*-re
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
251 (concat "\\([ \t]*"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
252 "\\(" c-awk-_-harmless-nonws-char-re "\\|"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
253 c-awk-non-eol-esc-pair-re "\\|"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
254 c-awk-one-line-possibly-open-string-re "\\|"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
255 c-awk-one-line-possibly-open-regexp-re
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
256 "\\)"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
257 "\\)*"))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
258
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
259
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
260 ;; ACM, 2002/5/29:
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
261 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
262 ;; The next section of code is about determining whether or not an AWK
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
263 ;; statement is complete or not. We use this to indent the following line.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
264 ;; The determination is pretty straightforward in C, where a statement ends
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
265 ;; with either a ; or a }. Only "while" really gives any trouble there, since
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
266 ;; it might be the end of a do-while. In AWK, on the other hand, semicolons
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
267 ;; are rarely used, and EOLs _usually_ act as "virtual semicolons". In
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
268 ;; addition, we have the complexity of escaped EOLs. The core of this
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
269 ;; analysis is in the middle of the function
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
270 ;; c-awk-calculate-NL-prop-prev-line, about 130 lines lower down.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
271 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
272 ;; To avoid continually repeating this expensive analysis, we "cache" its
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
273 ;; result in a text-property, c-awk-NL-prop, whose value for a line is set on
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
274 ;; the EOL (if any) which terminates that line. Should the property be
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
275 ;; required for the very last line (which has no EOL), it is calculated as
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
276 ;; required but not cached. The c-awk-NL-prop property should be thought of
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
277 ;; as only really valid immediately after a buffer change, not a permanently
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
278 ;; set property. (By contrast, the syntax-table text properties (set by an
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
279 ;; after-change function) must be constantly updated for the mode to work
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
280 ;; properly).
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
281 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
282 ;; This text property is also used for "syntactic whitespace" movement, this
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
283 ;; being where the distinction between the values '$' and '}' is significant.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
284 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
285 ;; The valid values for c-awk-NL-prop are:
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
286 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
287 ;; nil The property is not currently set for this line.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
288 ;; '#' There is NO statement on this line (at most a comment), and no open
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
289 ;; statement from a previous line which could have been completed on this
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
290 ;; line.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
291 ;; '{' There is an unfinished statement on this (or a previous) line which
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
292 ;; doesn't require \s to continue onto another line, e.g. the line ends
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
293 ;; with {, or the && operator, or "if (condition)". Note that even if the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
294 ;; newline is redundantly escaped, it remains a '{' line.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
295 ;; '\' There is an escaped newline at the end of this line and this '\' is
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
296 ;; essential to the syntax of the program. (i.e. if it had been a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
297 ;; frivolous \, it would have been ignored and the line been given one of
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
298 ;; the other property values.)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
299 ;; '$' A non-empty statement is terminated on the line by an EOL (a "virtual
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
300 ;; semicolon"). This might be a content-free line terminating a statement
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
301 ;; from the preceding (continued) line (which has property \).
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
302 ;; '}' A statement, being the last thing (aside from ws/comments) is
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
303 ;; explicitly terminated on this line by a closing brace (or sometimes a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
304 ;; semicolon).
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
305 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
306 ;; This set of values has been chosen so that the property's value on a line
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
307 ;; is completely determined by the contents of the line and the property on
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
308 ;; the previous line, EXCEPT for where a "while" might be the closing
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
309 ;; statement of a do-while.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
310
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
311 (defun c-awk-after-if-for-while-condition-p (&optional do-lim)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
312 ;; Are we just after the ) in "if/for/while (<condition>)"?
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
313 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
314 ;; Note that the end of the ) in a do .... while (<condition>) doesn't
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
315 ;; count, since the purpose of this routine is essentially to decide
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
316 ;; whether to indent the next line.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
317 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
318 ;; DO-LIM sets a limit on how far back we search for the "do" of a possible
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
319 ;; do-while.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
320 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
321 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
322 (and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
323 (eq (char-before) ?\))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
324 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
325 (let ((par-pos (c-safe (scan-lists (point) -1 0))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
326 (when par-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
327 (goto-char par-pos) ; back over "(...)"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
328 (c-backward-token-1) ; BOB isn't a problem.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
329 (or (looking-at "\\(if\\|for\\)\\>\\([^_]\\|$\\)")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
330 (and (looking-at "while\\>\\([^_]\\|$\\)") ; Ensure this isn't a do-while.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
331 (not (eq (c-beginning-of-statement-1 do-lim)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
332 'beginning)))))))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
333
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
334 (defun c-awk-after-function-decl-param-list ()
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
335 ;; Are we just after the ) in "function foo (bar)" ?
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
336 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
337 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
338 (and (eq (char-before) ?\))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
339 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
340 (let ((par-pos (c-safe (scan-lists (point) -1 0))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
341 (when par-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
342 (goto-char par-pos) ; back over "(...)"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
343 (c-backward-token-1) ; BOB isn't a problem
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
344 (and (looking-at "[_a-zA-Z][_a-zA-Z0-9]*\\>")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
345 (progn (c-backward-token-1)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
346 (looking-at "func\\(tion\\)?\\>"))))))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
347
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
348 ;; 2002/11/8: FIXME! Check c-backward-token-1/2 for success (0 return code).
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
349 (defun c-awk-after-continue-token ()
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
350 ;; Are we just after a token which can be continued onto the next line without
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
351 ;; a backslash?
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
352 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
353 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
354 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
355 (c-backward-token-1) ; FIXME 2002/10/27. What if this fails?
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
356 (if (and (looking-at "[&|]") (not (bobp)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
357 (backward-char)) ; c-backward-token-1 doesn't do this :-(
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
358 (looking-at "[,{?:]\\|&&\\|||\\|do\\>\\|else\\>")))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
359
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
360 (defun c-awk-after-rbrace-or-statement-semicolon ()
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
361 ;; Are we just after a } or a ; which closes a statement?
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
362 ;; Be careful about ;s in for loop control bits. They don't count!
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
363 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
364 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
365 (or (eq (char-before) ?\})
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
366 (and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
367 (eq (char-before) ?\;)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
368 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
369 (let ((par-pos (c-safe (scan-lists (point) -1 1))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
370 (when par-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
371 (goto-char par-pos) ; go back to containing (
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
372 (not (and (looking-at "(")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
373 (c-backward-token-1) ; BOB isn't a problem
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
374 (looking-at "for\\>")))))))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
375
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
376 (defun c-awk-back-to-contentful-text-or-NL-prop ()
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
377 ;; Move back to just after the first found of either (i) an EOL which has
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
378 ;; the c-awk-NL-prop text-property set; or (ii) non-ws text; or (iii) BOB.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
379 ;; We return either the value of c-awk-NL-prop (in case (i)) or nil.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
380 ;; Calling functions can best distinguish cases (ii) and (iii) with (bolp).
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
381 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
382 ;; Note that an escaped eol counts as whitespace here.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
383 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
384 ;; Kludge: If c-backward-syntactic-ws gets stuck at a BOL, it is likely
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
385 ;; that the previous line contains an unterminated string (without \). In
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
386 ;; this case, assume that the previous line's c-awk-NL-prop is a $.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
387 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
388 ;; POINT MUST BE AT THE START OF A LINE when calling this function. This
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
389 ;; is to ensure that the various backward-comment functions will work
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
390 ;; properly.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
391 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
392 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
393 (let ((nl-prop nil)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
394 bol-pos bsws-pos) ; starting pos for a backward-syntactic-ws call.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
395 (while ;; We are at a BOL here. Go back one line each iteration.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
396 (and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
397 (not (bobp))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
398 (not (setq nl-prop (c-get-char-property (1- (point)) 'c-awk-NL-prop)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
399 (progn (setq bol-pos (c-point 'bopl))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
400 (setq bsws-pos (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
401 ;; N.B. the following function will not go back past an EOL if
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
402 ;; there is an open string (without \) on the previous line.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
403 ;; If we find such, set the c-awk-NL-prop on it, too
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
404 ;; (2004/3/29).
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
405 (c-backward-syntactic-ws bol-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
406 (or (/= (point) bsws-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
407 (progn (setq nl-prop ?\$)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
408 (c-put-char-property (1- (point)) 'c-awk-NL-prop nl-prop)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
409 nil)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
410 ;; If we had a backslash at EOL, c-backward-syntactic-ws will
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
411 ;; have gone backwards over it. Check the backslash was "real".
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
412 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
413 (if (looking-at "[ \t]*\\\\+$")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
414 (if (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
415 (end-of-line)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
416 (search-backward-regexp
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
417 "\\(^\\|[^\\]\\)\\(\\\\\\\\\\)*\\\\$" ; ODD number of \s at EOL :-)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
418 bol-pos t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
419 (progn (end-of-line) ; escaped EOL.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
420 (backward-char)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
421 (c-backward-syntactic-ws bol-pos))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
422 (end-of-line))) ; The \ at eol is a fake.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
423 (bolp))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
424 nl-prop))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
425
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
426 (defun c-awk-calculate-NL-prop-prev-line (&optional do-lim)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
427 ;; Calculate and set the value of the c-awk-NL-prop on the immediately
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
428 ;; preceding EOL. This may also involve doing the same for several
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
429 ;; preceding EOLs.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
430 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
431 ;; NOTE that if the property was already set, we return it without
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
432 ;; recalculation. (This is by accident rather than design.)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
433 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
434 ;; Return the property which got set (or was already set) on the previous
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
435 ;; line. Return nil if we hit BOB.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
436 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
437 ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
438 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
439 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
440 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
441 (save-match-data
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
442 (beginning-of-line)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
443 (let* ((pos (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
444 (nl-prop (c-awk-back-to-contentful-text-or-NL-prop)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
445 ;; We are either (1) at a BOL (with nl-prop containing the previous
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
446 ;; line's c-awk-NL-prop) or (2) after contentful text on a line. At
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
447 ;; the BOB counts as case (1), so we test next for bolp rather than
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
448 ;; non-nil nl-prop.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
449 (when (not (bolp))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
450 (setq nl-prop
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
451 (cond
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
452 ;; Incomplete statement which doesn't require escaped EOL?
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
453 ((or (c-awk-after-if-for-while-condition-p do-lim)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
454 (c-awk-after-function-decl-param-list)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
455 (c-awk-after-continue-token))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
456 ?\{)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
457 ;; Escaped EOL (where there's also something to continue)?
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
458 ((and (looking-at "[ \t]*\\\\$")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
459 (not (c-awk-after-rbrace-or-statement-semicolon)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
460 ?\\)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
461 ;; A statement was completed on this line. How?
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
462 ((memq (char-before) '(?\; ?\})) ?\}) ; Real ; or }
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
463 (t ?\$))) ; A virtual semicolon.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
464 (end-of-line)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
465 (c-put-char-property (point) 'c-awk-NL-prop nl-prop)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
466 (forward-line))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
467
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
468 ;; We are now at a (possibly empty) sequence of content-free lines.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
469 ;; Set c-awk-NL-prop on each of these lines's EOL.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
470 (while (< (point) pos) ; one content-free line each iteration.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
471 (cond ; recalculate nl-prop from previous line's value.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
472 ((memq nl-prop '(?\} ?\$ nil)) (setq nl-prop ?\#))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
473 ((eq nl-prop ?\\)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
474 (if (not (looking-at "[ \t]*\\\\$")) (setq nl-prop ?\$)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
475 ;; ?\# (empty line) and ?\{ (open stmt) don't change.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
476 )
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
477 (forward-line)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
478 (c-put-char-property (1- (point)) 'c-awk-NL-prop nl-prop))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
479 nl-prop))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
480
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
481 (defun c-awk-get-NL-prop-prev-line (&optional do-lim)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
482 ;; Get the c-awk-NL-prop text-property from the previous line, calculating
79942
99c850a55c1c Correct typos, enhance comments.
Alan Mackenzie <acm@muc.de>
parents: 79717
diff changeset
483 ;; it if necessary. Return nil if we're already at BOB.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
484 ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
485 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
486 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
487 (if (bobp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
488 nil
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
489 (or (c-get-char-property (c-point 'eopl) 'c-awk-NL-prop)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
490 (c-awk-calculate-NL-prop-prev-line do-lim))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
491
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
492 (defun c-awk-get-NL-prop-cur-line (&optional do-lim)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
493 ;; Get the c-awk-NL-prop text-property from the current line, calculating it
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
494 ;; if necessary. (As a special case, the property doesn't get set on an
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
495 ;; empty line at EOB (there's no position to set the property on), but the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
496 ;; function returns the property value an EOL would have got.)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
497 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
498 ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
499 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
500 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
501 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
502 (let ((extra-nl nil))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
503 (end-of-line) ; Necessary for the following test to work.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
504 (when (= (forward-line) 1) ; if we were on the last line....
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
505 (insert-char ?\n 1) ; ...artificial eol is needed for comment detection.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
506 (setq extra-nl t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
507 (prog1 (c-awk-get-NL-prop-prev-line do-lim)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
508 (if extra-nl (delete-backward-char 1))))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
509
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
510 (defsubst c-awk-prev-line-incomplete-p (&optional do-lim)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
511 ;; Is there an incomplete statement at the end of the previous line?
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
512 ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
513 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
514 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
515 (memq (c-awk-get-NL-prop-prev-line do-lim) '(?\\ ?\{)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
516
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
517 (defsubst c-awk-cur-line-incomplete-p (&optional do-lim)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
518 ;; Is there an incomplete statement at the end of the current line?
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
519 ;; See c-awk-after-if-for-while-condition-p for a description of DO-LIM.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
520 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
521 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
522 (memq (c-awk-get-NL-prop-cur-line do-lim) '(?\\ ?\{)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
523
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
524 ;;;; NOTES ON "VIRTUAL SEMICOLONS"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
525 ;;;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
526 ;;;; A "virtual semicolon" is what terminates a statement when there is no ;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
527 ;;;; or } to do the job. Like point, it is considered to lie _between_ two
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
528 ;;;; characters. As from mid-March 2004, it is considered to lie just after
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
529 ;;;; the last non-syntactic-whitespace character on the line; (previously, it
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
530 ;;;; was considered an attribute of the EOL on the line). A real semicolon
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
531 ;;;; never counts as a virtual one.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
532
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
533 (defun c-awk-at-vsemi-p (&optional pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
534 ;; Is there a virtual semicolon at POS (or POINT)?
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
535 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
536 (let (nl-prop
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
537 (pos-or-point (progn (if pos (goto-char pos)) (point))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
538 (forward-line 0)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
539 (search-forward-regexp c-awk-one-line-non-syn-ws*-re)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
540 (and (eq (point) pos-or-point)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
541 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
542 (while (and (eq (setq nl-prop (c-awk-get-NL-prop-cur-line)) ?\\)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
543 (eq (forward-line) 0)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
544 (looking-at c-awk-blank-or-comment-line-re)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
545 (eq nl-prop ?\$))))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
546
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
547 (defun c-awk-vsemi-status-unknown-p ()
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
548 ;; Are we unsure whether there is a virtual semicolon on the current line?
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
549 ;; DO NOT under any circumstances attempt to calculate this; that would
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
550 ;; defeat the (admittedly kludgey) purpose of this function, which is to
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
551 ;; prevent an infinite recursion in c-beginning-of-statement-1 when point
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
552 ;; starts at a `while' token.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
553 (not (c-get-char-property (c-point 'eol) 'c-awk-NL-prop)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
554
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
555 (defun c-awk-clear-NL-props (beg end)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
556 ;; This function is run from before-change-hooks. It clears the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
557 ;; c-awk-NL-prop text property from beg to the end of the buffer (The END
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
558 ;; parameter is ignored). This ensures that the indentation engine will
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
559 ;; never use stale values for this property.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
560 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
561 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
562 (save-restriction
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
563 (widen)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
564 (c-clear-char-properties beg (point-max) 'c-awk-NL-prop)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
565
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
566 (defun c-awk-unstick-NL-prop ()
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
567 ;; Ensure that the text property c-awk-NL-prop is "non-sticky". Without
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
568 ;; this, a new newline inserted after an old newline (e.g. by C-j) would
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
569 ;; inherit any c-awk-NL-prop from the old newline. This would be a Bad
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
570 ;; Thing. This function's action is required by c-put-char-property.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
571 (if (and (boundp 'text-property-default-nonsticky) ; doesn't exist in Xemacs
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
572 (not (assoc 'c-awk-NL-prop text-property-default-nonsticky)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
573 (setq text-property-default-nonsticky
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
574 (cons '(c-awk-NL-prop . t) text-property-default-nonsticky))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
575
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
576 ;; The following is purely a diagnostic command, to be commented out of the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
577 ;; final release. ACM, 2002/6/1
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
578 ;; (defun NL-props ()
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
579 ;; (interactive)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
580 ;; (let (pl-prop cl-prop)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
581 ;; (message "Prev-line: %s Cur-line: %s"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
582 ;; (if (setq pl-prop (c-get-char-property (c-point 'eopl) 'c-awk-NL-prop))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
583 ;; (char-to-string pl-prop)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
584 ;; "nil")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
585 ;; (if (setq cl-prop (c-get-char-property (c-point 'eol) 'c-awk-NL-prop))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
586 ;; (char-to-string cl-prop)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
587 ;; "nil"))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
588 ;(define-key awk-mode-map [?\C-c ?\r] 'NL-props) ; commented out, 2002/8/31
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
589 ;for now. In the byte compiled version, this causes things to crash because
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
590 ;awk-mode-map isn't yet defined. :-(
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
591
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
592 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
593
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
594 ;; The following section of the code is to do with font-locking. The biggest
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
595 ;; problem for font-locking is deciding whether a / is a regular expression
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
596 ;; delimiter or a division sign - determining precisely where strings and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
597 ;; regular expressions start and stop is also troublesome. This is the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
598 ;; purpose of the function c-awk-set-syntax-table-properties and the myriad
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
599 ;; elisp regular expressions it uses.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
600 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
601 ;; Because AWK is a line oriented language, I felt the normal cc-mode strategy
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
602 ;; for font-locking unterminated strings (i.e. font-locking the buffer up to
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
603 ;; the next string delimiter as a string) was inappropriate. Instead,
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
604 ;; unbalanced string/regexp delimiters are given the warning font, being
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
605 ;; refonted with the string font as soon as the matching delimiter is entered.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
606 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
607 ;; This requires the region processed by the current font-lock after-change
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
608 ;; function to have access to the start of the string/regexp, which may be
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
609 ;; several lines back. The elisp "advice" feature is used on these functions
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
610 ;; to allow this.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
611
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
612 (defun c-awk-beginning-of-logical-line (&optional pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
613 ;; Go back to the start of the (apparent) current line (or the start of the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
614 ;; line containing POS), returning the buffer position of that point. I.e.,
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
615 ;; go back to the last line which doesn't have an escaped EOL before it.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
616 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
617 ;; This is guaranteed to be "safe" for syntactic analysis, i.e. outwith any
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
618 ;; comment, string or regexp. IT MAY WELL BE that this function should not be
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
619 ;; executed on a narrowed buffer.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
620 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
621 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
622 (if pos (goto-char pos))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
623 (forward-line 0)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
624 (while (and (> (point) (point-min))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
625 (eq (char-before (1- (point))) ?\\))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
626 (forward-line -1))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
627 (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
628
80155
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
629 (defun c-awk-beyond-logical-line (&optional pos)
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
630 ;; Return the position just beyond the (apparent) current logical line, or the
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
631 ;; one containing POS. This is usually the beginning of the next line which
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
632 ;; doesn't follow an escaped EOL. At EOB, this will be EOB.
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
633 ;;
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
634 ;; Point is unchanged.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
635 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
636 ;; This is guaranteed to be "safe" for syntactic analysis, i.e. outwith any
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
637 ;; comment, string or regexp. IT MAY WELL BE that this function should not be
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
638 ;; executed on a narrowed buffer.
80155
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
639 (save-excursion
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
640 (if pos (goto-char pos))
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
641 (end-of-line)
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
642 (while (and (< (point) (point-max))
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
643 (eq (char-before) ?\\))
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
644 (end-of-line 2))
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
645 (if (< (point) (point-max))
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
646 (1+ (point))
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
647 (point))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
648
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
649 ;; ACM, 2002/02/15: The idea of the next function is to put the "Error font"
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
650 ;; on strings/regexps which are missing their closing delimiter.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
651 ;; 2002/4/28. The default syntax for / has been changed from "string" to
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
652 ;; "punctuation", to reduce hassle when this character appears within a string
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
653 ;; or comment.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
654
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
655 (defun c-awk-set-string-regexp-syntax-table-properties (beg end)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
656 ;; BEG and END bracket a (possibly unterminated) string or regexp. The
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
657 ;; opening delimiter is after BEG, and the closing delimiter, IF ANY, is AFTER
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
658 ;; END. Set the appropriate syntax-table properties on the delimiters and
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
659 ;; contents of this string/regex.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
660 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
661 ;; "String" here can also mean a gawk 3.1 "localizable" string which starts
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
662 ;; with _". In this case, we step over the _ and ignore it; It will get it's
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
663 ;; font from an entry in awk-font-lock-keywords.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
664 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
665 ;; If the closing delimiter is missing (i.e., there is an EOL there) set the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
666 ;; STRING-FENCE property on the opening " or / and closing EOL.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
667 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
668 ;; This function does hidden buffer changes.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
669 (if (eq (char-after beg) ?_) (setq beg (1+ beg)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
670
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
671 ;; First put the properties on the delimiters.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
672 (cond ((eq end (point-max)) ; string/regexp terminated by EOB
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
673 (c-put-char-property beg 'syntax-table '(15))) ; (15) = "string fence"
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
674 ((/= (char-after beg) (char-after end)) ; missing end delimiter
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
675 (c-put-char-property beg 'syntax-table '(15))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
676 (c-put-char-property end 'syntax-table '(15)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
677 ((eq (char-after beg) ?/) ; Properly bracketed regexp
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
678 (c-put-char-property beg 'syntax-table '(7)) ; (7) = "string"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
679 (c-put-char-property end 'syntax-table '(7)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
680 (t)) ; Properly bracketed string: Nothing to do.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
681 ;; Now change the properties of any escaped "s in the string to punctuation.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
682 (save-excursion
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
683 (goto-char (1+ beg))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
684 (or (eobp)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
685 (while (search-forward "\"" end t)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
686 (c-put-char-property (1- (point)) 'syntax-table '(1))))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
687
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
688 (defun c-awk-syntax-tablify-string ()
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
689 ;; Point is at the opening " or _" of a string. Set the syntax-table
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
690 ;; properties on this string, leaving point just after the string.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
691 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
692 ;; The result is nil if a / immediately after the string would be a regexp
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
693 ;; opener, t if it would be a division sign.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
694 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
695 ;; This function does hidden buffer changes.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
696 (search-forward-regexp c-awk-string-without-end-here-re nil t) ; a (possibly unterminated) string
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
697 (c-awk-set-string-regexp-syntax-table-properties
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
698 (match-beginning 0) (match-end 0))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
699 (cond ((looking-at "\"")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
700 (forward-char)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
701 t) ; In AWK, ("15" / 5) gives 3 ;-)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
702 ((looking-at "[\n\r]") ; Unterminated string with EOL.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
703 (forward-char)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
704 nil) ; / on next line would start a regexp
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
705 (t nil))) ; Unterminated string at EOB
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
706
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
707 (defun c-awk-syntax-tablify-/ (anchor anchor-state-/div)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
708 ;; Point is at a /. Determine whether this is a division sign or a regexp
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
709 ;; opener, and if the latter, apply syntax-table properties to the entire
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
710 ;; regexp. Point is left immediately after the division sign or regexp, as
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
711 ;; the case may be.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
712 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
713 ;; ANCHOR-STATE-/DIV identifies whether a / at ANCHOR would have been a
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
714 ;; division sign (value t) or a regexp opener (value nil). The idea is that
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
715 ;; we analyse the line from ANCHOR up till point to determine what the / at
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
716 ;; point is.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
717 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
718 ;; The result is what ANCHOR-STATE-/DIV (see above) is where point is left.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
719 ;;
80155
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
720 ;; This function does hidden buffer changes.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
721 (let ((/point (point)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
722 (goto-char anchor)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
723 ;; Analyse the line to find out what the / is.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
724 (if (if anchor-state-/div
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
725 (not (search-forward-regexp c-awk-regexp-sign-re (1+ /point) t))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
726 (search-forward-regexp c-awk-div-sign-re (1+ /point) t))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
727 ;; A division sign.
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
728 (progn (goto-char (1+ /point)) nil)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
729 ;; A regexp opener
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
730 ;; Jump over the regexp innards, setting the match data.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
731 (goto-char /point)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
732 (search-forward-regexp c-awk-regexp-without-end-re)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
733 (c-awk-set-string-regexp-syntax-table-properties
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
734 (match-beginning 0) (match-end 0))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
735 (cond ((looking-at "/") ; Terminating /
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
736 (forward-char)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
737 t)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
738 ((looking-at "[\n\r]") ; Incomplete regexp terminated by EOL
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
739 (forward-char)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
740 nil) ; / on next line would start another regexp
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
741 (t nil))))) ; Unterminated regexp at EOB
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
742
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
743 (defun c-awk-set-syntax-table-properties (lim)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
744 ;; Scan the buffer text between point and LIM, setting (and clearing) the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
745 ;; syntax-table property where necessary.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
746 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
747 ;; This function is designed to be called as the FUNCTION in a MATCHER in
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
748 ;; font-lock-syntactic-keywords, and it always returns NIL (to inhibit
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
749 ;; repeated calls from font-lock: See elisp info page "Search-based
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
750 ;; Fontification"). It also gets called, with a bit of glue, from
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
751 ;; after-change-functions when font-lock isn't active. Point is left
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
752 ;; "undefined" after this function exits. THE BUFFER SHOULD HAVE BEEN
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
753 ;; WIDENED, AND ANY PRECIOUS MATCH-DATA SAVED BEFORE CALLING THIS ROUTINE.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
754 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
755 ;; We need to set/clear the syntax-table property on:
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
756 ;; (i) / - It is set to "string" on a / which is the opening or closing
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
757 ;; delimiter of the properly terminated regexp (and left unset on a
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
758 ;; division sign).
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
759 ;; (ii) the opener of an unterminated string/regexp, we set the property
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
760 ;; "generic string delimiter" on both the opening " or / and the end of the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
761 ;; line where the closing delimiter is missing.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
762 ;; (iii) "s inside strings/regexps (these will all be escaped "s). They are
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
763 ;; given the property "punctuation". This will later allow other routines
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
764 ;; to use the regexp "\\S\"*" to skip over the string innards.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
765 ;; (iv) Inside a comment, all syntax-table properties are cleared.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
766 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
767 ;; This function does hidden buffer changes.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
768 (let (anchor
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
769 (anchor-state-/div nil)) ; t means a following / would be a div sign.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
770 (c-awk-beginning-of-logical-line) ; ACM 2002/7/21. This is probably redundant.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
771 (c-clear-char-properties (point) lim 'syntax-table)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
772 ;; Once round the next loop for each string, regexp, or div sign
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
773 (while (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
774 ;; Skip any "harmless" lines before the next tricky one.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
775 (if (search-forward-regexp c-awk-harmless-lines+-here-re nil t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
776 (setq anchor-state-/div nil))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
777 (< (point) lim))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
778 (setq anchor (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
779 (search-forward-regexp c-awk-harmless-string*-here-re nil t)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
780 ;; We are now looking at either a " or a /.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
781 ;; Do our thing on the string, regexp or divsion sign.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
782 (setq anchor-state-/div
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
783 (if (looking-at "_?\"")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
784 (c-awk-syntax-tablify-string)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
785 (c-awk-syntax-tablify-/ anchor anchor-state-/div))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
786 nil))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
787
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
788 ;; ACM, 2002/07/21: Thoughts: We need an AWK Mode after-change function to set
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
789 ;; the syntax-table properties even when font-lock isn't enabled, for the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
790 ;; subsequent use of movement functions, etc. However, it seems that if font
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
791 ;; lock _is_ enabled, we can always leave it to do the job.
80155
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
792 (defvar c-awk-old-ByLL 0)
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
793 (make-variable-buffer-local 'c-awk-old-Byll)
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
794 ;; Just beyond logical line following the region which is about to be changed.
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
795 ;; Set in c-awk-record-region-clear-NL and used in c-awk-after-change.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
796
80155
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
797 (defun c-awk-record-region-clear-NL (beg end)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
798 ;; This function is called exclusively from the before-change-functions hook.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
799 ;; It does two things: Finds the end of the (logical) line on which END lies,
80155
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
800 ;; and clears c-awk-NL-prop text properties from this point onwards. BEG is
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
801 ;; ignored.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
802 ;;
80155
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
803 ;; On entry, the buffer will have been widened and match-data will have been
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
804 ;; saved; point is undefined on both entry and exit; the return value is
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
805 ;; ignored.
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
806 ;;
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
807 ;; This function does hidden buffer changes.
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
808 (c-save-buffer-state ()
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
809 (setq c-awk-old-ByLL (c-awk-beyond-logical-line end))
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
810 (c-save-buffer-state nil
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
811 (c-awk-clear-NL-props end (point-max)))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
812
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
813 (defun c-awk-end-of-change-region (beg end old-len)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
814 ;; Find the end of the region which needs to be font-locked after a change.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
815 ;; This is the end of the logical line on which the change happened, either
69140
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
816 ;; as it was before the change, or as it is now, whichever is later.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
817 ;; N.B. point is left undefined.
80155
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
818 (max (+ (- c-awk-old-ByLL old-len) (- end beg))
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
819 (c-awk-beyond-logical-line end)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
820
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
821 ;; ACM 2002/5/25. When font-locking is invoked by a buffer change, the region
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
822 ;; specified by the font-lock after-change function must be expanded to
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
823 ;; include ALL of any string or regexp within the region. The simplest way to
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
824 ;; do this in practice is to use the beginning/end-of-logical-line functions.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
825 ;; Don't overlook the possibility of the buffer change being the "recapturing"
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
826 ;; of a previously escaped newline.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
827
80155
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
828 ;; ACM 2008-02-05:
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
829 (defun c-awk-extend-and-syntax-tablify-region (beg end old-len)
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
830 ;; Expand the region (BEG END) as needed to (c-new-BEG c-new-END) then put
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
831 ;; `syntax-table' properties on this region.
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
832 ;;
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
833 ;; This function is called from an after-change function, BEG END and
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
834 ;; OLD-LEN being the standard parameters.
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
835 ;;
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
836 ;; Point is undefined both before and after this function call, the buffer
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
837 ;; has been widened, and match-data saved. The return value is ignored.
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
838 ;;
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
839 ;; It prepares the buffer for font
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
840 ;; locking, hence must get called before `font-lock-after-change-function'.
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
841 ;;
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
842 ;; This function is the AWK value of `c-before-font-lock-function'.
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
843 ;; It does hidden buffer changes.
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
844 (c-save-buffer-state ()
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
845 (setq c-new-END (c-awk-end-of-change-region beg end old-len))
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
846 (setq c-new-BEG (c-awk-beginning-of-logical-line beg))
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
847 (goto-char c-new-BEG)
78cb7fb87a03 Set of changes so that "obtrusive" syntactic elements in a C/C++/ObjC
Alan Mackenzie <acm@muc.de>
parents: 80054
diff changeset
848 (c-awk-set-syntax-table-properties c-new-END)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
849
71754
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
850 ;; Awk regexps written with help from Peter Galbraith
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
851 ;; <galbraith@mixing.qc.dfo.ca>.
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
852 ;; Take GNU Emacs's 'words out of the following regexp-opts. They dont work
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
853 ;; in Xemacs 21.4.4. acm 2002/9/19.
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
854 (defconst awk-font-lock-keywords
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
855 (eval-when-compile
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
856 (list
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
857 ;; Function names.
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
858 '("^\\s *\\(func\\(tion\\)?\\)\\>\\s *\\(\\sw+\\)?"
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
859 (1 font-lock-keyword-face) (3 font-lock-function-name-face nil t))
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
860 ;;
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
861 ;; Variable names.
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
862 (cons
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
863 (concat "\\<"
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
864 (regexp-opt
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
865 '("ARGC" "ARGIND" "ARGV" "BINMODE" "CONVFMT" "ENVIRON"
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
866 "ERRNO" "FIELDWIDTHS" "FILENAME" "FNR" "FS" "IGNORECASE"
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
867 "LINT" "NF" "NR" "OFMT" "OFS" "ORS" "PROCINFO" "RLENGTH"
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
868 "RS" "RSTART" "RT" "SUBSEP" "TEXTDOMAIN") t) "\\>")
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
869 'font-lock-variable-name-face)
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
870
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
871 ;; Special file names. (acm, 2002/7/22)
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
872 ;; The following regexp was created by first evaluating this in GNU Emacs 21.1:
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
873 ;; (regexp-opt '("/dev/stdin" "/dev/stdout" "/dev/stderr" "/dev/fd/n" "/dev/pid"
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
874 ;; "/dev/ppid" "/dev/pgrpid" "/dev/user") 'words)
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
875 ;; , removing the "?:" from each "\\(?:" (for backward compatibility with older Emacsen)
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
876 ;; , replacing the "n" in "dev/fd/n" with "[0-9]+"
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
877 ;; , removing the unwanted \\< at the beginning, and finally filling out the
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
878 ;; regexp so that a " must come before, and either a " or heuristic stuff after.
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
879 ;; The surrounding quotes are fontified along with the filename, since, semantically,
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
880 ;; they are an indivisible unit.
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
881 '("\\(\"/dev/\\(fd/[0-9]+\\|p\\(\\(\\(gr\\)?p\\)?id\\)\\|\
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
882 std\\(err\\|in\\|out\\)\\|user\\)\\)\\>\
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
883 \\(\\(\"\\)\\|\\([^\"/\n\r][^\"\n\r]*\\)?$\\)"
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
884 (1 font-lock-variable-name-face t)
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
885 (8 font-lock-variable-name-face t t))
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
886 ;; Do the same (almost) with
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
887 ;; (regexp-opt '("/inet/tcp/lport/rhost/rport" "/inet/udp/lport/rhost/rport"
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
888 ;; "/inet/raw/lport/rhost/rport") 'words)
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
889 ;; This cannot be combined with the above pattern, because the match number
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
890 ;; for the (optional) closing \" would then exceed 9.
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
891 '("\\(\"/inet/\\(\\(raw\\|\\(tc\\|ud\\)p\\)/lport/rhost/rport\\)\\)\\>\
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
892 \\(\\(\"\\)\\|\\([^\"/\n\r][^\"\n\r]*\\)?$\\)"
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
893 (1 font-lock-variable-name-face t)
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
894 (6 font-lock-variable-name-face t t))
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
895
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
896 ;; Keywords.
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
897 (concat "\\<"
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
898 (regexp-opt
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
899 '("BEGIN" "END" "break" "continue" "delete" "do" "else"
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
900 "exit" "for" "getline" "if" "in" "next" "nextfile"
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
901 "return" "while")
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
902 t) "\\>")
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
903
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
904 ;; Builtins.
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
905 `(eval . (list
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
906 ,(concat
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
907 "\\<"
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
908 (regexp-opt
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
909 '("adump" "and" "asort" "atan2" "bindtextdomain" "close"
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
910 "compl" "cos" "dcgettext" "exp" "extension" "fflush"
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
911 "gensub" "gsub" "index" "int" "length" "log" "lshift"
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
912 "match" "mktime" "or" "print" "printf" "rand" "rshift"
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
913 "sin" "split" "sprintf" "sqrt" "srand" "stopme"
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
914 "strftime" "strtonum" "sub" "substr" "system"
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
915 "systime" "tolower" "toupper" "xor") t)
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
916 "\\>")
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
917 0 c-preprocessor-face-name))
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
918
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
919 ;; gawk debugging keywords. (acm, 2002/7/21)
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
920 ;; (Removed, 2003/6/6. These functions are now fontified as built-ins)
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
921 ;; (list (concat "\\<" (regexp-opt '("adump" "stopme") t) "\\>")
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
922 ;; 0 'font-lock-warning-face)
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
923
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
924 ;; User defined functions with an apparent spurious space before the
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
925 ;; opening parenthesis. acm, 2002/5/30.
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
926 `(,(concat "\\(\\w\\|_\\)" c-awk-escaped-nls* "\\s "
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
927 c-awk-escaped-nls*-with-space* "(")
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
928 (0 'font-lock-warning-face))
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
929
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
930 ;; Space after \ in what looks like an escaped newline. 2002/5/31
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
931 '("\\\\\\s +$" 0 font-lock-warning-face t)
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
932
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
933 ;; Unbalanced string (") or regexp (/) delimiters. 2002/02/16.
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
934 '("\\s|" 0 font-lock-warning-face t nil)
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
935 ;; gawk 3.1 localizable strings ( _"translate me!"). 2002/5/21
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
936 '("\\(_\\)\\s|" 1 font-lock-warning-face)
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
937 '("\\(_\\)\\s\"" 1 font-lock-string-face) ; FIXME! not for XEmacs. 2002/10/6
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
938 ))
60304f6ae360 * progmodes/cc-awk.el, cc-defs.el, cc-fonts.el, cc-langs.el,
Alan Mackenzie <acm@muc.de>
parents: 69140
diff changeset
939 "Default expressions to highlight in AWK mode.")
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
940
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
941 ;; ACM 2002/9/29. Movement functions, e.g. for C-M-a and C-M-e
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
942
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
943 ;; The following three regexps differ from those earlier on in cc-awk.el in
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
944 ;; that they assume the syntax-table properties have been set. They are thus
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
945 ;; not useful for code which sets these properties.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
946 (defconst c-awk-terminated-regexp-or-string-here-re "\\=\\s\"\\S\"*\\s\"")
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
947 ;; Matches a terminated string/regexp.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
948
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
949 (defconst c-awk-unterminated-regexp-or-string-here-re "\\=\\s|\\S|*$")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
950 ;; Matches an unterminated string/regexp, NOT including the eol at the end.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
951
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
952 (defconst c-awk-harmless-pattern-characters*
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
953 (concat "\\([^{;#/\"\\\\\n\r]\\|" c-awk-esc-pair-re "\\)*"))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
954 ;; Matches any "harmless" character in a pattern or an escaped character pair.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
955
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
956 (defun c-awk-at-statement-end-p ()
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
957 ;; Point is not inside a comment or string. Is it AT the end of a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
958 ;; statement? This means immediately after the last non-ws character of the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
959 ;; statement. The caller is responsible for widening the buffer, if
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
960 ;; appropriate.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
961 (and (not (bobp))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
962 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
963 (backward-char)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
964 (or (looking-at "[};]")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
965 (and (memq (c-awk-get-NL-prop-cur-line) '(?\$ ?\\))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
966 (looking-at
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
967 (eval-when-compile
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
968 (concat "[^ \t\n\r\\]" c-awk-escaped-nls*-with-space*
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
969 "[#\n\r]"))))))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
970
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
971 (defun c-awk-beginning-of-defun (&optional arg)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
972 "Move backward to the beginning of an AWK \"defun\". With ARG, do it that
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
973 many times. Negative arg -N means move forward to Nth following beginning of
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
974 defun. Returns t unless search stops due to beginning or end of buffer.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
975
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
976 By a \"defun\" is meant either a pattern-action pair or a function. The start
63517
7316ffa5763c (c-awk-beginning-of-defun): Fix spelling in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 62641
diff changeset
977 of a defun is recognized as code starting at column zero which is neither a
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
978 closing brace nor a comment nor a continuation of the previous line. Unlike
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
979 in some other modes, having an opening brace at column 0 is neither necessary
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
980 nor helpful.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
981
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
982 Note that this function might do hidden buffer changes. See the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
983 comment at the start of cc-engine.el for more info."
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
984 (interactive "p")
77081
e8bd3e011b64 Changes to make `narrow-to-defun' and `mark-defun' work properly in CC
Alan Mackenzie <acm@muc.de>
parents: 75347
diff changeset
985 (or arg (setq arg 1))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
986 (save-match-data
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
987 (c-save-buffer-state ; ensures the buffer is writable.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
988 nil
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
989 (let ((found t)) ; Has the most recent regexp search found b-of-defun?
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
990 (if (>= arg 0)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
991 ;; Go back one defun each time round the following loop. (For +ve arg)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
992 (while (and found (> arg 0) (not (eq (point) (point-min))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
993 ;; Go back one "candidate" each time round the next loop until one
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
994 ;; is genuinely a beginning-of-defun.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
995 (while (and (setq found (search-backward-regexp
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
996 "^[^#} \t\n\r]" (point-min) 'stop-at-limit))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
997 (not (memq (c-awk-get-NL-prop-prev-line) '(?\$ ?\} ?\#)))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
998 (setq arg (1- arg)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
999 ;; The same for a -ve arg.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1000 (if (not (eq (point) (point-max))) (forward-char 1))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1001 (while (and found (< arg 0) (not (eq (point) (point-max)))) ; The same for -ve arg.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1002 (while (and (setq found (search-forward-regexp
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1003 "^[^#} \t\n\r]" (point-max) 'stop-at-limit))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
1004 (not (memq (c-awk-get-NL-prop-prev-line) '(?\$ ?\} ?\#)))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1005 (setq arg (1+ arg)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1006 (if found (goto-char (match-beginning 0))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1007 (eq arg 0)))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1008
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1009 (defun c-awk-forward-awk-pattern ()
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1010 ;; Point is at the start of an AWK pattern (which may be null) or function
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1011 ;; declaration. Move to the pattern's end, and past any trailing space or
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1012 ;; comment. Typically, we stop at the { which denotes the corresponding AWK
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1013 ;; action/function body. Otherwise we stop at the EOL (or ;) marking the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1014 ;; absence of an explicit action.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
1015 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
1016 ;; This function might do hidden buffer changes.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1017 (while
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1018 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1019 (search-forward-regexp c-awk-harmless-pattern-characters*)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1020 (if (looking-at "#") (end-of-line))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1021 (cond
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1022 ((eobp) nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1023 ((looking-at "[{;]") nil) ; We've finished!
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1024 ((eolp)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1025 (if (c-awk-cur-line-incomplete-p)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1026 (forward-line) ; returns non-nil
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1027 nil))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1028 ((search-forward-regexp c-awk-terminated-regexp-or-string-here-re nil t))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1029 ((search-forward-regexp c-awk-unterminated-regexp-or-string-here-re nil t))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1030 ((looking-at "/") (forward-char) t))))) ; division sign.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1031
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1032 (defun c-awk-end-of-defun1 ()
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1033 ;; point is at the start of a "defun". Move to its end. Return end position.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
1034 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
1035 ;; This function might do hidden buffer changes.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1036 (c-awk-forward-awk-pattern)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1037 (cond
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1038 ((looking-at "{") (goto-char (scan-sexps (point) 1)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1039 ((looking-at ";") (forward-char))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1040 ((eolp))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1041 (t (error "c-awk-end-of-defun1: Failure of c-awk-forward-awk-pattern")))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1042 (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1043
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1044 (defun c-awk-beginning-of-defun-p ()
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1045 ;; Are we already at the beginning of a defun? (i.e. at code in column 0
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1046 ;; which isn't a }, and isn't a continuation line of any sort.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
1047 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
1048 ;; This function might do hidden buffer changes.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1049 (and (looking-at "^[^#} \t\n\r]")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1050 (not (c-awk-prev-line-incomplete-p))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1051
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1052 (defun c-awk-end-of-defun (&optional arg)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1053 "Move forward to next end of defun. With argument, do it that many times.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1054 Negative argument -N means move back to Nth preceding end of defun.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1055
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1056 An end of a defun occurs right after the closing brace that matches the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1057 opening brace at its start, or immediately after the AWK pattern when there is
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
1058 no explicit action; see function `c-awk-beginning-of-defun'.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
1059
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
1060 Note that this function might do hidden buffer changes. See the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
1061 comment at the start of cc-engine.el for more info."
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1062 (interactive "p")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1063 (or arg (setq arg 1))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1064 (save-match-data
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1065 (c-save-buffer-state
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1066 nil
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1067 (let ((start-point (point)) end-point)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1068 ;; Strategy: (For +ve ARG): If we're not already at a beginning-of-defun,
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1069 ;; move backwards to one.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1070 ;; Repeat [(i) move forward to end-of-current-defun (see below);
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1071 ;; (ii) If this isn't it, move forward to beginning-of-defun].
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1072 ;; We start counting ARG only when step (i) has passed the original point.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1073 (when (> arg 0)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1074 ;; Try to move back to a beginning-of-defun, if not already at one.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1075 (if (not (c-awk-beginning-of-defun-p))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1076 (when (not (c-awk-beginning-of-defun 1)) ; No bo-defun before point.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1077 (goto-char start-point)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1078 (c-awk-beginning-of-defun -1))) ; if this fails, we're at EOB, tough!
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1079 ;; Now count forward, one defun at a time
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1080 (while (and (not (eobp))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1081 (c-awk-end-of-defun1)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1082 (if (> (point) start-point) (setq arg (1- arg)) t)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1083 (> arg 0)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1084 (c-awk-beginning-of-defun -1))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1085
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1086 (when (< arg 0)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1087 (setq end-point start-point)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1088 (while (and (not (bobp))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1089 (c-awk-beginning-of-defun 1)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1090 (if (< (setq end-point (if (bobp) (point)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1091 (save-excursion (c-awk-end-of-defun1))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1092 start-point)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1093 (setq arg (1+ arg)) t)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1094 (< arg 0)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1095 (goto-char (min start-point end-point)))))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1096
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64699
diff changeset
1097
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1098 (cc-provide 'cc-awk) ; Changed from 'awk-mode, ACM 2002/5/21
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51714
diff changeset
1099
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51714
diff changeset
1100 ;;; arch-tag: c4836289-3aa4-4a59-9934-9ccc2bacccf3
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff changeset
1101 ;;; awk-mode.el ends here