cc-langs.el 130 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362
  1. ;;; cc-langs.el --- language specific settings for CC Mode -*- coding: utf-8 -*-
  2. ;; Copyright (C) 1985, 1987, 1992-2015 Free Software Foundation, Inc.
  3. ;; Authors: 2002- Alan Mackenzie
  4. ;; 1998- Martin Stjernholm
  5. ;; 1992-1999 Barry A. Warsaw
  6. ;; 1987 Dave Detlefs
  7. ;; 1987 Stewart Clamen
  8. ;; 1985 Richard M. Stallman
  9. ;; Maintainer: bug-cc-mode@gnu.org
  10. ;; Created: 22-Apr-1997 (split from cc-mode.el)
  11. ;; Keywords: c languages
  12. ;; Package: cc-mode
  13. ;; This file is part of GNU Emacs.
  14. ;; GNU Emacs is free software: you can redistribute it and/or modify
  15. ;; it under the terms of the GNU General Public License as published by
  16. ;; the Free Software Foundation, either version 3 of the License, or
  17. ;; (at your option) any later version.
  18. ;; GNU Emacs is distributed in the hope that it will be useful,
  19. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. ;; GNU General Public License for more details.
  22. ;; You should have received a copy of the GNU General Public License
  23. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  24. ;;; Commentary:
  25. ;; HACKERS NOTE: There's heavy macro magic here. If you need to make
  26. ;; changes in this or other files containing `c-lang-defconst' but
  27. ;; don't want to read through the longer discussion below then read
  28. ;; this:
  29. ;;
  30. ;; o A change in a `c-lang-defconst' or `c-lang-defvar' will not take
  31. ;; effect if the file containing the mode init function (typically
  32. ;; cc-mode.el) is byte compiled.
  33. ;; o To make changes show in font locking you need to reevaluate the
  34. ;; `*-font-lock-keywords-*' constants, which normally is easiest to
  35. ;; do with M-x eval-buffer in cc-fonts.el.
  36. ;; o In either case it's necessary to reinitialize the mode to make
  37. ;; the changes show in an existing buffer.
  38. ;;; Introduction to the language dependent variable system:
  39. ;;
  40. ;; This file contains all the language dependent variables, except
  41. ;; those specific for font locking which reside in cc-fonts.el. As
  42. ;; far as possible, all the differences between the languages that CC
  43. ;; Mode supports are described with these variables only, so that the
  44. ;; code can be shared.
  45. ;;
  46. ;; The language constant system (see cc-defs.el) is used to specify
  47. ;; various language dependent info at a high level, such as lists of
  48. ;; keywords, and then from them generate - at compile time - the
  49. ;; various regexps and other low-level structures actually employed in
  50. ;; the code at runtime.
  51. ;;
  52. ;; This system is also designed to make it easy for developers of
  53. ;; derived modes to customize the source constants for new language
  54. ;; variants, without having to keep up with the exact regexps etc that
  55. ;; are used in each CC Mode version. It's possible from an external
  56. ;; package to add a new language by inheriting an existing one, and
  57. ;; then change specific constants as necessary for the new language.
  58. ;; The old values for those constants (and the values of all the other
  59. ;; high-level constants) may be used to build the new ones, and those
  60. ;; new values will in turn be used by the low-level definitions here
  61. ;; to build the runtime constants appropriately for the new language
  62. ;; in the current version of CC Mode.
  63. ;;
  64. ;; Like elsewhere in CC Mode, the existence of a doc string signifies
  65. ;; that a language constant is part of the external API, and that it
  66. ;; therefore can be used with a high confidence that it will continue
  67. ;; to work with future versions of CC Mode. Even so, it's not
  68. ;; unlikely that such constants will change meaning slightly as this
  69. ;; system is refined further; a certain degree of dependence on the CC
  70. ;; Mode version is unavoidable when hooking in at this level. Also
  71. ;; note that there's still work to be done to actually use these
  72. ;; constants everywhere inside CC Mode; there are still hardcoded
  73. ;; values in many places in the code.
  74. ;;
  75. ;; Separate packages will also benefit from the compile time
  76. ;; evaluation; the byte compiled file(s) for them will contain the
  77. ;; compiled runtime constants ready for use by (the byte compiled) CC
  78. ;; Mode, and the source definitions in this file don't have to be
  79. ;; loaded then. However, if a byte compiled package is loaded that
  80. ;; has been compiled with a different version of CC Mode than the one
  81. ;; currently loaded, then the compiled-in values will be discarded and
  82. ;; new ones will be built when the mode is initialized. That will
  83. ;; automatically trig a load of the file(s) containing the source
  84. ;; definitions (i.e. this file and/or cc-fonts.el) if necessary.
  85. ;;
  86. ;; A small example of a derived mode is available at
  87. ;; <http://cc-mode.sourceforge.net/derived-mode-ex.el>. It also
  88. ;; contains some useful hints for derived mode developers.
  89. ;;; Using language variables:
  90. ;;
  91. ;; The `c-lang-defvar' forms in this file comprise the language
  92. ;; variables that CC Mode uses. It does not work to use
  93. ;; `c-lang-defvar' anywhere else (which isn't much of a limitation
  94. ;; since these variables sole purpose is to interface with the CC Mode
  95. ;; core functions). The values in these `c-lang-defvar's are not
  96. ;; evaluated right away but instead collected to a single large `setq'
  97. ;; that can be inserted for a particular language with the
  98. ;; `c-init-language-vars' macro.
  99. ;; This file is only required at compile time, or when not running
  100. ;; from byte compiled files, or when the source definitions for the
  101. ;; language constants are requested.
  102. ;;; Code:
  103. ;; For Emacs < 22.2.
  104. (eval-and-compile
  105. (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
  106. (eval-when-compile
  107. (let ((load-path
  108. (if (and (boundp 'byte-compile-dest-file)
  109. (stringp byte-compile-dest-file))
  110. (cons (file-name-directory byte-compile-dest-file) load-path)
  111. load-path)))
  112. (load "cc-bytecomp" nil t)))
  113. (cc-require 'cc-defs)
  114. (cc-require 'cc-vars)
  115. ;; This file is not always loaded. See note above.
  116. (cc-external-require (if (eq c--mapcan-status 'cl-mapcan) 'cl-lib 'cl))
  117. ;;; Setup for the `c-lang-defvar' system.
  118. (eval-and-compile
  119. ;; These are used to collect the init forms from the subsequent
  120. ;; `c-lang-defvar' and `c-lang-setvar'. They are used to build the
  121. ;; lambda in `c-make-init-lang-vars-fun' below, and to build `defvar's
  122. ;; and `make-variable-buffer-local's in cc-engine and
  123. ;; `make-local-variable's in `c-init-language-vars-for'.
  124. (defvar c-lang-variable-inits nil)
  125. (defvar c-lang-variable-inits-tail nil)
  126. (setq c-lang-variable-inits (list nil)
  127. c-lang-variable-inits-tail c-lang-variable-inits)
  128. (defvar c-emacs-variable-inits nil)
  129. (defvar c-emacs-variable-inits-tail nil)
  130. (setq c-emacs-variable-inits (list nil)
  131. c-emacs-variable-inits-tail c-emacs-variable-inits))
  132. (defmacro c-lang-defvar (var val &optional doc)
  133. "Declares the buffer local variable VAR to get the value VAL. VAL is
  134. evaluated and assigned at mode initialization. More precisely, VAL is
  135. evaluated and bound to VAR when the result from the macro
  136. `c-init-language-vars' is evaluated.
  137. `c-lang-const' is typically used in VAL to get the right value for the
  138. language being initialized, and such calls will be macro expanded to
  139. the evaluated constant value at compile time."
  140. (when (and (not doc)
  141. (eq (car-safe val) 'c-lang-const)
  142. (eq (nth 1 val) var)
  143. (not (nth 2 val)))
  144. ;; Special case: If there's no docstring and the value is a
  145. ;; simple (c-lang-const foo) where foo is the same name as VAR
  146. ;; then take the docstring from the language constant foo.
  147. (setq doc (get (intern (symbol-name (nth 1 val)) c-lang-constants)
  148. 'variable-documentation)))
  149. (or (stringp doc)
  150. (setq doc nil))
  151. (let ((elem (assq var (cdr c-lang-variable-inits))))
  152. (if elem
  153. (setcdr elem (list val doc))
  154. (setcdr c-lang-variable-inits-tail (list (list var val doc)))
  155. (setq c-lang-variable-inits-tail (cdr c-lang-variable-inits-tail))))
  156. ;; Return the symbol, like the other def* forms.
  157. `',var)
  158. (defmacro c-lang-setvar (var val)
  159. "Causes the variable VAR to be made buffer local and to get set to the
  160. value VAL. VAL is evaluated and assigned at mode initialization. More
  161. precisely, VAL is evaluated and bound to VAR when the result from the
  162. macro `c-init-language-vars' is evaluated. VAR is typically a standard
  163. Emacs variable like `comment-start'.
  164. `c-lang-const' is typically used in VAL to get the right value for the
  165. language being initialized, and such calls will be macro expanded to
  166. the evaluated constant value at compile time."
  167. (let ((elem (assq var (cdr c-emacs-variable-inits))))
  168. (if elem
  169. (setcdr elem (list val)) ; Maybe remove "list", sometime. 2006-07-19
  170. (setcdr c-emacs-variable-inits-tail (list (list var val)))
  171. (setq c-emacs-variable-inits-tail (cdr c-emacs-variable-inits-tail))))
  172. ;; Return the symbol, like the other def* forms.
  173. `',var)
  174. (put 'c-lang-defvar 'lisp-indent-function 'defun)
  175. ; (eval-after-load "edebug" ; 2006-07-09: def-edebug-spec is now in subr.el.
  176. ; '
  177. (def-edebug-spec c-lang-defvar
  178. (&define name def-form &optional stringp)) ;)
  179. ;; Suppress "might not be defined at runtime" warning.
  180. ;; This file is only used when compiling other cc files.
  181. ;; These are defined in cl as aliases to the cl- versions.
  182. ;(declare-function delete-duplicates "cl-seq" (cl-seq &rest cl-keys) t)
  183. ;(declare-function mapcan "cl-extra" (cl-func cl-seq &rest cl-rest) t)
  184. (eval-and-compile
  185. ;; Some helper functions used when building the language constants.
  186. (defun c-filter-ops (ops opgroup-filter op-filter &optional xlate)
  187. ;; Extract a subset of the operators in the list OPS in a DWIM:ey
  188. ;; way. The return value is a plain list of operators:
  189. ;;
  190. ;; OPS either has the structure of `c-operators', is a single
  191. ;; group in `c-operators', or is a plain list of operators.
  192. ;;
  193. ;; OPGROUP-FILTER specifies how to select the operator groups. It
  194. ;; can be t to choose all groups, a list of group type symbols
  195. ;; (such as 'prefix) to accept, or a function which will be called
  196. ;; with the group symbol for each group and should return non-nil
  197. ;; if that group is to be included.
  198. ;;
  199. ;; If XLATE is given, it's a function which is called for each
  200. ;; matching operator and its return value is collected instead.
  201. ;; If it returns a list, the elements are spliced directly into
  202. ;; the final result, which is returned as a list with duplicates
  203. ;; removed using `equal'.
  204. ;;
  205. ;; `c-mode-syntax-table' for the current mode is in effect during
  206. ;; the whole procedure.
  207. (unless (listp (car-safe ops))
  208. (setq ops (list ops)))
  209. (cond ((eq opgroup-filter t)
  210. (setq opgroup-filter (lambda (opgroup) t)))
  211. ((not (functionp opgroup-filter))
  212. (setq opgroup-filter `(lambda (opgroup)
  213. (memq opgroup ',opgroup-filter)))))
  214. (cond ((eq op-filter t)
  215. (setq op-filter (lambda (op) t)))
  216. ((stringp op-filter)
  217. (setq op-filter `(lambda (op)
  218. (string-match ,op-filter op)))))
  219. (unless xlate
  220. (setq xlate 'identity))
  221. (c-with-syntax-table (c-lang-const c-mode-syntax-table)
  222. (c--delete-duplicates
  223. (c--mapcan (lambda (opgroup)
  224. (when (if (symbolp (car opgroup))
  225. (when (funcall opgroup-filter (car opgroup))
  226. (setq opgroup (cdr opgroup))
  227. t)
  228. t)
  229. (c--mapcan (lambda (op)
  230. (when (funcall op-filter op)
  231. (let ((res (funcall xlate op)))
  232. (if (listp res) res (list res)))))
  233. opgroup)))
  234. ops)
  235. :test 'equal))))
  236. ;;; Various mode specific values that aren't language related.
  237. (c-lang-defconst c-mode-menu
  238. ;; The definition for the mode menu. The menu title is prepended to
  239. ;; this before it's fed to `easy-menu-define'.
  240. t `(["Comment Out Region" comment-region
  241. (c-fn-region-is-active-p)]
  242. ["Uncomment Region" (comment-region (region-beginning)
  243. (region-end) '(4))
  244. (c-fn-region-is-active-p)]
  245. ["Indent Expression" c-indent-exp
  246. (memq (char-after) '(?\( ?\[ ?\{))]
  247. ["Indent Line or Region" c-indent-line-or-region t]
  248. ["Fill Comment Paragraph" c-fill-paragraph t]
  249. "----"
  250. ["Backward Statement" c-beginning-of-statement t]
  251. ["Forward Statement" c-end-of-statement t]
  252. ,@(when (c-lang-const c-opt-cpp-prefix)
  253. ;; Only applicable if there's a cpp preprocessor.
  254. `(["Up Conditional" c-up-conditional t]
  255. ["Backward Conditional" c-backward-conditional t]
  256. ["Forward Conditional" c-forward-conditional t]
  257. "----"
  258. ["Macro Expand Region" c-macro-expand
  259. (c-fn-region-is-active-p)]
  260. ["Backslashify" c-backslash-region
  261. (c-fn-region-is-active-p)]))
  262. "----"
  263. ("Style..."
  264. ["Set Style..." c-set-style t]
  265. ["Show Current Style Name" (message
  266. "Style Name: %s"
  267. c-indentation-style)
  268. t]
  269. ["Guess Style from this Buffer" c-guess-buffer-no-install t]
  270. ["Install the Last Guessed Style..." c-guess-install
  271. (and c-guess-guessed-offsets-alist
  272. c-guess-guessed-basic-offset) ]
  273. ["View the Last Guessed Style" c-guess-view
  274. (and c-guess-guessed-offsets-alist
  275. c-guess-guessed-basic-offset) ])
  276. "----"
  277. ("Toggle..."
  278. ["Syntactic indentation" c-toggle-syntactic-indentation
  279. :style toggle :selected c-syntactic-indentation]
  280. ["Electric mode" c-toggle-electric-state
  281. :style toggle :selected c-electric-flag]
  282. ["Auto newline" c-toggle-auto-newline
  283. :style toggle :selected c-auto-newline]
  284. ["Hungry delete" c-toggle-hungry-state
  285. :style toggle :selected c-hungry-delete-key]
  286. ["Subword mode" c-subword-mode
  287. :style toggle :selected (and (boundp 'c-subword-mode)
  288. c-subword-mode)])))
  289. ;;; Syntax tables.
  290. (defun c-populate-syntax-table (table)
  291. "Populate the given syntax table as necessary for a C-like language.
  292. This includes setting \\=' and \" as string delimiters, and setting up
  293. the comment syntax to handle both line style \"//\" and block style
  294. \"/*\" \"*/\" comments."
  295. (modify-syntax-entry ?_ "_" table)
  296. (modify-syntax-entry ?\\ "\\" table)
  297. (modify-syntax-entry ?+ "." table)
  298. (modify-syntax-entry ?- "." table)
  299. (modify-syntax-entry ?= "." table)
  300. (modify-syntax-entry ?% "." table)
  301. (modify-syntax-entry ?< "." table)
  302. (modify-syntax-entry ?> "." table)
  303. (modify-syntax-entry ?& "." table)
  304. (modify-syntax-entry ?| "." table)
  305. (modify-syntax-entry ?\' "\"" table)
  306. (modify-syntax-entry ?\240 "." table)
  307. ;; Set up block and line oriented comments. The new C
  308. ;; standard mandates both comment styles even in C, so since
  309. ;; all languages now require dual comments, we make this the
  310. ;; default.
  311. (cond
  312. ;; XEmacs
  313. ((memq '8-bit c-emacs-features)
  314. (modify-syntax-entry ?/ ". 1456" table)
  315. (modify-syntax-entry ?* ". 23" table))
  316. ;; Emacs
  317. ((memq '1-bit c-emacs-features)
  318. (modify-syntax-entry ?/ ". 124b" table)
  319. (modify-syntax-entry ?* ". 23" table))
  320. ;; incompatible
  321. (t (error "CC Mode is incompatible with this version of Emacs")))
  322. (modify-syntax-entry ?\n "> b" table)
  323. ;; Give CR the same syntax as newline, for selective-display
  324. (modify-syntax-entry ?\^m "> b" table))
  325. (c-lang-defconst c-make-mode-syntax-table
  326. "Functions that generates the mode specific syntax tables.
  327. The syntax tables aren't stored directly since they're quite large."
  328. t `(lambda ()
  329. (let ((table (make-syntax-table)))
  330. (c-populate-syntax-table table)
  331. ;; Mode specific syntaxes.
  332. ,(cond ((or (c-major-mode-is 'objc-mode) (c-major-mode-is 'java-mode))
  333. ;; Let '@' be part of symbols in ObjC to cope with
  334. ;; its compiler directives as single keyword tokens.
  335. ;; This is then necessary since it's assumed that
  336. ;; every keyword is a single symbol.
  337. `(modify-syntax-entry ?@ "_" table))
  338. ((c-major-mode-is 'pike-mode)
  339. `(modify-syntax-entry ?@ "." table)))
  340. table)))
  341. (c-lang-defconst c-mode-syntax-table
  342. ;; The syntax tables in evaluated form. Only used temporarily when
  343. ;; the constants in this file are evaluated.
  344. t (funcall (c-lang-const c-make-mode-syntax-table)))
  345. (c-lang-defconst c++-make-template-syntax-table
  346. ;; A variant of `c++-mode-syntax-table' that defines `<' and `>' as
  347. ;; parenthesis characters. Used temporarily when template argument
  348. ;; lists are parsed. Note that this encourages incorrect parsing of
  349. ;; templates since they might contain normal operators that uses the
  350. ;; '<' and '>' characters. Therefore this syntax table might go
  351. ;; away when CC Mode handles templates correctly everywhere. WHILE
  352. ;; THIS SYNTAX TABLE IS CURRENT, `c-parse-state' MUST _NOT_ BE
  353. ;; CALLED!!!
  354. t nil
  355. (java c++) `(lambda ()
  356. (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table))))
  357. (modify-syntax-entry ?< "(>" table)
  358. (modify-syntax-entry ?> ")<" table)
  359. table)))
  360. (c-lang-defvar c++-template-syntax-table
  361. (and (c-lang-const c++-make-template-syntax-table)
  362. (funcall (c-lang-const c++-make-template-syntax-table))))
  363. (c-lang-defconst c-make-no-parens-syntax-table
  364. ;; A variant of the standard syntax table which is used to find matching
  365. ;; "<"s and ">"s which have been marked as parens using syntax table
  366. ;; properties. The other paren characters (e.g. "{", ")" "]") are given a
  367. ;; non-paren syntax here. so that the list commands will work on "< ... >"
  368. ;; even when there's unbalanced other parens inside them.
  369. ;;
  370. ;; This variable is nil for languages which don't have template stuff.
  371. t (if (c-lang-const c-recognize-<>-arglists)
  372. `(lambda ()
  373. ;(if (c-lang-const c-recognize-<>-arglists)
  374. (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table))))
  375. (modify-syntax-entry ?\( "." table)
  376. (modify-syntax-entry ?\) "." table)
  377. (modify-syntax-entry ?\[ "." table)
  378. (modify-syntax-entry ?\] "." table)
  379. (modify-syntax-entry ?\{ "." table)
  380. (modify-syntax-entry ?\} "." table)
  381. table))))
  382. (c-lang-defvar c-no-parens-syntax-table
  383. (and (c-lang-const c-make-no-parens-syntax-table)
  384. (funcall (c-lang-const c-make-no-parens-syntax-table))))
  385. (c-lang-defconst c-identifier-syntax-modifications
  386. "A list that describes the modifications that should be done to the
  387. mode syntax table to get a syntax table that matches all identifiers
  388. and keywords as words.
  389. The list is just like the one used in `font-lock-defaults': Each
  390. element is a cons where the car is the character to modify and the cdr
  391. the new syntax, as accepted by `modify-syntax-entry'."
  392. ;; The $ character is not allowed in most languages (one exception
  393. ;; is Java which allows it for legacy reasons) but we still classify
  394. ;; it as an identifier character since it's often used in various
  395. ;; machine generated identifiers.
  396. t '((?_ . "w") (?$ . "w"))
  397. (objc java) (append '((?@ . "w"))
  398. (c-lang-const c-identifier-syntax-modifications))
  399. awk '((?_ . "w")))
  400. (c-lang-defvar c-identifier-syntax-modifications
  401. (c-lang-const c-identifier-syntax-modifications))
  402. (c-lang-defvar c-identifier-syntax-table
  403. (let ((table (copy-syntax-table (c-mode-var "mode-syntax-table")))
  404. (mods c-identifier-syntax-modifications)
  405. mod)
  406. (while mods
  407. (setq mod (car mods)
  408. mods (cdr mods))
  409. (modify-syntax-entry (car mod) (cdr mod) table))
  410. table)
  411. "Syntax table built on the mode syntax table but additionally
  412. classifies symbol constituents like `_' and `$' as word constituents,
  413. so that all identifiers are recognized as words.")
  414. (c-lang-defconst c-get-state-before-change-functions
  415. ;; For documentation see the following c-lang-defvar of the same name.
  416. ;; The value here may be a list of functions or a single function.
  417. t nil
  418. c++ '(c-extend-region-for-CPP
  419. c-before-change-check-<>-operators
  420. c-invalidate-macro-cache)
  421. (c objc) '(c-extend-region-for-CPP c-invalidate-macro-cache)
  422. ;; java 'c-before-change-check-<>-operators
  423. awk 'c-awk-record-region-clear-NL)
  424. (c-lang-defvar c-get-state-before-change-functions
  425. (let ((fs (c-lang-const c-get-state-before-change-functions)))
  426. (if (listp fs)
  427. fs
  428. (list fs)))
  429. "If non-nil, a list of functions called from c-before-change-hook.
  430. Typically these will record enough state to allow
  431. `c-before-font-lock-function' to extend the region to fontify,
  432. and may do such things as removing text-properties which must be
  433. recalculated.
  434. These functions will be run in the order given. Each of them
  435. takes 2 parameters, the BEG and END supplied to every
  436. before-change function; on entry, the buffer will have been
  437. widened and match-data will have been saved; point is undefined
  438. on both entry and exit; the return value is ignored.
  439. The functions are called even when font locking isn't enabled.
  440. When the mode is initialized, the functions are called with
  441. parameters \(point-min) and \(point-max).")
  442. (c-lang-defconst c-before-font-lock-functions
  443. ;; For documentation see the following c-lang-defvar of the same name.
  444. ;; The value here may be a list of functions or a single function.
  445. t 'c-change-expand-fl-region
  446. (c c++ objc) '(c-neutralize-syntax-in-and-mark-CPP
  447. c-change-expand-fl-region)
  448. awk 'c-awk-extend-and-syntax-tablify-region)
  449. (c-lang-defvar c-before-font-lock-functions
  450. (let ((fs (c-lang-const c-before-font-lock-functions)))
  451. (if (listp fs)
  452. fs
  453. (list fs)))
  454. "If non-nil, a list of functions called just before font locking.
  455. Typically they will extend the region about to be fontified \(see
  456. below) and will set `syntax-table' text properties on the region.
  457. These functions will be run in the order given. Each of them
  458. takes 3 parameters, the BEG, END, and OLD-LEN supplied to every
  459. after-change function; point is undefined on both entry and exit;
  460. on entry, the buffer will have been widened and match-data will
  461. have been saved; the return value is ignored.
  462. The functions may extend the region to be fontified by setting the
  463. buffer local variables c-new-BEG and c-new-END.
  464. The functions are called even when font locking is disabled.
  465. When the mode is initialized, these functions are called with
  466. parameters \(point-min), \(point-max) and <buffer size>.")
  467. (c-lang-defconst c-before-context-fontification-functions
  468. awk nil
  469. t 'c-context-expand-fl-region)
  470. ;; For documentation see the following c-lang-defvar of the same name.
  471. ;; The value here may be a list of functions or a single function.
  472. (c-lang-defvar c-before-context-fontification-functions
  473. (let ((fs (c-lang-const c-before-context-fontification-functions)))
  474. (if (listp fs)
  475. fs
  476. (list fs)))
  477. "If non-nil, a list of functions called just before context (or
  478. other non-change) fontification is done. Typically they will
  479. extend the region.
  480. These functions will be run in the order given. Each of them
  481. takes 2 parameters, the BEG and END of the region to be
  482. fontified. Point is undefined on both entry and exit. On entry,
  483. the buffer will have been widened and match-data will have been
  484. saved; the return value is a cons of the adjusted
  485. region, (NEW-BEG . NEW-END).")
  486. ;;; Syntactic analysis ("virtual semicolons") for line-oriented languages (AWK).
  487. (c-lang-defconst c-at-vsemi-p-fn
  488. "Contains a function \"Is there a virtual semicolon at POS or point?\".
  489. Such a function takes one optional parameter, a buffer position (defaults to
  490. point), and returns nil or t. This variable contains nil for languages which
  491. don't have EOL terminated statements. "
  492. t nil
  493. (c c++ objc) 'c-at-macro-vsemi-p
  494. awk 'c-awk-at-vsemi-p)
  495. (c-lang-defvar c-at-vsemi-p-fn (c-lang-const c-at-vsemi-p-fn))
  496. (c-lang-defconst c-vsemi-status-unknown-p-fn
  497. "Contains a function \"are we unsure whether there is a virtual semicolon on this line?\".
  498. The (admittedly kludgy) purpose of such a function is to prevent an infinite
  499. recursion in c-beginning-of-statement-1 when point starts at a `while' token.
  500. The function MUST NOT UNDER ANY CIRCUMSTANCES call c-beginning-of-statement-1,
  501. even indirectly. This variable contains nil for languages which don't have
  502. EOL terminated statements."
  503. t nil
  504. (c c++ objc) 'c-macro-vsemi-status-unknown-p
  505. awk 'c-awk-vsemi-status-unknown-p)
  506. (c-lang-defvar c-vsemi-status-unknown-p-fn
  507. (c-lang-const c-vsemi-status-unknown-p-fn))
  508. ;;; Lexer-level syntax (identifiers, tokens etc).
  509. (c-lang-defconst c-has-bitfields
  510. "Whether the language has bitfield declarations."
  511. t nil
  512. (c c++ objc) t)
  513. (c-lang-defvar c-has-bitfields (c-lang-const c-has-bitfields))
  514. (c-lang-defconst c-modified-constant
  515. "Regexp that matches a “modified” constant literal such as \"L\\='a\\='\",
  516. a “long character”. In particular, this recognizes forms of constant
  517. which `c-backward-sexp' needs to be called twice to move backwards over."
  518. t nil
  519. (c c++ objc) "L'\\([^\\'\t\f\n\r]\\|\\\\.\\)'")
  520. ;; FIXME!!! Extend this to cover strings, if needed. 2008-04-11
  521. (c-lang-defvar c-modified-constant (c-lang-const c-modified-constant))
  522. (c-lang-defconst c-symbol-start
  523. "Regexp that matches the start of a symbol, i.e. any identifier or
  524. keyword. It's unspecified how far it matches. Does not contain a \\|
  525. operator at the top level."
  526. t (concat "[" c-alpha "_]")
  527. java (concat "[" c-alpha "_@]")
  528. objc (concat "[" c-alpha "_@]")
  529. pike (concat "[" c-alpha "_`]"))
  530. (c-lang-defvar c-symbol-start (c-lang-const c-symbol-start))
  531. (c-lang-defconst c-symbol-chars
  532. "Set of characters that can be part of a symbol.
  533. This is of the form that fits inside [ ] in a regexp."
  534. ;; Pike note: With the backquote identifiers this would include most
  535. ;; operator chars too, but they are handled with other means instead.
  536. t (concat c-alnum "_$")
  537. objc (concat c-alnum "_$@"))
  538. (c-lang-defvar c-symbol-chars (c-lang-const c-symbol-chars))
  539. (c-lang-defconst c-symbol-key
  540. "Regexp matching identifiers and keywords (with submatch 0). Assumed
  541. to match if `c-symbol-start' matches on the same position."
  542. t (concat (c-lang-const c-symbol-start)
  543. "[" (c-lang-const c-symbol-chars) "]*")
  544. pike (concat
  545. ;; Use the value from C here since the operator backquote is
  546. ;; covered by the other alternative.
  547. (c-lang-const c-symbol-key c)
  548. "\\|"
  549. (c-make-keywords-re nil
  550. (c-lang-const c-overloadable-operators))))
  551. (c-lang-defvar c-symbol-key (c-lang-const c-symbol-key))
  552. (c-lang-defconst c-symbol-key-depth
  553. ;; Number of regexp grouping parens in `c-symbol-key'.
  554. t (regexp-opt-depth (c-lang-const c-symbol-key)))
  555. (c-lang-defconst c-nonsymbol-chars
  556. "This is the set of chars that can't be part of a symbol, i.e. the
  557. negation of `c-symbol-chars'."
  558. t (concat "^" (c-lang-const c-symbol-chars)))
  559. (c-lang-defvar c-nonsymbol-chars (c-lang-const c-nonsymbol-chars))
  560. (c-lang-defconst c-nonsymbol-key
  561. "Regexp that matches any character that can't be part of a symbol.
  562. It's usually appended to other regexps to avoid matching a prefix.
  563. It's assumed to not contain any submatchers."
  564. ;; The same thing regarding Unicode identifiers applies here as to
  565. ;; `c-symbol-key'.
  566. t (concat "[" (c-lang-const c-nonsymbol-chars) "]"))
  567. (c-lang-defconst c-identifier-ops
  568. "The operators that make up fully qualified identifiers. nil in
  569. languages that don't have such things. See `c-operators' for a
  570. description of the format. Binary operators can concatenate symbols,
  571. e.g. \"::\" in \"A::B::C\". Prefix operators can precede identifiers,
  572. e.g. \"~\" in \"~A::B\". Other types of operators aren't supported.
  573. This value is by default merged into `c-operators'."
  574. t nil
  575. c++ '((prefix "~" "??-" "compl")
  576. (right-assoc "::")
  577. (prefix "::"))
  578. ;; Java has "." to concatenate identifiers but it's also used for
  579. ;; normal indexing. There's special code in the Java font lock
  580. ;; rules to fontify qualified identifiers based on the standard
  581. ;; naming conventions. We still define "." here to make
  582. ;; `c-forward-name' move over as long names as possible which is
  583. ;; necessary to e.g. handle throws clauses correctly.
  584. java '((left-assoc "."))
  585. idl '((left-assoc "::")
  586. (prefix "::"))
  587. pike '((left-assoc "::")
  588. (prefix "::")
  589. (left-assoc ".")))
  590. (c-lang-defconst c-opt-identifier-concat-key
  591. ;; Appendable adorned regexp matching the operators that join
  592. ;; symbols to fully qualified identifiers, or nil in languages that
  593. ;; don't have such things.
  594. ;;
  595. ;; This was a docstring constant in 5.30. It still works but is now
  596. ;; considered internal - change `c-identifier-ops' instead.
  597. t (let ((ops (c-filter-ops (c-lang-const c-identifier-ops)
  598. '(left-assoc right-assoc)
  599. t)))
  600. (when ops
  601. (c-make-keywords-re 'appendable ops))))
  602. (c-lang-defvar c-opt-identifier-concat-key
  603. (c-lang-const c-opt-identifier-concat-key)
  604. 'dont-doc)
  605. (c-lang-defconst c-opt-identifier-concat-key-depth
  606. ;; Number of regexp grouping parens in `c-opt-identifier-concat-key'.
  607. t (regexp-opt-depth (c-lang-const c-opt-identifier-concat-key)))
  608. (c-lang-defconst c-opt-identifier-prefix-key
  609. ;; Appendable adorned regexp matching operators that might precede
  610. ;; an identifier and that are part of the identifier in that case.
  611. ;; nil in languages without such things.
  612. t (let ((ops (c-filter-ops (c-lang-const c-identifier-ops)
  613. '(prefix)
  614. t)))
  615. (when ops
  616. (c-make-keywords-re 'appendable ops))))
  617. (c-lang-defconst c-after-id-concat-ops
  618. "Operators that can occur after a binary operator on `c-identifier-ops'
  619. in identifiers. nil in languages that don't have such things.
  620. Operators here should also have appropriate entries in `c-operators' -
  621. it's not taken care of by default."
  622. t nil
  623. ;; '~' for destructors in C++, '*' for member pointers.
  624. c++ '("~" "*")
  625. ;; In Java we recognize '*' to deal with "foo.bar.*" that can occur
  626. ;; in import declarations. (This will also match bogus things like
  627. ;; "foo.*bar" but we don't bother.)
  628. java '("*"))
  629. (c-lang-defconst c-opt-after-id-concat-key
  630. ;; Regexp that must match the token after
  631. ;; `c-opt-identifier-concat-key' for it to be considered an
  632. ;; identifier concatenation operator (which e.g. causes the
  633. ;; preceding identifier to be fontified as a reference). Assumed to
  634. ;; be a string if `c-opt-identifier-concat-key' is.
  635. ;;
  636. ;; This was a docstring constant in 5.30. It still works but is now
  637. ;; considered internal - change `c-after-id-concat-ops' instead.
  638. t (concat (c-lang-const c-symbol-start)
  639. (if (c-lang-const c-after-id-concat-ops)
  640. (concat "\\|" (c-make-keywords-re 'appendable
  641. (c-lang-const c-after-id-concat-ops)))
  642. "")))
  643. (c-lang-defconst c-identifier-start
  644. "Regexp that matches the start of an (optionally qualified) identifier.
  645. It should also match all keywords. It's unspecified how far it
  646. matches."
  647. t (concat (c-lang-const c-symbol-start)
  648. (if (c-lang-const c-opt-identifier-prefix-key)
  649. (concat "\\|"
  650. (c-lang-const c-opt-identifier-prefix-key))
  651. "")))
  652. (c-lang-defvar c-identifier-start (c-lang-const c-identifier-start))
  653. (c-lang-defconst c-identifier-key
  654. "Regexp matching a fully qualified identifier, like \"A::B::c\" in
  655. C++. It does not recognize the full range of syntactic whitespace
  656. between the tokens; `c-forward-name' has to be used for that. It
  657. should also not match identifiers containing parenthesis groupings,
  658. e.g. identifiers with template arguments such as \"A<X,Y>\" in C++."
  659. ;; This regexp is more complex than strictly necessary to ensure
  660. ;; that it can be matched with a minimum of backtracking.
  661. t (concat (if (c-lang-const c-opt-identifier-prefix-key)
  662. (concat
  663. "\\("
  664. (c-lang-const c-opt-identifier-prefix-key)
  665. (c-lang-const c-simple-ws) "*"
  666. "\\)?")
  667. "")
  668. "\\(" (c-lang-const c-symbol-key) "\\)"
  669. (if (c-lang-const c-opt-identifier-concat-key)
  670. (concat
  671. "\\("
  672. (c-lang-const c-simple-ws) "*"
  673. (c-lang-const c-opt-identifier-concat-key)
  674. (c-lang-const c-simple-ws) "*"
  675. (if (c-lang-const c-after-id-concat-ops)
  676. (concat
  677. "\\("
  678. (c-make-keywords-re 'appendable
  679. (c-lang-const c-after-id-concat-ops))
  680. (concat
  681. ;; For flexibility, consider the symbol match
  682. ;; optional if we've hit a
  683. ;; `c-after-id-concat-ops' operator. This is
  684. ;; also necessary to handle the "*" that can
  685. ;; end import declaration identifiers in Java.
  686. "\\("
  687. (c-lang-const c-simple-ws) "*"
  688. "\\(" (c-lang-const c-symbol-key) "\\)"
  689. "\\)?")
  690. "\\|"
  691. "\\(" (c-lang-const c-symbol-key) "\\)"
  692. "\\)")
  693. (concat "\\(" (c-lang-const c-symbol-key) "\\)"))
  694. "\\)*")
  695. "")))
  696. (c-lang-defvar c-identifier-key (c-lang-const c-identifier-key))
  697. (c-lang-defconst c-identifier-last-sym-match
  698. ;; This was a docstring constant in 5.30 but it's no longer used.
  699. ;; It's only kept to avoid breaking third party code.
  700. ;;
  701. ;; Used to identify the submatch in `c-identifier-key' that
  702. ;; surrounds the last symbol in the qualified identifier. It's a
  703. ;; list of submatch numbers, of which the first that has a match is
  704. ;; taken. It's assumed that at least one does when the regexp has
  705. ;; matched.
  706. t nil)
  707. (c-lang-defconst c-string-escaped-newlines
  708. "Set if the language support backslash escaped newlines inside string
  709. literals."
  710. t nil
  711. (c c++ objc pike) t)
  712. (c-lang-defvar c-string-escaped-newlines
  713. (c-lang-const c-string-escaped-newlines))
  714. (c-lang-defconst c-multiline-string-start-char
  715. "Set if the language supports multiline string literals without escaped
  716. newlines. If t, all string literals are multiline. If a character,
  717. only literals where the open quote is immediately preceded by that
  718. literal are multiline."
  719. t nil
  720. pike ?#)
  721. (c-lang-defvar c-multiline-string-start-char
  722. (c-lang-const c-multiline-string-start-char))
  723. (c-lang-defconst c-opt-cpp-symbol
  724. "The symbol which starts preprocessor constructs when in the margin."
  725. t "#"
  726. (java awk) nil)
  727. (c-lang-defvar c-opt-cpp-symbol (c-lang-const c-opt-cpp-symbol))
  728. (c-lang-defconst c-opt-cpp-prefix
  729. "Regexp matching the prefix of a cpp directive in the languages that
  730. normally use that macro preprocessor. Tested at bol or at boi.
  731. Assumed to not contain any submatches or \\| operators."
  732. ;; TODO (ACM, 2005-04-01). Amend the following to recognize escaped NLs;
  733. ;; amend all uses of c-opt-cpp-prefix which count regexp-depth.
  734. t "\\s *#\\s *"
  735. (java awk) nil)
  736. (c-lang-defvar c-opt-cpp-prefix (c-lang-const c-opt-cpp-prefix))
  737. (c-lang-defconst c-anchored-cpp-prefix
  738. "Regexp matching the prefix of a cpp directive anchored to BOL,
  739. in the languages that have a macro preprocessor."
  740. t "^\\s *\\(#\\)\\s *"
  741. (java awk) nil)
  742. (c-lang-defvar c-anchored-cpp-prefix (c-lang-const c-anchored-cpp-prefix))
  743. (c-lang-defconst c-opt-cpp-start
  744. "Regexp matching the prefix of a cpp directive including the directive
  745. name, or nil in languages without preprocessor support. The first
  746. submatch surrounds the directive name."
  747. t (if (c-lang-const c-opt-cpp-prefix)
  748. (concat (c-lang-const c-opt-cpp-prefix)
  749. "\\([" c-alnum "]+\\)"))
  750. ;; Pike, being a scripting language, recognizes hash-bangs too.
  751. pike (concat (c-lang-const c-opt-cpp-prefix)
  752. "\\([" c-alnum "]+\\|!\\)"))
  753. (c-lang-defvar c-opt-cpp-start (c-lang-const c-opt-cpp-start))
  754. (c-lang-defconst c-cpp-message-directives
  755. "List of cpp directives (without the prefix) that are followed by a
  756. string message."
  757. t (if (c-lang-const c-opt-cpp-prefix)
  758. '("error"))
  759. (c c++ objc pike) '("error" "warning"))
  760. (c-lang-defconst c-cpp-include-directives
  761. "List of cpp directives (without the prefix) that are followed by a
  762. file name in angle brackets or quotes."
  763. t (if (c-lang-const c-opt-cpp-prefix)
  764. '("include"))
  765. objc '("include" "import"))
  766. (c-lang-defconst c-opt-cpp-macro-define
  767. "Cpp directive (without the prefix) that is followed by a macro
  768. definition, or nil if the language doesn't have any."
  769. t (if (c-lang-const c-opt-cpp-prefix)
  770. "define"))
  771. (c-lang-defvar c-opt-cpp-macro-define
  772. (c-lang-const c-opt-cpp-macro-define))
  773. (c-lang-defconst c-opt-cpp-macro-define-start
  774. ;; Regexp matching everything up to the macro body of a cpp define, or the
  775. ;; end of the logical line if there is none. Submatch 1 is the name of the
  776. ;; macro. Set if c-opt-cpp-macro-define is.
  777. t (if (c-lang-const c-opt-cpp-macro-define)
  778. (concat (c-lang-const c-opt-cpp-prefix)
  779. (c-lang-const c-opt-cpp-macro-define)
  780. "[ \t]+\\(\\(\\sw\\|_\\)+\\)\\(([^)]*)\\)?"
  781. ;; ^ ^ #defined name
  782. "\\([ \t]\\|\\\\\n\\)*")))
  783. (c-lang-defvar c-opt-cpp-macro-define-start
  784. (c-lang-const c-opt-cpp-macro-define-start))
  785. (c-lang-defconst c-opt-cpp-macro-define-id
  786. ;; Regexp matching everything up to the end of the identifier defined
  787. ;; by a cpp define.
  788. t (if (c-lang-const c-opt-cpp-macro-define)
  789. (concat (c-lang-const c-opt-cpp-prefix) ; #
  790. (c-lang-const c-opt-cpp-macro-define) ; define
  791. "[ \t]+\\(\\sw\\|_\\)+")))
  792. (c-lang-defvar c-opt-cpp-macro-define-id
  793. (c-lang-const c-opt-cpp-macro-define-id))
  794. (c-lang-defconst c-cpp-expr-directives
  795. "List of cpp directives (without the prefix) that are followed by an
  796. expression."
  797. t (if (c-lang-const c-opt-cpp-prefix)
  798. '("if" "elif")))
  799. (c-lang-defconst c-cpp-expr-intro-re
  800. "Regexp which matches the start of a CPP directive which contains an
  801. expression, or nil if there aren't any in the language."
  802. t (if (c-lang-const c-cpp-expr-directives)
  803. (concat
  804. (c-lang-const c-opt-cpp-prefix)
  805. (c-make-keywords-re t (c-lang-const c-cpp-expr-directives)))))
  806. (c-lang-defvar c-cpp-expr-intro-re
  807. (c-lang-const c-cpp-expr-intro-re))
  808. (c-lang-defconst c-cpp-expr-functions
  809. "List of functions in cpp expressions."
  810. t (if (c-lang-const c-opt-cpp-prefix)
  811. '("defined"))
  812. pike '("defined" "efun" "constant"))
  813. (c-lang-defconst c-assignment-operators
  814. "List of all assignment operators."
  815. t '("=" "*=" "/=" "%=" "+=" "-=" ">>=" "<<=" "&=" "^=" "|=")
  816. java (append (c-lang-const c-assignment-operators)
  817. '(">>>="))
  818. c++ (append (c-lang-const c-assignment-operators)
  819. '("and_eq" "or_eq" "xor_eq" "??!=" "??'="))
  820. idl nil)
  821. (c-lang-defconst c-operators
  822. "List describing all operators, along with their precedence and
  823. associativity. The order in the list corresponds to the precedence of
  824. the operators: The operators in each element are a group with the same
  825. precedence, and the group has higher precedence than the groups in all
  826. following elements. The car of each element describes the type of the
  827. operator group, and the cdr is a list of the operator tokens in it.
  828. The operator group types are:
  829. `prefix' Unary prefix operators.
  830. `postfix' Unary postfix operators.
  831. `postfix-if-paren'
  832. Unary postfix operators if and only if the chars have
  833. parenthesis syntax.
  834. `left-assoc' Binary left associative operators (i.e. a+b+c means (a+b)+c).
  835. `right-assoc' Binary right associative operators (i.e. a=b=c means a=(b=c)).
  836. `right-assoc-sequence'
  837. Right associative operator that constitutes of a
  838. sequence of tokens that separate expressions. All the
  839. tokens in the group are in this case taken as
  840. describing the sequence in one such operator, and the
  841. order between them is therefore significant.
  842. Operators containing a character with paren syntax are taken to match
  843. with a corresponding open/close paren somewhere else. A postfix
  844. operator with close paren syntax is taken to end a postfix expression
  845. started somewhere earlier, rather than start a new one at point. Vice
  846. versa for prefix operators with open paren syntax.
  847. Note that operators like \".\" and \"->\" which in language references
  848. often are described as postfix operators are considered binary here,
  849. since CC Mode treats every identifier as an expression."
  850. ;; There's currently no code in CC Mode that exploits all the info
  851. ;; in this variable; precedence, associativity etc are present as a
  852. ;; preparation for future work.
  853. ;; FIXME!!! C++11's "auto" operators "=" and "->" need to go in here
  854. ;; somewhere. 2012-03-24.
  855. t `(;; Preprocessor.
  856. ,@(when (c-lang-const c-opt-cpp-prefix)
  857. `((prefix "#"
  858. ,@(when (c-major-mode-is '(c-mode c++-mode))
  859. '("%:" "??=")))
  860. (left-assoc "##"
  861. ,@(when (c-major-mode-is '(c-mode c++-mode))
  862. '("%:%:" "??=??=")))))
  863. ;; Primary.
  864. ,@(c-lang-const c-identifier-ops)
  865. ,@(cond ((or (c-major-mode-is 'c++-mode) (c-major-mode-is 'java-mode))
  866. `((postfix-if-paren "<" ">"))) ; Templates.
  867. ((c-major-mode-is 'pike-mode)
  868. `((prefix "global" "predef")))
  869. ((c-major-mode-is 'java-mode)
  870. `((prefix "super"))))
  871. ;; Postfix.
  872. ,@(when (c-major-mode-is 'c++-mode)
  873. ;; The following need special treatment.
  874. `((prefix "dynamic_cast" "static_cast"
  875. "reinterpret_cast" "const_cast" "typeid"
  876. "alignof")))
  877. (left-assoc "."
  878. ,@(unless (c-major-mode-is 'java-mode)
  879. '("->")))
  880. (postfix "++" "--" "[" "]" "(" ")"
  881. ,@(when (c-major-mode-is '(c-mode c++-mode))
  882. '("<:" ":>" "??(" "??)")))
  883. ;; Unary.
  884. (prefix "++" "--" "+" "-" "!" "~"
  885. ,@(when (c-major-mode-is 'c++-mode) '("not" "compl"))
  886. ,@(when (c-major-mode-is '(c-mode c++-mode))
  887. '("*" "&" "sizeof" "??-"))
  888. ,@(when (c-major-mode-is 'objc-mode)
  889. '("@selector" "@protocol" "@encode"))
  890. ;; The following need special treatment.
  891. ,@(cond ((c-major-mode-is 'c++-mode)
  892. '("new" "delete"))
  893. ((c-major-mode-is 'java-mode)
  894. '("new"))
  895. ((c-major-mode-is 'pike-mode)
  896. '("class" "lambda" "catch" "throw" "gauge")))
  897. "(" ")" ; Cast.
  898. ,@(when (c-major-mode-is 'pike-mode)
  899. '("[" "]"))) ; Type cast.
  900. ;; Member selection.
  901. ,@(when (c-major-mode-is 'c++-mode)
  902. `((left-assoc ".*" "->*")))
  903. ;; Multiplicative.
  904. (left-assoc "*" "/" "%")
  905. ;; Additive.
  906. (left-assoc "+" "-")
  907. ;; Shift.
  908. (left-assoc "<<" ">>"
  909. ,@(when (c-major-mode-is 'java-mode)
  910. '(">>>")))
  911. ;; Relational.
  912. (left-assoc "<" ">" "<=" ">="
  913. ,@(when (c-major-mode-is 'java-mode)
  914. '("instanceof")))
  915. ;; Equality.
  916. (left-assoc "==" "!="
  917. ,@(when (c-major-mode-is 'c++-mode) '("not_eq")))
  918. ;; Bitwise and.
  919. (left-assoc "&"
  920. ,@(when (c-major-mode-is 'c++-mode) '("bitand")))
  921. ;; Bitwise exclusive or.
  922. (left-assoc "^"
  923. ,@(when (c-major-mode-is '(c-mode c++-mode))
  924. '("??'"))
  925. ,@(when (c-major-mode-is 'c++-mode) '("xor")))
  926. ;; Bitwise or.
  927. (left-assoc "|"
  928. ,@(when (c-major-mode-is '(c-mode c++-mode))
  929. '("??!"))
  930. ,@(when (c-major-mode-is 'c++-mode) '("bitor")))
  931. ;; Logical and.
  932. (left-assoc "&&"
  933. ,@(when (c-major-mode-is 'c++-mode) '("and")))
  934. ;; Logical or.
  935. (left-assoc "||"
  936. ,@(when (c-major-mode-is '(c-mode c++-mode))
  937. '("??!??!"))
  938. ,@(when (c-major-mode-is 'c++-mode) '("or")))
  939. ;; Conditional.
  940. (right-assoc-sequence "?" ":")
  941. ;; Assignment.
  942. (right-assoc ,@(c-lang-const c-assignment-operators))
  943. ;; Exception.
  944. ,@(when (c-major-mode-is 'c++-mode)
  945. '((prefix "throw")))
  946. ;; Sequence.
  947. (left-assoc ","))
  948. ;; IDL got its own definition since it has a much smaller operator
  949. ;; set than the other languages.
  950. idl `(;; Preprocessor.
  951. (prefix "#")
  952. (left-assoc "##")
  953. ;; Primary.
  954. ,@(c-lang-const c-identifier-ops)
  955. ;; Unary.
  956. (prefix "+" "-" "~")
  957. ;; Multiplicative.
  958. (left-assoc "*" "/" "%")
  959. ;; Additive.
  960. (left-assoc "+" "-")
  961. ;; Shift.
  962. (left-assoc "<<" ">>")
  963. ;; And.
  964. (left-assoc "&")
  965. ;; Xor.
  966. (left-assoc "^")
  967. ;; Or.
  968. (left-assoc "|")))
  969. (c-lang-defconst c-operator-list
  970. ;; The operators as a flat list (without duplicates).
  971. t (c-filter-ops (c-lang-const c-operators) t t))
  972. (c-lang-defconst c-overloadable-operators
  973. "List of the operators that are overloadable, in their \"identifier
  974. form\". See also `c-op-identifier-prefix'."
  975. t nil
  976. c++ '("new" "delete" ;; Can be followed by "[]" but we ignore that.
  977. "+" "-" "*" "/" "%"
  978. "^" "??'" "xor" "&" "bitand" "|" "??!" "bitor" "~" "??-" "compl"
  979. "!" "=" "<" ">" "+=" "-=" "*=" "/=" "%=" "^="
  980. "??'=" "xor_eq" "&=" "and_eq" "|=" "??!=" "or_eq"
  981. "<<" ">>" ">>=" "<<=" "==" "!=" "not_eq" "<=" ">="
  982. "&&" "and" "||" "??!??!" "or" "++" "--" "," "->*" "->"
  983. "()" "[]" "<::>" "??(??)")
  984. ;; These work like identifiers in Pike.
  985. pike '("`+" "`-" "`&" "`|" "`^" "`<<" "`>>" "`*" "`/" "`%" "`~"
  986. "`==" "`<" "`>" "`!" "`[]" "`[]=" "`->" "`->=" "`()" "``+"
  987. "``-" "``&" "``|" "``^" "``<<" "``>>" "``*" "``/" "``%"
  988. "`+="))
  989. (c-lang-defconst c-overloadable-operators-regexp
  990. ;; Regexp tested after an "operator" token in C++.
  991. t nil
  992. c++ (c-make-keywords-re nil (c-lang-const c-overloadable-operators)))
  993. (c-lang-defvar c-overloadable-operators-regexp
  994. (c-lang-const c-overloadable-operators-regexp))
  995. (c-lang-defconst c-opt-op-identifier-prefix
  996. "Regexp matching the token before the ones in
  997. `c-overloadable-operators' when operators are specified in their
  998. \"identifier form\". This typically matches \"operator\" in C++ where
  999. operator functions are specified as e.g. \"operator +\". It's nil in
  1000. languages without operator functions or where the complete operator
  1001. identifier is listed in `c-overloadable-operators'.
  1002. This regexp is assumed to not match any non-operator identifier."
  1003. t nil
  1004. c++ (c-make-keywords-re t '("operator")))
  1005. (c-lang-defvar c-opt-op-identifier-prefix
  1006. (c-lang-const c-opt-op-identifier-prefix))
  1007. ;; Note: the following alias is an old name which was a mis-spelling. It has
  1008. ;; been corrected above and throughout cc-engine.el. It will be removed at
  1009. ;; some release very shortly in the future. ACM, 2006-04-14.
  1010. (defvaralias 'c-opt-op-identitier-prefix 'c-opt-op-identifier-prefix)
  1011. (make-obsolete-variable 'c-opt-op-identitier-prefix 'c-opt-op-identifier-prefix
  1012. "CC Mode 5.31.4, 2006-04-14")
  1013. (c-lang-defconst c-other-op-syntax-tokens
  1014. "List of the tokens made up of characters in the punctuation or
  1015. parenthesis syntax classes that have uses other than as expression
  1016. operators."
  1017. t '("{" "}" "(" ")" "[" "]" ";" ":" "," "=" "/*" "*/" "//")
  1018. (c c++ pike) (append '("#" "##" ; Used by cpp.
  1019. "::" "...")
  1020. (c-lang-const c-other-op-syntax-tokens))
  1021. (c c++) (append '("*") (c-lang-const c-other-op-syntax-tokens))
  1022. c++ (append '("&" "<%" "%>" "<:" ":>" "%:" "%:%:")
  1023. (c-lang-const c-other-op-syntax-tokens))
  1024. objc (append '("#" "##" ; Used by cpp.
  1025. "+" "-")
  1026. (c-lang-const c-other-op-syntax-tokens))
  1027. idl (append '("#" "##") ; Used by cpp.
  1028. (c-lang-const c-other-op-syntax-tokens))
  1029. pike (append '("..")
  1030. (c-lang-const c-other-op-syntax-tokens)
  1031. (c-lang-const c-overloadable-operators))
  1032. awk '("{" "}" "(" ")" "[" "]" ";" "," "=" "/"))
  1033. (c-lang-defconst c-all-op-syntax-tokens
  1034. ;; List of all tokens in the punctuation and parenthesis syntax
  1035. ;; classes.
  1036. t (c--delete-duplicates (append (c-lang-const c-other-op-syntax-tokens)
  1037. (c-lang-const c-operator-list))
  1038. :test 'string-equal))
  1039. (c-lang-defconst c-nonsymbol-token-char-list
  1040. ;; List containing all chars not in the word, symbol or
  1041. ;; syntactically irrelevant syntax classes, i.e. all punctuation,
  1042. ;; parenthesis and string delimiter chars.
  1043. t (c-with-syntax-table (c-lang-const c-mode-syntax-table)
  1044. ;; Only go through the chars in the printable ASCII range. No
  1045. ;; language so far has 8-bit or widestring operators.
  1046. (let (list (char 32))
  1047. (while (< char 127)
  1048. (or (memq (char-syntax char) '(?w ?_ ?< ?> ?\ ))
  1049. (setq list (cons (c-int-to-char char) list)))
  1050. (setq char (1+ char)))
  1051. list)))
  1052. (c-lang-defconst c-nonsymbol-token-regexp
  1053. ;; Regexp matching all tokens in the punctuation and parenthesis
  1054. ;; syntax classes. Note that this also matches ".", which can start
  1055. ;; a float.
  1056. t (c-make-keywords-re nil
  1057. (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
  1058. t
  1059. "\\`\\(\\s.\\)+\\'")))
  1060. (c-lang-defvar c-nonsymbol-token-regexp
  1061. (c-lang-const c-nonsymbol-token-regexp))
  1062. (c-lang-defconst c-assignment-op-regexp
  1063. ;; Regexp matching all assignment operators and only them. The
  1064. ;; beginning of the first submatch is used to detect the end of the
  1065. ;; token, along with the end of the whole match.
  1066. t (if (c-lang-const c-assignment-operators)
  1067. (concat
  1068. ;; Need special case for "=" since it's a prefix of "==".
  1069. "=\\([^=]\\|$\\)"
  1070. "\\|"
  1071. (c-make-keywords-re nil
  1072. (c--set-difference (c-lang-const c-assignment-operators)
  1073. '("=")
  1074. :test 'string-equal)))
  1075. "\\<\\>"))
  1076. (c-lang-defvar c-assignment-op-regexp
  1077. (c-lang-const c-assignment-op-regexp))
  1078. (c-lang-defconst c-<>-multichar-token-regexp
  1079. ;; Regexp matching all tokens containing "<" or ">" which are longer
  1080. ;; than one char.
  1081. t (c-make-keywords-re nil
  1082. (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
  1083. t
  1084. ".[<>]\\|[<>].")))
  1085. (c-lang-defvar c-<>-multichar-token-regexp
  1086. (c-lang-const c-<>-multichar-token-regexp))
  1087. (c-lang-defconst c-<-op-cont-regexp
  1088. ;; Regexp matching the second and subsequent characters of all
  1089. ;; multicharacter tokens that begin with "<".
  1090. t (c-make-keywords-re nil
  1091. (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
  1092. t
  1093. "\\`<."
  1094. (lambda (op) (substring op 1)))))
  1095. (c-lang-defvar c-<-op-cont-regexp (c-lang-const c-<-op-cont-regexp))
  1096. (c-lang-defconst c->-op-cont-tokens
  1097. ;; A list of second and subsequent characters of all multicharacter tokens
  1098. ;; that begin with ">".
  1099. t (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
  1100. t
  1101. "\\`>."
  1102. (lambda (op) (substring op 1)))
  1103. java (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
  1104. t
  1105. "\\`>[^>]\\|\\`>>[^>]"
  1106. (lambda (op) (substring op 1))))
  1107. (c-lang-defconst c->-op-cont-regexp
  1108. ;; Regexp matching the second and subsequent characters of all
  1109. ;; multicharacter tokens that begin with ">".
  1110. t (c-make-keywords-re nil (c-lang-const c->-op-cont-tokens)))
  1111. (c-lang-defvar c->-op-cont-regexp (c-lang-const c->-op-cont-regexp))
  1112. (c-lang-defconst c->-op-without->-cont-regexp
  1113. ;; Regexp matching the second and subsequent characters of all
  1114. ;; multicharacter tokens that begin with ">" except for those beginning with
  1115. ;; ">>".
  1116. t (c-make-keywords-re nil
  1117. (c--set-difference
  1118. (c-lang-const c->-op-cont-tokens)
  1119. (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
  1120. t
  1121. "\\`>>"
  1122. (lambda (op) (substring op 1)))
  1123. :test 'string-equal)))
  1124. (c-lang-defvar c->-op-without->-cont-regexp
  1125. (c-lang-const c->-op-without->-cont-regexp))
  1126. (c-lang-defconst c-stmt-delim-chars
  1127. ;; The characters that should be considered to bound statements. To
  1128. ;; optimize `c-crosses-statement-barrier-p' somewhat, it's assumed to
  1129. ;; begin with "^" to negate the set. If ? : operators should be
  1130. ;; detected then the string must end with "?:".
  1131. t "^;{}?:")
  1132. (c-lang-defvar c-stmt-delim-chars (c-lang-const c-stmt-delim-chars))
  1133. (c-lang-defconst c-stmt-delim-chars-with-comma
  1134. ;; Variant of `c-stmt-delim-chars' that additionally contains ','.
  1135. t "^;,{}?:")
  1136. (c-lang-defvar c-stmt-delim-chars-with-comma
  1137. (c-lang-const c-stmt-delim-chars-with-comma))
  1138. (c-lang-defconst c-auto-ops
  1139. ;; Ops which signal C++11's new auto uses.
  1140. t nil
  1141. c++ '("=" "->"))
  1142. (c-lang-defconst c-auto-ops-re
  1143. t (c-make-keywords-re nil (c-lang-const c-auto-ops)))
  1144. (c-lang-defvar c-auto-ops-re (c-lang-const c-auto-ops-re))
  1145. (c-lang-defconst c-haskell-op
  1146. ;; Op used in the new C++11 auto function definition, indicating type.
  1147. t nil
  1148. c++ '("->"))
  1149. (c-lang-defconst c-haskell-op-re
  1150. t (c-make-keywords-re nil (c-lang-const c-haskell-op)))
  1151. (c-lang-defvar c-haskell-op-re (c-lang-const c-haskell-op-re))
  1152. ;;; Syntactic whitespace.
  1153. (c-lang-defconst c-simple-ws
  1154. "Regexp matching an ordinary whitespace character.
  1155. Does not contain a \\| operator at the top level."
  1156. ;; "\\s " is not enough since it doesn't match line breaks.
  1157. t "\\(\\s \\|[\n\r]\\)")
  1158. (c-lang-defconst c-simple-ws-depth
  1159. ;; Number of regexp grouping parens in `c-simple-ws'.
  1160. t (regexp-opt-depth (c-lang-const c-simple-ws)))
  1161. (c-lang-defconst c-line-comment-starter
  1162. "String that starts line comments, or nil if such don't exist.
  1163. Line comments are always terminated by newlines. At least one of
  1164. `c-block-comment-starter' and this one is assumed to be set.
  1165. Note that it's currently not enough to set this to support a new
  1166. comment style. Other stuff like the syntax table must also be set up
  1167. properly."
  1168. t "//"
  1169. awk "#")
  1170. (c-lang-defvar c-line-comment-starter (c-lang-const c-line-comment-starter))
  1171. (c-lang-defconst c-block-comment-starter
  1172. "String that starts block comments, or nil if such don't exist.
  1173. Block comments are ended by `c-block-comment-ender', which is assumed
  1174. to be set if this is. At least one of `c-line-comment-starter' and
  1175. this one is assumed to be set.
  1176. Note that it's currently not enough to set this to support a new
  1177. comment style. Other stuff like the syntax table must also be set up
  1178. properly."
  1179. t "/*"
  1180. awk nil)
  1181. (c-lang-defconst c-block-comment-ender
  1182. "String that ends block comments, or nil if such don't exist.
  1183. Note that it's currently not enough to set this to support a new
  1184. comment style. Other stuff like the syntax table must also be set up
  1185. properly."
  1186. t "*/"
  1187. awk nil)
  1188. (c-lang-defconst c-comment-start-regexp
  1189. ;; Regexp to match the start of any type of comment.
  1190. t (let ((re (c-make-keywords-re nil
  1191. (list (c-lang-const c-line-comment-starter)
  1192. (c-lang-const c-block-comment-starter)))))
  1193. (if (memq 'gen-comment-delim c-emacs-features)
  1194. (concat re "\\|\\s!")
  1195. re)))
  1196. (c-lang-defvar c-comment-start-regexp (c-lang-const c-comment-start-regexp))
  1197. (c-lang-defconst c-block-comment-start-regexp
  1198. ;; Regexp which matches the start of a block comment (if such exists in the
  1199. ;; language)
  1200. t (if (c-lang-const c-block-comment-starter)
  1201. (regexp-quote (c-lang-const c-block-comment-starter))
  1202. "\\<\\>"))
  1203. (c-lang-defvar c-block-comment-start-regexp
  1204. (c-lang-const c-block-comment-start-regexp))
  1205. (c-lang-defconst c-line-comment-start-regexp
  1206. ;; Regexp which matches the start of a line comment (if such exists in the
  1207. ;; language; it does in all 7 CC Mode languages).
  1208. t (if (c-lang-const c-line-comment-starter)
  1209. (regexp-quote (c-lang-const c-line-comment-starter))
  1210. "\\<\\>"))
  1211. (c-lang-defvar c-line-comment-start-regexp
  1212. (c-lang-const c-line-comment-start-regexp))
  1213. (c-lang-defconst c-literal-start-regexp
  1214. ;; Regexp to match the start of comments and string literals.
  1215. t (concat (c-lang-const c-comment-start-regexp)
  1216. "\\|"
  1217. (if (memq 'gen-string-delim c-emacs-features)
  1218. "\"|"
  1219. "\"")))
  1220. (c-lang-defvar c-literal-start-regexp (c-lang-const c-literal-start-regexp))
  1221. (c-lang-defconst c-doc-comment-start-regexp
  1222. "Regexp to match the start of documentation comments."
  1223. t "\\<\\>"
  1224. ;; From font-lock.el: `doxygen' uses /*! while others use /**.
  1225. (c c++ objc) "/\\*[*!]"
  1226. java "/\\*\\*"
  1227. pike "/[/*]!")
  1228. (c-lang-defvar c-doc-comment-start-regexp
  1229. (c-lang-const c-doc-comment-start-regexp))
  1230. (c-lang-defconst comment-start
  1231. "String that starts comments inserted with M-; etc.
  1232. `comment-start' is initialized from this."
  1233. ;; Default: Prefer line comments to block comments, and pad with a space.
  1234. t (concat (or (c-lang-const c-line-comment-starter)
  1235. (c-lang-const c-block-comment-starter))
  1236. " ")
  1237. ;; In C we still default to the block comment style since line
  1238. ;; comments aren't entirely portable.
  1239. c "/* ")
  1240. (c-lang-setvar comment-start (c-lang-const comment-start))
  1241. (c-lang-defconst comment-end
  1242. "String that ends comments inserted with M-; etc.
  1243. `comment-end' is initialized from this."
  1244. ;; Default: Use block comment style if comment-start uses block
  1245. ;; comments, and pad with a space in that case.
  1246. t (if (string-match (concat "\\`\\("
  1247. (c-lang-const c-block-comment-start-regexp)
  1248. "\\)")
  1249. (c-lang-const comment-start))
  1250. (concat " " (c-lang-const c-block-comment-ender))
  1251. ""))
  1252. (c-lang-setvar comment-end (c-lang-const comment-end))
  1253. (c-lang-defconst comment-start-skip
  1254. "Regexp to match the start of a comment plus everything up to its body.
  1255. `comment-start-skip' is initialized from this."
  1256. ;; Default: Allow the last char of the comment starter(s) to be
  1257. ;; repeated, then allow any amount of horizontal whitespace.
  1258. t (concat "\\("
  1259. (c-concat-separated
  1260. (mapcar (lambda (cs)
  1261. (when cs
  1262. (concat (regexp-quote cs) "+")))
  1263. (list (c-lang-const c-line-comment-starter)
  1264. (c-lang-const c-block-comment-starter)))
  1265. "\\|")
  1266. "\\)\\s *"))
  1267. (c-lang-setvar comment-start-skip (c-lang-const comment-start-skip))
  1268. (c-lang-defconst c-syntactic-ws-start
  1269. ;; Regexp matching any sequence that can start syntactic whitespace.
  1270. ;; The only uncertain case is '#' when there are cpp directives.
  1271. t (concat "\\s \\|"
  1272. (c-make-keywords-re nil
  1273. (append (list (c-lang-const c-line-comment-starter)
  1274. (c-lang-const c-block-comment-starter)
  1275. (when (c-lang-const c-opt-cpp-prefix)
  1276. "#"))
  1277. '("\n" "\r")))
  1278. "\\|\\\\[\n\r]"
  1279. (when (memq 'gen-comment-delim c-emacs-features)
  1280. "\\|\\s!")))
  1281. (c-lang-defvar c-syntactic-ws-start (c-lang-const c-syntactic-ws-start))
  1282. (c-lang-defconst c-syntactic-ws-end
  1283. ;; Regexp matching any single character that might end syntactic whitespace.
  1284. t (concat "\\s \\|"
  1285. (c-make-keywords-re nil
  1286. (append (when (c-lang-const c-block-comment-ender)
  1287. (list
  1288. (string
  1289. (elt (c-lang-const c-block-comment-ender)
  1290. (1- (length
  1291. (c-lang-const c-block-comment-ender)))))))
  1292. '("\n" "\r")))
  1293. (when (memq 'gen-comment-delim c-emacs-features)
  1294. "\\|\\s!")))
  1295. (c-lang-defvar c-syntactic-ws-end (c-lang-const c-syntactic-ws-end))
  1296. (c-lang-defconst c-unterminated-block-comment-regexp
  1297. ;; Regexp matching an unterminated block comment that doesn't
  1298. ;; contain line breaks, or nil in languages without block comments.
  1299. ;; Does not contain a \| operator at the top level.
  1300. t (when (c-lang-const c-block-comment-starter)
  1301. (concat
  1302. (regexp-quote (c-lang-const c-block-comment-starter))
  1303. ;; It's messy to cook together a regexp that matches anything
  1304. ;; but c-block-comment-ender.
  1305. (let ((end (c-lang-const c-block-comment-ender)))
  1306. (cond ((= (length end) 1)
  1307. (concat "[^" end "\n\r]*"))
  1308. ((= (length end) 2)
  1309. (concat "[^" (substring end 0 1) "\n\r]*"
  1310. "\\("
  1311. (regexp-quote (substring end 0 1)) "+"
  1312. "[^"
  1313. ;; The quoting rules inside char classes are silly. :P
  1314. (cond ((= (elt end 0) (elt end 1))
  1315. (concat (substring end 0 1) "\n\r"))
  1316. ((= (elt end 1) ?\])
  1317. (concat (substring end 1 2) "\n\r"
  1318. (substring end 0 1)))
  1319. (t
  1320. (concat (substring end 0 1) "\n\r"
  1321. (substring end 1 2))))
  1322. "]"
  1323. "[^" (substring end 0 1) "\n\r]*"
  1324. "\\)*"))
  1325. (t
  1326. (error "Can't handle a block comment ender of length %s"
  1327. (length end))))))))
  1328. (c-lang-defconst c-block-comment-regexp
  1329. ;; Regexp matching a block comment that doesn't contain line breaks,
  1330. ;; or nil in languages without block comments. The reason we don't
  1331. ;; allow line breaks is to avoid going very far and risk running out
  1332. ;; of regexp stack; this regexp is intended to handle only short
  1333. ;; comments that might be put in the middle of limited constructs
  1334. ;; like declarations. Does not contain a \| operator at the top
  1335. ;; level.
  1336. t (when (c-lang-const c-unterminated-block-comment-regexp)
  1337. (concat
  1338. (c-lang-const c-unterminated-block-comment-regexp)
  1339. (let ((end (c-lang-const c-block-comment-ender)))
  1340. (cond ((= (length end) 1)
  1341. (regexp-quote end))
  1342. ((= (length end) 2)
  1343. (concat (regexp-quote (substring end 0 1)) "+"
  1344. (regexp-quote (substring end 1 2))))
  1345. (t
  1346. (error "Can't handle a block comment ender of length %s"
  1347. (length end))))))))
  1348. (c-lang-defconst c-nonwhite-syntactic-ws
  1349. ;; Regexp matching a piece of syntactic whitespace that isn't a
  1350. ;; sequence of simple whitespace characters. As opposed to
  1351. ;; `c-(forward|backward)-syntactic-ws', this doesn't regard cpp
  1352. ;; directives as syntactic whitespace.
  1353. t (c-concat-separated
  1354. (list (when (c-lang-const c-line-comment-starter)
  1355. (concat (regexp-quote (c-lang-const c-line-comment-starter))
  1356. "[^\n\r]*[\n\r]"))
  1357. (c-lang-const c-block-comment-regexp)
  1358. "\\\\[\n\r]"
  1359. (when (memq 'gen-comment-delim c-emacs-features)
  1360. "\\s!\\S!*\\s!"))
  1361. "\\|"))
  1362. (c-lang-defconst c-syntactic-ws
  1363. ;; Regexp matching syntactic whitespace, including possibly the
  1364. ;; empty string. As opposed to `c-(forward|backward)-syntactic-ws',
  1365. ;; this doesn't regard cpp directives as syntactic whitespace. Does
  1366. ;; not contain a \| operator at the top level.
  1367. t (concat (c-lang-const c-simple-ws) "*"
  1368. "\\("
  1369. (concat "\\(" (c-lang-const c-nonwhite-syntactic-ws) "\\)"
  1370. (c-lang-const c-simple-ws) "*")
  1371. "\\)*"))
  1372. (c-lang-defconst c-syntactic-ws-depth
  1373. ;; Number of regexp grouping parens in `c-syntactic-ws'.
  1374. t (regexp-opt-depth (c-lang-const c-syntactic-ws)))
  1375. (c-lang-defconst c-nonempty-syntactic-ws
  1376. ;; Regexp matching syntactic whitespace, which is at least one
  1377. ;; character long. As opposed to `c-(forward|backward)-syntactic-ws',
  1378. ;; this doesn't regard cpp directives as syntactic whitespace. Does
  1379. ;; not contain a \| operator at the top level.
  1380. t (concat "\\("
  1381. (c-lang-const c-simple-ws)
  1382. "\\|"
  1383. (c-lang-const c-nonwhite-syntactic-ws)
  1384. "\\)+"))
  1385. (c-lang-defconst c-nonempty-syntactic-ws-depth
  1386. ;; Number of regexp grouping parens in `c-nonempty-syntactic-ws'.
  1387. t (regexp-opt-depth (c-lang-const c-nonempty-syntactic-ws)))
  1388. (c-lang-defconst c-single-line-syntactic-ws
  1389. ;; Regexp matching syntactic whitespace without any line breaks. As
  1390. ;; opposed to `c-(forward|backward)-syntactic-ws', this doesn't
  1391. ;; regard cpp directives as syntactic whitespace. Does not contain
  1392. ;; a \| operator at the top level.
  1393. t (if (c-lang-const c-block-comment-regexp)
  1394. (concat "\\s *\\("
  1395. (c-lang-const c-block-comment-regexp)
  1396. "\\s *\\)*")
  1397. "\\s *"))
  1398. (c-lang-defconst c-single-line-syntactic-ws-depth
  1399. ;; Number of regexp grouping parens in `c-single-line-syntactic-ws'.
  1400. t (regexp-opt-depth (c-lang-const c-single-line-syntactic-ws)))
  1401. (c-lang-defconst c-syntactic-eol
  1402. ;; Regexp that matches when there is no syntactically significant
  1403. ;; text before eol. Macros are regarded as syntactically
  1404. ;; significant text here.
  1405. t (concat (c-lang-const c-single-line-syntactic-ws)
  1406. ;; Match eol (possibly inside a block comment or preceded
  1407. ;; by a line continuation backslash), or the beginning of a
  1408. ;; line comment. Note: This has to be modified for awk
  1409. ;; where line comments start with '#'.
  1410. "\\("
  1411. (c-concat-separated
  1412. (list (when (c-lang-const c-line-comment-starter)
  1413. (regexp-quote (c-lang-const c-line-comment-starter)))
  1414. (when (c-lang-const c-unterminated-block-comment-regexp)
  1415. (concat (c-lang-const c-unterminated-block-comment-regexp)
  1416. "$"))
  1417. "\\\\$"
  1418. "$")
  1419. "\\|")
  1420. "\\)"))
  1421. (c-lang-defvar c-syntactic-eol (c-lang-const c-syntactic-eol))
  1422. ;;; Defun handling.
  1423. ;; The Emacs variables beginning-of-defun-function and end-of-defun-function
  1424. ;; will be set so that commands like `mark-defun' and `narrow-to-defun' work
  1425. ;; right. In older Emacsen, the key sequences C-M-a and C-M-e are, however,
  1426. ;; bound directly to the CC Mode functions, allowing optimization for large n.
  1427. ;; From Emacs 23, this isn't necessary any more, since n is passed to the two
  1428. ;; functions.
  1429. (c-lang-defconst beginning-of-defun-function
  1430. "Function to which beginning-of-defun-function will be set."
  1431. t 'c-beginning-of-defun
  1432. awk 'c-awk-beginning-of-defun)
  1433. (c-lang-setvar beginning-of-defun-function
  1434. (c-lang-const beginning-of-defun-function))
  1435. (c-lang-defconst end-of-defun-function
  1436. "Function to which end-of-defun-function will be set."
  1437. t 'c-end-of-defun
  1438. awk 'c-awk-end-of-defun)
  1439. (c-lang-setvar end-of-defun-function (c-lang-const end-of-defun-function))
  1440. ;;; In-comment text handling.
  1441. (c-lang-defconst c-paragraph-start
  1442. "Regexp to append to `paragraph-start'."
  1443. t "$"
  1444. java "\\(@[a-zA-Z]+\\>\\|$\\)" ; For Javadoc.
  1445. pike "\\(@[a-zA-Z_-]+\\>\\([^{]\\|$\\)\\|$\\)") ; For Pike refdoc.
  1446. (c-lang-defvar c-paragraph-start (c-lang-const c-paragraph-start))
  1447. (c-lang-defconst c-paragraph-separate
  1448. "Regexp to append to `paragraph-separate'."
  1449. t "$"
  1450. pike (c-lang-const c-paragraph-start))
  1451. (c-lang-defvar c-paragraph-separate (c-lang-const c-paragraph-separate))
  1452. ;;; Keyword lists.
  1453. ;; Note: All and only all language constants containing keyword lists
  1454. ;; should end with "-kwds"; they're automatically collected into the
  1455. ;; `c-kwds-lang-consts' list below and used to build `c-keywords' etc.
  1456. (c-lang-defconst c-primitive-type-kwds
  1457. "Primitive type keywords. As opposed to the other keyword lists, the
  1458. keywords listed here are fontified with the type face instead of the
  1459. keyword face.
  1460. If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
  1461. `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
  1462. `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
  1463. will be handled.
  1464. Do not try to modify this list for end user customizations; the
  1465. `*-font-lock-extra-types' variable, where `*' is the mode prefix, is
  1466. the appropriate place for that."
  1467. t '("char" "double" "float" "int" "long" "short" "signed"
  1468. "unsigned" "void")
  1469. c (append
  1470. '("_Bool" "_Complex" "_Imaginary") ; Conditionally defined in C99.
  1471. (c-lang-const c-primitive-type-kwds))
  1472. c++ (append
  1473. '("bool" "wchar_t" "char16_t" "char32_t")
  1474. (c-lang-const c-primitive-type-kwds))
  1475. ;; Objective-C extends C, but probably not the new stuff in C99.
  1476. objc (append
  1477. '("id" "Class" "SEL" "IMP" "BOOL")
  1478. (c-lang-const c-primitive-type-kwds))
  1479. java '("boolean" "byte" "char" "double" "float" "int" "long" "short" "void")
  1480. idl '("Object" "ValueBase" "any" "boolean" "char" "double" "fixed" "float"
  1481. "long" "octet" "sequence" "short" "string" "void" "wchar" "wstring"
  1482. ;; In CORBA PSDL:
  1483. "ref"
  1484. ;; The following can't really end a type, but we have to specify them
  1485. ;; here due to the assumption in `c-primitive-type-prefix-kwds'. It
  1486. ;; doesn't matter that much.
  1487. "unsigned" "strong")
  1488. pike '(;; this_program isn't really a keyword, but it's practically
  1489. ;; used as a builtin type.
  1490. "array" "float" "function" "int" "mapping" "mixed" "multiset"
  1491. "object" "program" "string" "this_program" "void"))
  1492. (c-lang-defconst c-primitive-type-key
  1493. ;; An adorned regexp that matches `c-primitive-type-kwds'.
  1494. t (c-make-keywords-re t (c-lang-const c-primitive-type-kwds)))
  1495. (c-lang-defvar c-primitive-type-key (c-lang-const c-primitive-type-key))
  1496. (c-lang-defconst c-primitive-type-prefix-kwds
  1497. "Keywords that might act as prefixes for primitive types. Assumed to
  1498. be a subset of `c-primitive-type-kwds'."
  1499. t nil
  1500. (c c++) '("long" "short" "signed" "unsigned")
  1501. idl '("long" "unsigned"
  1502. ;; In CORBA PSDL:
  1503. "strong"))
  1504. (c-lang-defconst c-typedef-kwds
  1505. "Prefix keyword(s) like \"typedef\" which make a type declaration out
  1506. of a variable declaration."
  1507. t '("typedef")
  1508. (awk idl java) nil)
  1509. (c-lang-defconst c-typedef-key
  1510. ;; Adorned regexp matching `c-typedef-kwds'.
  1511. t (c-make-keywords-re t (c-lang-const c-typedef-kwds)))
  1512. (c-lang-defvar c-typedef-key (c-lang-const c-typedef-key))
  1513. (c-lang-defconst c-typeof-kwds
  1514. "Keywords followed by a parenthesized expression, which stands for
  1515. the type of that expression."
  1516. t nil
  1517. c '("typeof") ; longstanding GNU C(++) extension.
  1518. c++ '("decltype" "typeof"))
  1519. (c-lang-defconst c-typeof-key
  1520. ;; Adorned regexp matching `c-typeof-kwds'.
  1521. t (c-make-keywords-re t (c-lang-const c-typeof-kwds)))
  1522. (c-lang-defvar c-typeof-key (c-lang-const c-typeof-key))
  1523. (c-lang-defconst c-type-prefix-kwds
  1524. "Keywords where the following name - if any - is a type name, and
  1525. where the keyword together with the symbol works as a type in
  1526. declarations.
  1527. Note that an alternative if the second part doesn't hold is
  1528. `c-type-list-kwds'. Keywords on this list are typically also present
  1529. on one of the `*-decl-kwds' lists."
  1530. t nil
  1531. c '("struct" "union" "enum")
  1532. c++ (append '("class" "typename")
  1533. (c-lang-const c-type-prefix-kwds c)))
  1534. (c-lang-defconst c-type-prefix-key
  1535. ;; Adorned regexp matching `c-type-prefix-kwds'.
  1536. t (c-make-keywords-re t (c-lang-const c-type-prefix-kwds)))
  1537. (c-lang-defvar c-type-prefix-key (c-lang-const c-type-prefix-key))
  1538. (c-lang-defconst c-type-modifier-kwds
  1539. "Type modifier keywords. These can occur almost anywhere in types
  1540. but they don't build a type of themselves. Unlike the keywords on
  1541. `c-primitive-type-kwds', they are fontified with the keyword face and
  1542. not the type face."
  1543. t nil
  1544. c '("const" "restrict" "volatile")
  1545. c++ '("const" "constexpr" "noexcept" "volatile" "throw" "final" "override")
  1546. objc '("const" "volatile"))
  1547. (c-lang-defconst c-opt-type-modifier-key
  1548. ;; Adorned regexp matching `c-type-modifier-kwds', or nil in
  1549. ;; languages without such keywords.
  1550. t (and (c-lang-const c-type-modifier-kwds)
  1551. (c-make-keywords-re t (c-lang-const c-type-modifier-kwds))))
  1552. (c-lang-defvar c-opt-type-modifier-key (c-lang-const c-opt-type-modifier-key))
  1553. (c-lang-defconst c-opt-type-component-key
  1554. ;; An adorned regexp that matches `c-primitive-type-prefix-kwds' and
  1555. ;; `c-type-modifier-kwds', or nil in languages without any of them.
  1556. t (and (or (c-lang-const c-primitive-type-prefix-kwds)
  1557. (c-lang-const c-type-modifier-kwds))
  1558. (c-make-keywords-re t
  1559. (append (c-lang-const c-primitive-type-prefix-kwds)
  1560. (c-lang-const c-type-modifier-kwds)))))
  1561. (c-lang-defvar c-opt-type-component-key
  1562. (c-lang-const c-opt-type-component-key))
  1563. (c-lang-defconst c-type-start-kwds
  1564. ;; All keywords that can start a type (i.e. are either a type prefix
  1565. ;; or a complete type).
  1566. t (c--delete-duplicates (append (c-lang-const c-primitive-type-kwds)
  1567. (c-lang-const c-type-prefix-kwds)
  1568. (c-lang-const c-type-modifier-kwds))
  1569. :test 'string-equal))
  1570. (c-lang-defconst c-class-decl-kwds
  1571. "Keywords introducing declarations where the following block (if any)
  1572. contains another declaration level that should be considered a class.
  1573. If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
  1574. `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
  1575. `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
  1576. will be handled.
  1577. Note that presence on this list does not automatically treat the
  1578. following identifier as a type; the keyword must also be present on
  1579. `c-type-prefix-kwds' or `c-type-list-kwds' to accomplish that."
  1580. t nil
  1581. c '("struct" "union")
  1582. c++ '("class" "struct" "union")
  1583. objc '("struct" "union"
  1584. "@interface" "@implementation" "@protocol")
  1585. java '("class" "@interface" "interface")
  1586. idl '("component" "eventtype" "exception" "home" "interface" "struct"
  1587. "union" "valuetype"
  1588. ;; In CORBA PSDL:
  1589. "storagehome" "storagetype"
  1590. ;; In CORBA CIDL:
  1591. "catalog" "executor" "manages" "segment")
  1592. pike '("class"))
  1593. (c-lang-defconst c-class-key
  1594. ;; Regexp matching the start of a class.
  1595. t (c-make-keywords-re t (c-lang-const c-class-decl-kwds)))
  1596. (c-lang-defvar c-class-key (c-lang-const c-class-key))
  1597. (c-lang-defconst c-brace-list-decl-kwds
  1598. "Keywords introducing declarations where the following block (if
  1599. any) is a brace list.
  1600. If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
  1601. `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
  1602. `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
  1603. will be handled."
  1604. t '("enum")
  1605. (awk) nil)
  1606. (c-lang-defconst c-brace-list-key
  1607. ;; Regexp matching the start of declarations where the following
  1608. ;; block is a brace list.
  1609. t (c-make-keywords-re t (c-lang-const c-brace-list-decl-kwds)))
  1610. (c-lang-defvar c-brace-list-key (c-lang-const c-brace-list-key))
  1611. (c-lang-defconst c-after-brace-list-decl-kwds
  1612. "Keywords that might follow keywords in `c-brace-list-decl-kwds'
  1613. and precede the opening brace."
  1614. t nil
  1615. c++ '("class" "struct"))
  1616. (c-lang-defconst c-after-brace-list-key
  1617. ;; Regexp matching keywords that can fall between a brace-list
  1618. ;; keyword and the associated brace list.
  1619. t (c-make-keywords-re t (c-lang-const c-after-brace-list-decl-kwds)))
  1620. (c-lang-defvar c-after-brace-list-key (c-lang-const c-after-brace-list-key))
  1621. (c-lang-defconst c-recognize-post-brace-list-type-p
  1622. "Set to t when we recognize a colon and then a type after an enum,
  1623. e.g., enum foo : int { A, B, C };"
  1624. t nil
  1625. c++ t)
  1626. (c-lang-defvar c-recognize-post-brace-list-type-p
  1627. (c-lang-const c-recognize-post-brace-list-type-p))
  1628. (c-lang-defconst c-other-block-decl-kwds
  1629. "Keywords where the following block (if any) contains another
  1630. declaration level that should not be considered a class. For every
  1631. keyword here, CC Mode will add a set of special syntactic symbols for
  1632. those blocks. E.g. if the keyword is \"foo\" then there will be
  1633. `foo-open', `foo-close', and `infoo' symbols.
  1634. The intention is that this category should be used for block
  1635. constructs that aren't related to object orientation concepts like
  1636. classes (which thus also include e.g. interfaces, templates,
  1637. contracts, structs, etc). The more pragmatic distinction is that
  1638. while most want some indentation inside classes, it's fairly common
  1639. that they don't want it in some of these constructs, so it should be
  1640. simple to configure that differently from classes. See also
  1641. `c-class-decl-kwds'.
  1642. If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
  1643. `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
  1644. `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
  1645. will be handled."
  1646. t nil
  1647. (c objc) '("extern")
  1648. c++ '("namespace" "extern")
  1649. idl '("module"
  1650. ;; In CORBA CIDL:
  1651. "composition"))
  1652. (c-lang-defconst c-other-decl-block-key
  1653. ;; Regexp matching the start of blocks besides classes that contain
  1654. ;; another declaration level.
  1655. t (c-make-keywords-re t (c-lang-const c-other-block-decl-kwds)))
  1656. (c-lang-defvar c-other-decl-block-key (c-lang-const c-other-decl-block-key))
  1657. (c-lang-defvar c-other-decl-block-key-in-symbols-alist
  1658. (mapcar
  1659. (lambda (elt)
  1660. (cons elt
  1661. (if (string= elt "extern")
  1662. 'inextern-lang
  1663. (intern (concat "in" elt)))))
  1664. (c-lang-const c-other-block-decl-kwds))
  1665. "Alist associating keywords in c-other-decl-block-decl-kwds with
  1666. their matching \"in\" syntactic symbols.")
  1667. (c-lang-defconst c-typedef-decl-kwds
  1668. "Keywords introducing declarations where the identifier(s) being
  1669. declared are types.
  1670. If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
  1671. `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
  1672. `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
  1673. will be handled."
  1674. ;; Default to `c-class-decl-kwds' and `c-brace-list-decl-kwds'
  1675. ;; (since e.g. "Foo" is a type that's being defined in "class Foo
  1676. ;; {...}").
  1677. t (append (c-lang-const c-class-decl-kwds)
  1678. (c-lang-const c-brace-list-decl-kwds))
  1679. ;; Languages that have a "typedef" construct.
  1680. (c c++ objc idl pike) (append (c-lang-const c-typedef-decl-kwds)
  1681. '("typedef"))
  1682. ;; Unlike most other languages, exception names are not handled as
  1683. ;; types in IDL since they only can occur in "raises" specs.
  1684. idl (delete "exception" (append (c-lang-const c-typedef-decl-kwds) nil)))
  1685. (c-lang-defconst c-typedef-decl-key
  1686. t (c-make-keywords-re t (c-lang-const c-typedef-decl-kwds)))
  1687. (c-lang-defvar c-typedef-decl-key (c-lang-const c-typedef-decl-key))
  1688. (c-lang-defconst c-typeless-decl-kwds
  1689. "Keywords introducing declarations where the \(first) identifier
  1690. \(declarator) follows directly after the keyword, without any type.
  1691. If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
  1692. `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
  1693. `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
  1694. will be handled."
  1695. ;; Default to `c-class-decl-kwds' and `c-brace-list-decl-kwds'
  1696. ;; (since e.g. "Foo" is the identifier being defined in "class Foo
  1697. ;; {...}").
  1698. t (append (c-lang-const c-class-decl-kwds)
  1699. (c-lang-const c-brace-list-decl-kwds))
  1700. c++ (append (c-lang-const c-typeless-decl-kwds) '("auto")) ; C++11.
  1701. ;; Note: "manages" for CORBA CIDL clashes with its presence on
  1702. ;; `c-type-list-kwds' for IDL.
  1703. idl (append (c-lang-const c-typeless-decl-kwds)
  1704. '("factory" "finder" "native"
  1705. ;; In CORBA PSDL:
  1706. "key" "stores"
  1707. ;; In CORBA CIDL:
  1708. "facet"))
  1709. pike (append (c-lang-const c-class-decl-kwds)
  1710. '("constant")))
  1711. (c-lang-defconst c-modifier-kwds
  1712. "Keywords that can prefix normal declarations of identifiers
  1713. \(and typically act as flags). Things like argument declarations
  1714. inside function headers are also considered declarations in this
  1715. sense.
  1716. If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
  1717. `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
  1718. `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
  1719. will be handled."
  1720. t nil
  1721. (c c++) '("auto" "extern" "inline" "register" "static")
  1722. c++ (append '("explicit" "friend" "mutable" "template" "thread_local"
  1723. "using" "virtual")
  1724. (c-lang-const c-modifier-kwds))
  1725. objc '("auto" "bycopy" "byref" "extern" "in" "inout" "oneway" "out" "static")
  1726. ;; FIXME: Some of those below ought to be on `c-other-decl-kwds' instead.
  1727. idl '("abstract" "attribute" "const" "consumes" "custom" "emits" "import"
  1728. "in" "inout" "local" "multiple" "oneway" "out" "private" "provides"
  1729. "public" "publishes" "readonly" "typeid" "typeprefix" "uses"
  1730. ;; In CORBA PSDL:
  1731. "primary" "state"
  1732. ;; In CORBA CIDL:
  1733. "bindsTo" "delegatesTo" "implements" "proxy" "storedOn")
  1734. ;; Note: "const" is not used in Java, but it's still a reserved keyword.
  1735. java '("abstract" "const" "final" "native" "private" "protected" "public"
  1736. "static" "strictfp" "synchronized" "transient" "volatile")
  1737. pike '("final" "inline" "local" "nomask" "optional" "private" "protected"
  1738. "public" "static" "variant"))
  1739. (c-lang-defconst c-other-decl-kwds
  1740. "Keywords that can start or prefix any declaration level construct,
  1741. besides those on `c-class-decl-kwds', `c-brace-list-decl-kwds',
  1742. `c-other-block-decl-kwds', `c-typedef-decl-kwds',
  1743. `c-typeless-decl-kwds' and `c-modifier-kwds'.
  1744. If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
  1745. `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
  1746. `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
  1747. will be handled."
  1748. t nil
  1749. objc '("@class" "@end" "@defs")
  1750. java '("import" "package")
  1751. pike '("import" "inherit"))
  1752. (c-lang-defconst c-decl-start-kwds
  1753. "Keywords that always start declarations, wherever they occur.
  1754. This can be used for declarations that aren't recognized by the normal
  1755. combination of `c-decl-prefix-re' and `c-decl-start-re'."
  1756. t nil
  1757. ;; Classes can be declared anywhere in a Pike expression.
  1758. pike '("class"))
  1759. (c-lang-defconst c-decl-hangon-kwds
  1760. "Keywords that can occur anywhere in a declaration level construct.
  1761. This is used for self-contained things that can be tacked on anywhere
  1762. on a declaration and that should be ignored to be able to recognize it
  1763. correctly. Typical cases are compiler extensions like
  1764. \"__attribute__\" or \"__declspec\":
  1765. __declspec(noreturn) void foo();
  1766. class __declspec(dllexport) classname {...};
  1767. void foo() __attribute__((noreturn));
  1768. Note that unrecognized plain symbols are skipped anyway if they occur
  1769. before the type, so such things are not necessary to mention here.
  1770. Mentioning them here is necessary only if they can occur in other
  1771. places, or if they are followed by a construct that must be skipped
  1772. over \(like the parens in the \"__attribute__\" and \"__declspec\"
  1773. examples above). In the last case, they alse need to be present on
  1774. one of `c-type-list-kwds', `c-ref-list-kwds',
  1775. `c-colon-type-list-kwds', `c-paren-nontype-kwds', `c-paren-type-kwds',
  1776. `c-<>-type-kwds', or `c-<>-arglist-kwds'."
  1777. ;; NB: These are currently not recognized in all parts of a
  1778. ;; declaration. Specifically, they aren't recognized in the middle
  1779. ;; of multi-token types, inside declarators, and between the
  1780. ;; identifier and the arglist paren of a function declaration.
  1781. ;;
  1782. ;; FIXME: This ought to be user customizable since compiler stuff
  1783. ;; like this usually is wrapped in project specific macros. (It'd
  1784. ;; of course be even better if we could cope without knowing this.)
  1785. t nil
  1786. (c c++) '(;; GCC extension.
  1787. "__attribute__"
  1788. ;; MSVC extension.
  1789. "__declspec"))
  1790. (c-lang-defconst c-decl-hangon-key
  1791. ;; Adorned regexp matching `c-decl-hangon-kwds'.
  1792. t (c-make-keywords-re t (c-lang-const c-decl-hangon-kwds)))
  1793. (c-lang-defvar c-decl-hangon-key (c-lang-const c-decl-hangon-key))
  1794. (c-lang-defconst c-prefix-spec-kwds
  1795. ;; All keywords that can occur in the preamble of a declaration.
  1796. ;; They typically occur before the type, but they are also matched
  1797. ;; after presumptive types since we often can't be sure that
  1798. ;; something is a type or just some sort of macro in front of the
  1799. ;; declaration. They might be ambiguous with types or type
  1800. ;; prefixes.
  1801. t (c--delete-duplicates (append (c-lang-const c-class-decl-kwds)
  1802. (c-lang-const c-brace-list-decl-kwds)
  1803. (c-lang-const c-other-block-decl-kwds)
  1804. (c-lang-const c-typedef-decl-kwds)
  1805. (c-lang-const c-typeless-decl-kwds)
  1806. (c-lang-const c-modifier-kwds)
  1807. (c-lang-const c-other-decl-kwds)
  1808. (c-lang-const c-decl-start-kwds)
  1809. (c-lang-const c-decl-hangon-kwds))
  1810. :test 'string-equal))
  1811. (c-lang-defconst c-prefix-spec-kwds-re
  1812. ;; Adorned regexp of `c-prefix-spec-kwds'.
  1813. t (c-make-keywords-re t (c-lang-const c-prefix-spec-kwds)))
  1814. (c-lang-defvar c-prefix-spec-kwds-re (c-lang-const c-prefix-spec-kwds-re))
  1815. (c-lang-defconst c-specifier-key
  1816. ;; Adorned regexp of the keywords in `c-prefix-spec-kwds' that aren't
  1817. ;; ambiguous with types or type prefixes. These are the keywords (like
  1818. ;; extern, namespace, but NOT template) that can modify a declaration.
  1819. t (c-make-keywords-re t
  1820. (c--set-difference (c-lang-const c-prefix-spec-kwds)
  1821. (append (c-lang-const c-type-start-kwds)
  1822. (c-lang-const c-<>-arglist-kwds))
  1823. :test 'string-equal)))
  1824. (c-lang-defvar c-specifier-key (c-lang-const c-specifier-key))
  1825. (c-lang-defconst c-postfix-spec-kwds
  1826. ;; Keywords that can occur after argument list of a function header
  1827. ;; declaration, i.e. in the "K&R region".
  1828. t (append (c-lang-const c-postfix-decl-spec-kwds)
  1829. (c-lang-const c-decl-hangon-kwds)))
  1830. (c-lang-defconst c-not-decl-init-keywords
  1831. ;; Adorned regexp matching all keywords that can't appear at the
  1832. ;; start of a declaration.
  1833. t (c-make-keywords-re t
  1834. (c--set-difference (c-lang-const c-keywords)
  1835. (append (c-lang-const c-type-start-kwds)
  1836. (c-lang-const c-prefix-spec-kwds)
  1837. (c-lang-const c-typeof-kwds))
  1838. :test 'string-equal)))
  1839. (c-lang-defvar c-not-decl-init-keywords
  1840. (c-lang-const c-not-decl-init-keywords))
  1841. (c-lang-defconst c-not-primitive-type-keywords
  1842. "List of all keywords apart from primitive types (like \"int\")."
  1843. t (c--set-difference (c-lang-const c-keywords)
  1844. (c-lang-const c-primitive-type-kwds)
  1845. :test 'string-equal)
  1846. ;; The "more" for C++ is the QT keyword (as in "more slots:").
  1847. ;; This variable is intended for use in c-beginning-of-statement-1.
  1848. c++ (append (c-lang-const c-not-primitive-type-keywords) '("more")))
  1849. (c-lang-defconst c-not-primitive-type-keywords-regexp
  1850. t (c-make-keywords-re t
  1851. (c-lang-const c-not-primitive-type-keywords)))
  1852. (c-lang-defvar c-not-primitive-type-keywords-regexp
  1853. (c-lang-const c-not-primitive-type-keywords-regexp))
  1854. (c-lang-defconst c-protection-kwds
  1855. "Access protection label keywords in classes."
  1856. t nil
  1857. c++ '("private" "protected" "public")
  1858. objc '("@private" "@protected" "@public"))
  1859. (c-lang-defconst c-block-decls-with-vars
  1860. "Keywords introducing declarations that can contain a block which
  1861. might be followed by variable declarations, e.g. like \"foo\" in
  1862. \"class Foo { ... } foo;\". So if there is a block in a declaration
  1863. like that, it ends with the following `;' and not right away.
  1864. The keywords on list are assumed to also be present on one of the
  1865. `*-decl-kwds' lists."
  1866. t nil
  1867. (c objc) '("struct" "union" "enum" "typedef")
  1868. c++ '("class" "struct" "union" "enum" "typedef"))
  1869. (c-lang-defconst c-opt-block-decls-with-vars-key
  1870. ;; Regexp matching the `c-block-decls-with-vars' keywords, or nil in
  1871. ;; languages without such constructs.
  1872. t (and (c-lang-const c-block-decls-with-vars)
  1873. (c-make-keywords-re t (c-lang-const c-block-decls-with-vars))))
  1874. (c-lang-defvar c-opt-block-decls-with-vars-key
  1875. (c-lang-const c-opt-block-decls-with-vars-key))
  1876. (c-lang-defconst c-postfix-decl-spec-kwds
  1877. "Keywords introducing extra declaration specifiers in the region
  1878. between the header and the body \(i.e. the \"K&R-region\") in
  1879. declarations."
  1880. t nil
  1881. java '("extends" "implements" "throws")
  1882. idl '("context" "getraises" "manages" "primarykey" "raises" "setraises"
  1883. "supports"
  1884. ;; In CORBA PSDL:
  1885. "as" "const" "implements" "of" "ref"))
  1886. (c-lang-defconst c-postfix-decl-spec-key
  1887. ;; Regexp matching the keywords in `c-postfix-decl-spec-kwds'.
  1888. t (c-make-keywords-re t (c-lang-const c-postfix-decl-spec-kwds)))
  1889. (c-lang-defvar c-postfix-decl-spec-key
  1890. (c-lang-const c-postfix-decl-spec-key))
  1891. (c-lang-defconst c-nonsymbol-sexp-kwds
  1892. "Keywords that may be followed by a nonsymbol sexp before whatever
  1893. construct it's part of continues."
  1894. t nil
  1895. (c c++ objc) '("extern"))
  1896. (c-lang-defconst c-type-list-kwds
  1897. "Keywords that may be followed by a comma separated list of type
  1898. identifiers, where each optionally can be prefixed by keywords. (Can
  1899. also be used for the special case when the list can contain only one
  1900. element.)
  1901. Assumed to be mutually exclusive with `c-ref-list-kwds'. There's no
  1902. reason to put keywords on this list if they are on `c-type-prefix-kwds'.
  1903. There's also no reason to add keywords that prefixes a normal
  1904. declaration consisting of a type followed by a declarator (list), so
  1905. the keywords on `c-modifier-kwds' should normally not be listed here
  1906. either.
  1907. Note: Use `c-typeless-decl-kwds' for keywords followed by a function
  1908. or variable identifier (that's being defined)."
  1909. t nil
  1910. c++ '("operator")
  1911. objc '("@class")
  1912. java '("import" "new" "extends" "super" "implements" "throws")
  1913. idl '("manages" "native" "primarykey" "supports"
  1914. ;; In CORBA PSDL:
  1915. "as" "implements" "of" "scope")
  1916. pike '("inherit"))
  1917. (c-lang-defconst c-ref-list-kwds
  1918. "Keywords that may be followed by a comma separated list of
  1919. reference (i.e. namespace/scope/module) identifiers, where each
  1920. optionally can be prefixed by keywords. (Can also be used for the
  1921. special case when the list can contain only one element.) Assumed to
  1922. be mutually exclusive with `c-type-list-kwds'.
  1923. Note: Use `c-typeless-decl-kwds' for keywords followed by a function
  1924. or variable identifier (that's being defined)."
  1925. t nil
  1926. c++ '("namespace")
  1927. java '("package")
  1928. idl '("import" "module"
  1929. ;; In CORBA CIDL:
  1930. "composition")
  1931. pike '("import"))
  1932. (c-lang-defconst c-colon-type-list-kwds
  1933. "Keywords that may be followed (not necessarily directly) by a colon
  1934. and then a comma separated list of type identifiers, where each
  1935. optionally can be prefixed by keywords. (Can also be used for the
  1936. special case when the list can contain only one element.)"
  1937. t nil
  1938. c++ '("class" "struct")
  1939. idl '("component" "eventtype" "home" "interface" "valuetype"
  1940. ;; In CORBA PSDL:
  1941. "storagehome" "storagetype"))
  1942. (c-lang-defconst c-colon-type-list-re
  1943. "Regexp matched after the keywords in `c-colon-type-list-kwds' to skip
  1944. forward to the colon. The end of the match is assumed to be directly
  1945. after the colon, so the regexp should end with \":\". Must be a
  1946. regexp if `c-colon-type-list-kwds' isn't nil."
  1947. t (if (c-lang-const c-colon-type-list-kwds)
  1948. ;; Disallow various common punctuation chars that can't come
  1949. ;; before the ":" that starts the inherit list after "class"
  1950. ;; or "struct" in C++. (Also used as default for other
  1951. ;; languages.)
  1952. "[^][{}();,/#=:]*:"))
  1953. (c-lang-defvar c-colon-type-list-re (c-lang-const c-colon-type-list-re))
  1954. (c-lang-defconst c-paren-nontype-kwds
  1955. "Keywords that may be followed by a parenthesis expression that doesn't
  1956. contain type identifiers."
  1957. t nil
  1958. (c c++) '(;; GCC extension.
  1959. "__attribute__"
  1960. ;; MSVC extension.
  1961. "__declspec"))
  1962. (c-lang-defconst c-paren-type-kwds
  1963. "Keywords that may be followed by a parenthesis expression containing
  1964. type identifiers separated by arbitrary tokens."
  1965. t nil
  1966. c++ '("throw")
  1967. objc '("@defs")
  1968. idl '("switch")
  1969. pike '("array" "function" "int" "mapping" "multiset" "object" "program"))
  1970. (c-lang-defconst c-paren-any-kwds
  1971. t (c--delete-duplicates (append (c-lang-const c-paren-nontype-kwds)
  1972. (c-lang-const c-paren-type-kwds))
  1973. :test 'string-equal))
  1974. (c-lang-defconst c-<>-type-kwds
  1975. "Keywords that may be followed by an angle bracket expression
  1976. containing type identifiers separated by \",\". The difference from
  1977. `c-<>-arglist-kwds' is that unknown names are taken to be types and
  1978. not other identifiers. `c-recognize-<>-arglists' is assumed to be set
  1979. if this isn't nil."
  1980. t nil
  1981. objc '("id")
  1982. idl '("sequence"
  1983. ;; In CORBA PSDL:
  1984. "ref"))
  1985. (c-lang-defconst c-<>-arglist-kwds
  1986. "Keywords that can be followed by a C++ style template arglist; see
  1987. `c-recognize-<>-arglists' for details. That language constant is
  1988. assumed to be set if this isn't nil."
  1989. t nil
  1990. c++ '("template")
  1991. idl '("fixed" "string" "wstring"))
  1992. (c-lang-defconst c-<>-sexp-kwds
  1993. ;; All keywords that can be followed by an angle bracket sexp.
  1994. t (c--delete-duplicates (append (c-lang-const c-<>-type-kwds)
  1995. (c-lang-const c-<>-arglist-kwds))
  1996. :test 'string-equal))
  1997. (c-lang-defconst c-opt-<>-sexp-key
  1998. ;; Adorned regexp matching keywords that can be followed by an angle
  1999. ;; bracket sexp. Always set when `c-recognize-<>-arglists' is.
  2000. t (c-make-keywords-re t (c-lang-const c-<>-sexp-kwds)))
  2001. (c-lang-defvar c-opt-<>-sexp-key (c-lang-const c-opt-<>-sexp-key))
  2002. (c-lang-defconst c-brace-id-list-kwds
  2003. "Keywords that may be followed by a brace block containing a comma
  2004. separated list of identifier definitions, i.e. like the list of
  2005. identifiers that follows the type in a normal declaration."
  2006. t (c-lang-const c-brace-list-decl-kwds))
  2007. (c-lang-defconst c-block-stmt-1-kwds
  2008. "Statement keywords followed directly by a substatement."
  2009. t '("do" "else")
  2010. c++ '("do" "else" "try")
  2011. objc '("do" "else" "@finally" "@try")
  2012. java '("do" "else" "finally" "try")
  2013. idl nil)
  2014. (c-lang-defconst c-block-stmt-1-key
  2015. ;; Regexp matching the start of any statement followed directly by a
  2016. ;; substatement (doesn't match a bare block, however).
  2017. t (c-make-keywords-re t (c-lang-const c-block-stmt-1-kwds)))
  2018. (c-lang-defvar c-block-stmt-1-key (c-lang-const c-block-stmt-1-key))
  2019. (c-lang-defconst c-block-stmt-1-2-kwds
  2020. "Statement keywords optionally followed by a paren sexp.
  2021. Keywords here should also be in `c-block-stmt-1-kwds'."
  2022. t nil
  2023. java '("try"))
  2024. (c-lang-defconst c-block-stmt-1-2-key
  2025. ;; Regexp matching the start of a statement which may be followed by a
  2026. ;; paren sexp and will then be followed by a substatement.
  2027. t (c-make-keywords-re t (c-lang-const c-block-stmt-1-2-kwds)))
  2028. (c-lang-defvar c-block-stmt-1-2-key (c-lang-const c-block-stmt-1-2-key))
  2029. (c-lang-defconst c-block-stmt-2-kwds
  2030. "Statement keywords followed by a paren sexp and then by a substatement."
  2031. t '("for" "if" "switch" "while")
  2032. c++ '("for" "if" "switch" "while" "catch")
  2033. objc '("for" "if" "switch" "while" "@catch" "@synchronized")
  2034. java '("for" "if" "switch" "while" "catch" "synchronized")
  2035. idl nil
  2036. pike '("for" "if" "switch" "while" "foreach")
  2037. awk '("for" "if" "while"))
  2038. (c-lang-defconst c-block-stmt-2-key
  2039. ;; Regexp matching the start of any statement followed by a paren sexp
  2040. ;; and then by a substatement.
  2041. t (c-make-keywords-re t (c-lang-const c-block-stmt-2-kwds)))
  2042. (c-lang-defvar c-block-stmt-2-key (c-lang-const c-block-stmt-2-key))
  2043. (c-lang-defconst c-block-stmt-kwds
  2044. ;; Union of `c-block-stmt-1-kwds' and `c-block-stmt-2-kwds'.
  2045. t (c--delete-duplicates (append (c-lang-const c-block-stmt-1-kwds)
  2046. (c-lang-const c-block-stmt-2-kwds))
  2047. :test 'string-equal))
  2048. (c-lang-defconst c-opt-block-stmt-key
  2049. ;; Regexp matching the start of any statement that has a
  2050. ;; substatement (except a bare block). Nil in languages that
  2051. ;; don't have such constructs.
  2052. t (if (or (c-lang-const c-block-stmt-1-kwds)
  2053. (c-lang-const c-block-stmt-2-kwds))
  2054. (c-make-keywords-re t
  2055. (append (c-lang-const c-block-stmt-1-kwds)
  2056. (c-lang-const c-block-stmt-2-kwds)))))
  2057. (c-lang-defvar c-opt-block-stmt-key (c-lang-const c-opt-block-stmt-key))
  2058. (c-lang-defconst c-simple-stmt-kwds
  2059. "Statement keywords followed by an expression or nothing."
  2060. t '("break" "continue" "goto" "return")
  2061. objc '("break" "continue" "goto" "return" "@throw")
  2062. ;; Note: `goto' is not valid in Java, but the keyword is still reserved.
  2063. java '("break" "continue" "goto" "return" "throw")
  2064. idl nil
  2065. pike '("break" "continue" "return")
  2066. awk '(;; Not sure about "delete", "exit", "getline", etc. ; ACM 2002/5/30
  2067. "break" "continue" "return" "delete" "exit" "getline" "next"
  2068. "nextfile" "print" "printf"))
  2069. (c-lang-defconst c-simple-stmt-key
  2070. ;; Adorned regexp matching `c-simple-stmt-kwds'.
  2071. t (c-make-keywords-re t (c-lang-const c-simple-stmt-kwds)))
  2072. (c-lang-defvar c-simple-stmt-key (c-lang-const c-simple-stmt-key))
  2073. (c-lang-defconst c-paren-stmt-kwds
  2074. "Statement keywords followed by a parenthesis expression that
  2075. nevertheless contains a list separated with `;' and not `,'."
  2076. t '("for")
  2077. idl nil)
  2078. (c-lang-defconst c-paren-stmt-key
  2079. ;; Adorned regexp matching `c-paren-stmt-kwds'.
  2080. t (c-make-keywords-re t (c-lang-const c-paren-stmt-kwds)))
  2081. (c-lang-defvar c-paren-stmt-key (c-lang-const c-paren-stmt-key))
  2082. (c-lang-defconst c-asm-stmt-kwds
  2083. "Statement keywords followed by an assembler expression."
  2084. t nil
  2085. (c c++) '("asm" "__asm__")) ;; Not standard, but common.
  2086. (c-lang-defconst c-opt-asm-stmt-key
  2087. ;; Regexp matching the start of an assembler statement. Nil in
  2088. ;; languages that don't support that.
  2089. t (if (c-lang-const c-asm-stmt-kwds)
  2090. (c-make-keywords-re t (c-lang-const c-asm-stmt-kwds))))
  2091. (c-lang-defvar c-opt-asm-stmt-key (c-lang-const c-opt-asm-stmt-key))
  2092. (c-lang-defconst c-case-kwds
  2093. "The keyword(s) which introduce a \"case\" like construct.
  2094. This construct is \"<keyword> <expression> :\"."
  2095. t '("case")
  2096. awk nil)
  2097. (c-lang-defconst c-case-kwds-regexp
  2098. ;; Adorned regexp matching any "case"-like keyword.
  2099. t (c-make-keywords-re t (c-lang-const c-case-kwds)))
  2100. (c-lang-defvar c-case-kwds-regexp (c-lang-const c-case-kwds-regexp))
  2101. (c-lang-defconst c-label-kwds
  2102. "Keywords introducing colon terminated labels in blocks."
  2103. t '("case" "default"))
  2104. (c-lang-defconst c-label-kwds-regexp
  2105. ;; Adorned regexp matching any keyword that introduces a label.
  2106. t (c-make-keywords-re t (c-lang-const c-label-kwds)))
  2107. (c-lang-defvar c-label-kwds-regexp (c-lang-const c-label-kwds-regexp))
  2108. (c-lang-defconst c-before-label-kwds
  2109. "Keywords that might be followed by a label identifier."
  2110. t '("goto")
  2111. (java pike) (append '("break" "continue")
  2112. (c-lang-const c-before-label-kwds))
  2113. idl nil
  2114. awk nil)
  2115. (c-lang-defconst c-constant-kwds
  2116. "Keywords for constants."
  2117. t nil
  2118. c '("NULL" ;; Not a keyword, but practically works as one.
  2119. "false" "true") ; Defined in C99.
  2120. c++ (append
  2121. '("nullptr")
  2122. (c-lang-const c-constant-kwds c))
  2123. objc '("nil" "Nil" "YES" "NO" "NS_DURING" "NS_HANDLER" "NS_ENDHANDLER")
  2124. idl '("TRUE" "FALSE")
  2125. java '("true" "false" "null") ; technically "literals", not keywords
  2126. pike '("UNDEFINED")) ;; Not a keyword, but practically works as one.
  2127. (c-lang-defconst c-primary-expr-kwds
  2128. "Keywords besides constants and operators that start primary expressions."
  2129. t nil
  2130. c++ '("operator" "this")
  2131. objc '("super" "self")
  2132. java '("this")
  2133. pike '("this")) ;; Not really a keyword, but practically works as one.
  2134. (c-lang-defconst c-expr-kwds
  2135. ;; Keywords that can occur anywhere in expressions. Built from
  2136. ;; `c-primary-expr-kwds' and all keyword operators in `c-operators'.
  2137. t (c--delete-duplicates
  2138. (append (c-lang-const c-primary-expr-kwds)
  2139. (c-filter-ops (c-lang-const c-operator-list)
  2140. t
  2141. "\\`\\(\\w\\|\\s_\\)+\\'"))
  2142. :test 'string-equal))
  2143. (c-lang-defconst c-lambda-kwds
  2144. "Keywords that start lambda constructs, i.e. function definitions in
  2145. expressions."
  2146. t nil
  2147. pike '("lambda"))
  2148. (c-lang-defconst c-inexpr-block-kwds
  2149. "Keywords that start constructs followed by statement blocks which can
  2150. be used in expressions \(the gcc extension for this in C and C++ is
  2151. handled separately by `c-recognize-paren-inexpr-blocks')."
  2152. t nil
  2153. pike '("catch" "gauge"))
  2154. (c-lang-defconst c-inexpr-class-kwds
  2155. "Keywords that can start classes inside expressions."
  2156. t nil
  2157. java '("new")
  2158. pike '("class"))
  2159. (c-lang-defconst c-inexpr-brace-list-kwds
  2160. "Keywords that can start brace list blocks inside expressions.
  2161. Note that Java specific rules are currently applied to tell this from
  2162. `c-inexpr-class-kwds'."
  2163. t nil
  2164. java '("new"))
  2165. (c-lang-defconst c-opt-inexpr-brace-list-key
  2166. ;; Regexp matching the start of a brace list in an expression, or
  2167. ;; nil in languages that don't have such things. This should not
  2168. ;; match brace lists recognized through `c-special-brace-lists'.
  2169. t (and (c-lang-const c-inexpr-brace-list-kwds)
  2170. (c-make-keywords-re t (c-lang-const c-inexpr-brace-list-kwds))))
  2171. (c-lang-defvar c-opt-inexpr-brace-list-key
  2172. (c-lang-const c-opt-inexpr-brace-list-key))
  2173. (c-lang-defconst c-decl-block-key
  2174. ;; Regexp matching keywords in any construct that contain another
  2175. ;; declaration level, i.e. that isn't followed by a function block
  2176. ;; or brace list. When the first submatch matches, it's an
  2177. ;; unambiguous construct, otherwise it's an ambiguous match that
  2178. ;; might also be the return type of a function declaration.
  2179. t (let* ((decl-kwds (append (c-lang-const c-class-decl-kwds)
  2180. (c-lang-const c-other-block-decl-kwds)
  2181. (c-lang-const c-inexpr-class-kwds)))
  2182. (unambiguous (c--set-difference decl-kwds
  2183. (c-lang-const c-type-start-kwds)
  2184. :test 'string-equal))
  2185. (ambiguous (c--intersection decl-kwds
  2186. (c-lang-const c-type-start-kwds)
  2187. :test 'string-equal)))
  2188. (if ambiguous
  2189. (concat (c-make-keywords-re t unambiguous)
  2190. "\\|"
  2191. (c-make-keywords-re t ambiguous))
  2192. (c-make-keywords-re t unambiguous))))
  2193. (c-lang-defvar c-decl-block-key (c-lang-const c-decl-block-key))
  2194. (c-lang-defconst c-bitfield-kwds
  2195. "Keywords that can introduce bitfields."
  2196. t nil
  2197. (c c++ objc) '("char" "int" "long" "signed" "unsigned"))
  2198. (c-lang-defconst c-opt-bitfield-key
  2199. ;; Regexp matching the start of a bitfield (not uniquely), or nil in
  2200. ;; languages without bitfield support.
  2201. t nil
  2202. (c c++) (c-make-keywords-re t (c-lang-const c-bitfield-kwds)))
  2203. (c-lang-defvar c-opt-bitfield-key (c-lang-const c-opt-bitfield-key))
  2204. (c-lang-defconst c-other-kwds
  2205. "Keywords not accounted for by any other `*-kwds' language constant."
  2206. t nil
  2207. idl '("truncatable"
  2208. ;; In CORBA CIDL: (These are declaration keywords that never
  2209. ;; can start a declaration.)
  2210. "entity" "process" "service" "session" "storage"))
  2211. ;;; Constants built from keywords.
  2212. ;; Note: No `*-kwds' language constants may be defined below this point.
  2213. (eval-and-compile
  2214. (defconst c-kwds-lang-consts
  2215. ;; List of all the language constants that contain keyword lists.
  2216. (let (list)
  2217. (mapatoms (lambda (sym)
  2218. (when (and (boundp sym)
  2219. (string-match "-kwds\\'" (symbol-name sym)))
  2220. ;; Make the list of globally interned symbols
  2221. ;; instead of ones interned in `c-lang-constants'.
  2222. (setq list (cons (intern (symbol-name sym)) list))))
  2223. c-lang-constants)
  2224. list)))
  2225. (c-lang-defconst c-keywords
  2226. ;; All keywords as a list.
  2227. t (c--delete-duplicates
  2228. (c-lang-defconst-eval-immediately
  2229. `(append ,@(mapcar (lambda (kwds-lang-const)
  2230. `(c-lang-const ,kwds-lang-const))
  2231. c-kwds-lang-consts)
  2232. nil))
  2233. :test 'string-equal))
  2234. (c-lang-defconst c-keywords-regexp
  2235. ;; All keywords as an adorned regexp.
  2236. t (c-make-keywords-re t (c-lang-const c-keywords)))
  2237. (c-lang-defvar c-keywords-regexp (c-lang-const c-keywords-regexp))
  2238. (c-lang-defconst c-keyword-member-alist
  2239. ;; An alist with all the keywords in the cars. The cdr for each
  2240. ;; keyword is a list of the symbols for the `*-kwds' lists that
  2241. ;; contains it.
  2242. t (let ((kwd-list-alist
  2243. (c-lang-defconst-eval-immediately
  2244. `(list ,@(mapcar (lambda (kwds-lang-const)
  2245. `(cons ',kwds-lang-const
  2246. (c-lang-const ,kwds-lang-const)))
  2247. c-kwds-lang-consts))))
  2248. lang-const kwd-list kwd
  2249. result-alist elem)
  2250. (while kwd-list-alist
  2251. (setq lang-const (caar kwd-list-alist)
  2252. kwd-list (cdar kwd-list-alist)
  2253. kwd-list-alist (cdr kwd-list-alist))
  2254. (while kwd-list
  2255. (setq kwd (car kwd-list)
  2256. kwd-list (cdr kwd-list))
  2257. (unless (setq elem (assoc kwd result-alist))
  2258. (setq result-alist (cons (setq elem (list kwd)) result-alist)))
  2259. (unless (memq lang-const (cdr elem))
  2260. (setcdr elem (cons lang-const (cdr elem))))))
  2261. result-alist))
  2262. (c-lang-defvar c-keywords-obarray
  2263. ;; An obarray containing all keywords as symbols. The property list
  2264. ;; of each symbol has a non-nil entry for the specific `*-kwds'
  2265. ;; lists it's a member of.
  2266. ;;
  2267. ;; E.g. to see whether the string str contains a keyword on
  2268. ;; `c-class-decl-kwds', one can do like this:
  2269. ;; (get (intern-soft str c-keyword-obarray) 'c-class-decl-kwds)
  2270. ;; Which preferably is written using the associated functions in
  2271. ;; cc-engine:
  2272. ;; (c-keyword-member (c-keyword-sym str) 'c-class-decl-kwds)
  2273. ;; The obarray is not stored directly as a language constant since
  2274. ;; the printed representation for obarrays used in .elc files isn't
  2275. ;; complete.
  2276. (let* ((alist (c-lang-const c-keyword-member-alist))
  2277. kwd lang-const-list
  2278. (obarray (make-vector (* (length alist) 2) 0)))
  2279. (while alist
  2280. (setq kwd (caar alist)
  2281. lang-const-list (cdar alist)
  2282. alist (cdr alist))
  2283. (setplist (intern kwd obarray)
  2284. ;; Emacs has an odd bug that causes `mapcan' to fail
  2285. ;; with unintelligible errors. (XEmacs works.)
  2286. ;; (2015-06-24): This bug has not yet been fixed.
  2287. ;;(mapcan (lambda (lang-const)
  2288. ;; (list lang-const t))
  2289. ;; lang-const-list)
  2290. (apply 'nconc (mapcar (lambda (lang-const)
  2291. (list lang-const t))
  2292. lang-const-list))))
  2293. obarray))
  2294. (c-lang-defconst c-regular-keywords-regexp
  2295. ;; Adorned regexp matching all keywords that should be fontified
  2296. ;; with the keywords face. I.e. that aren't types or constants.
  2297. t (c-make-keywords-re t
  2298. (c--set-difference (c-lang-const c-keywords)
  2299. (append (c-lang-const c-primitive-type-kwds)
  2300. (c-lang-const c-constant-kwds))
  2301. :test 'string-equal)))
  2302. (c-lang-defvar c-regular-keywords-regexp
  2303. (c-lang-const c-regular-keywords-regexp))
  2304. (c-lang-defconst c-primary-expr-regexp
  2305. ;; Regexp matching the start of any primary expression, i.e. any
  2306. ;; literal, symbol, prefix operator, and '('. It doesn't need to
  2307. ;; exclude keywords; they are excluded afterwards unless the second
  2308. ;; submatch matches. If the first but not the second submatch
  2309. ;; matches then it is an ambiguous primary expression; it could also
  2310. ;; be a match of e.g. an infix operator. (The case with ambiguous
  2311. ;; keyword operators isn't handled.)
  2312. t (let* ((prefix-ops
  2313. (c-filter-ops (c-lang-const c-operators)
  2314. '(prefix)
  2315. (lambda (op)
  2316. ;; Filter out the special case prefix
  2317. ;; operators that are close parens.
  2318. (not (string-match "\\s)" op)))))
  2319. (nonkeyword-prefix-ops
  2320. (c-filter-ops prefix-ops
  2321. t
  2322. "\\`\\(\\s.\\|\\s(\\|\\s)\\)+\\'"))
  2323. (in-or-postfix-ops
  2324. (c-filter-ops (c-lang-const c-operators)
  2325. '(postfix
  2326. postfix-if-paren
  2327. left-assoc
  2328. right-assoc
  2329. right-assoc-sequence)
  2330. t))
  2331. (unambiguous-prefix-ops (c--set-difference nonkeyword-prefix-ops
  2332. in-or-postfix-ops
  2333. :test 'string-equal))
  2334. (ambiguous-prefix-ops (c--intersection nonkeyword-prefix-ops
  2335. in-or-postfix-ops
  2336. :test 'string-equal)))
  2337. (concat
  2338. "\\("
  2339. ;; Take out all symbol class operators from `prefix-ops' and make the
  2340. ;; first submatch from them together with `c-primary-expr-kwds'.
  2341. (c-make-keywords-re t
  2342. (append (c-lang-const c-primary-expr-kwds)
  2343. (c--set-difference prefix-ops nonkeyword-prefix-ops
  2344. :test 'string-equal)))
  2345. "\\|"
  2346. ;; Match all ambiguous operators.
  2347. (c-make-keywords-re nil
  2348. (c--intersection nonkeyword-prefix-ops in-or-postfix-ops
  2349. :test 'string-equal))
  2350. "\\)"
  2351. "\\|"
  2352. ;; Now match all other symbols.
  2353. (c-lang-const c-symbol-start)
  2354. "\\|"
  2355. ;; The chars that can start integer and floating point
  2356. ;; constants.
  2357. "\\.?[0-9]"
  2358. "\\|"
  2359. ;; The unambiguous operators from `prefix-ops'.
  2360. (c-make-keywords-re nil
  2361. (c--set-difference nonkeyword-prefix-ops in-or-postfix-ops
  2362. :test 'string-equal))
  2363. "\\|"
  2364. ;; Match string and character literals.
  2365. "\\s\""
  2366. (if (memq 'gen-string-delim c-emacs-features)
  2367. "\\|\\s|"
  2368. ""))))
  2369. (c-lang-defvar c-primary-expr-regexp (c-lang-const c-primary-expr-regexp))
  2370. ;;; Additional constants for parser-level constructs.
  2371. (c-lang-defconst c-decl-start-colon-kwd-re
  2372. "Regexp matching a keyword that is followed by a colon, where
  2373. the whole construct can precede a declaration.
  2374. E.g. \"public:\" in C++."
  2375. t "\\<\\>"
  2376. c++ (c-make-keywords-re t (c-lang-const c-protection-kwds)))
  2377. (c-lang-defvar c-decl-start-colon-kwd-re
  2378. (c-lang-const c-decl-start-colon-kwd-re))
  2379. (c-lang-defconst c-decl-prefix-re
  2380. "Regexp matching something that might precede a declaration, cast or
  2381. label, such as the last token of a preceding statement or declaration.
  2382. This is used in the common situation where a declaration or cast
  2383. doesn't start with any specific token that can be searched for.
  2384. The regexp should not match bob; that is done implicitly. It can't
  2385. require a match longer than one token. The end of the token is taken
  2386. to be at the end of the first submatch, which is assumed to always
  2387. match. It's undefined whether identifier syntax (see
  2388. `c-identifier-syntax-table') is in effect or not. This regexp is
  2389. assumed to be a superset of `c-label-prefix-re' if
  2390. `c-recognize-colon-labels' is set.
  2391. Besides this, `c-decl-start-kwds' is used to find declarations.
  2392. Note: This variable together with `c-decl-start-re' and
  2393. `c-decl-start-kwds' is only used to detect \"likely\"
  2394. declaration/cast/label starts. I.e. they might produce more matches
  2395. but should not miss anything (or else it's necessary to use text
  2396. properties - see the next note). Wherever they match, the following
  2397. construct is analyzed to see if it indeed is a declaration, cast or
  2398. label. That analysis is not cheap, so it's important that not too
  2399. many false matches are triggered.
  2400. Note: If a declaration/cast/label start can't be detected with this
  2401. variable, it's necessary to use the `c-type' text property with the
  2402. value `c-decl-end' on the last char of the last token preceding the
  2403. declaration. See the comment blurb at the start of cc-engine.el for
  2404. more info."
  2405. ;; We match a sequence of characters to skip over things like \"};\"
  2406. ;; more quickly. We match ")" in C for K&R region declarations, and
  2407. ;; in all languages except Java for when a cpp macro definition
  2408. ;; begins with a declaration.
  2409. t "\\([{}();,]+\\)"
  2410. java "\\([{}(;,<]+\\)"
  2411. ;; Match "<" in C++ to get the first argument in a template arglist.
  2412. ;; In that case there's an additional check in `c-find-decl-spots'
  2413. ;; that it got open paren syntax. Match ":" to aid in picking up
  2414. ;; "public:", etc. This involves additional checks in
  2415. ;; `c-find-decl-prefix-search' to prevent a match of identifiers
  2416. ;; or labels.
  2417. c++ "\\([{}();:,<]+\\)"
  2418. ;; Additionally match the protection directives in Objective-C.
  2419. ;; Note that this doesn't cope with the longer directives, which we
  2420. ;; would have to match from start to end since they don't end with
  2421. ;; any easily recognized characters.
  2422. objc (concat "\\([{}();,]+\\|"
  2423. (c-make-keywords-re nil (c-lang-const c-protection-kwds))
  2424. "\\)")
  2425. ;; Pike is like C but we also match "[" for multiple value
  2426. ;; assignments and type casts.
  2427. pike "\\([{}()[;,]+\\)")
  2428. (c-lang-defvar c-decl-prefix-re (c-lang-const c-decl-prefix-re)
  2429. 'dont-doc)
  2430. (c-lang-defconst c-decl-start-re
  2431. "Regexp matching the start of any declaration, cast or label.
  2432. It's used on the token after the one `c-decl-prefix-re' matched. This
  2433. regexp should not try to match those constructs accurately as it's
  2434. only used as a sieve to avoid spending more time checking other
  2435. constructs."
  2436. t (c-lang-const c-identifier-start))
  2437. (c-lang-defvar c-decl-start-re (c-lang-const c-decl-start-re))
  2438. (c-lang-defconst c-decl-prefix-or-start-re
  2439. ;; Regexp matching something that might precede or start a
  2440. ;; declaration, cast or label.
  2441. ;;
  2442. ;; If the first submatch matches, it's taken to match the end of a
  2443. ;; token that might precede such a construct, e.g. ';', '}' or '{'.
  2444. ;; It's built from `c-decl-prefix-re'.
  2445. ;;
  2446. ;; If the first submatch did not match, the match of the whole
  2447. ;; regexp is taken to be at the first token in the declaration.
  2448. ;; `c-decl-start-re' is not checked in this case.
  2449. ;;
  2450. ;; Design note: The reason the same regexp is used to match both
  2451. ;; tokens that precede declarations and start them is to avoid an
  2452. ;; extra regexp search from the previous declaration spot in
  2453. ;; `c-find-decl-spots'. Users of `c-find-decl-spots' also count on
  2454. ;; that it finds all declaration/cast/label starts in approximately
  2455. ;; linear order, so we can't do the searches in two separate passes.
  2456. t (if (c-lang-const c-decl-start-kwds)
  2457. (concat (c-lang-const c-decl-prefix-re)
  2458. "\\|"
  2459. (c-make-keywords-re t (c-lang-const c-decl-start-kwds)))
  2460. (c-lang-const c-decl-prefix-re)))
  2461. (c-lang-defvar c-decl-prefix-or-start-re
  2462. (c-lang-const c-decl-prefix-or-start-re)
  2463. 'dont-doc)
  2464. (c-lang-defconst c-cast-parens
  2465. ;; List containing the paren characters that can open a cast, or nil in
  2466. ;; languages without casts.
  2467. t (c-filter-ops (c-lang-const c-operators)
  2468. '(prefix)
  2469. "\\`\\s(\\'"
  2470. (lambda (op) (elt op 0))))
  2471. (c-lang-defvar c-cast-parens (c-lang-const c-cast-parens))
  2472. (c-lang-defconst c-block-prefix-disallowed-chars
  2473. "List of syntactically relevant characters that never can occur before
  2474. the open brace in any construct that contains a brace block, e.g. in
  2475. the \"class Foo: public Bar\" part of:
  2476. class Foo: public Bar {int x();} a, *b;
  2477. If parens can occur, the chars inside those aren't filtered with this
  2478. list.
  2479. `<' and `>' should be disallowed even if angle bracket arglists can
  2480. occur. That since the search function needs to stop at them anyway to
  2481. ensure they are given paren syntax.
  2482. This is used to skip backward from the open brace to find the region
  2483. in which to look for a construct like \"class\", \"enum\",
  2484. \"namespace\" or whatever. That skipping should be as tight as
  2485. possible for good performance."
  2486. ;; Default to all chars that only occurs in nonsymbol tokens outside
  2487. ;; identifiers.
  2488. t (c--set-difference
  2489. (c-lang-const c-nonsymbol-token-char-list)
  2490. (c-filter-ops (append (c-lang-const c-identifier-ops)
  2491. (list (cons nil
  2492. (c-lang-const c-after-id-concat-ops))))
  2493. t
  2494. t
  2495. (lambda (op)
  2496. (let ((pos 0) res)
  2497. (while (string-match "\\(\\s.\\|\\s(\\|\\s)\\)"
  2498. op pos)
  2499. (setq res (cons (aref op (match-beginning 1)) res)
  2500. pos (match-end 0)))
  2501. res))))
  2502. ;; Allow cpp operations (where applicable).
  2503. t (if (c-lang-const c-opt-cpp-prefix)
  2504. (c--set-difference (c-lang-const c-block-prefix-disallowed-chars)
  2505. '(?#))
  2506. (c-lang-const c-block-prefix-disallowed-chars))
  2507. ;; Allow ':' for inherit list starters.
  2508. (c++ objc idl) (c--set-difference (c-lang-const c-block-prefix-disallowed-chars)
  2509. '(?:))
  2510. ;; Allow ',' for multiple inherits.
  2511. (c++ java) (c--set-difference (c-lang-const c-block-prefix-disallowed-chars)
  2512. '(?,))
  2513. ;; Allow parentheses for anonymous inner classes in Java and class
  2514. ;; initializer lists in Pike.
  2515. (java pike) (c--set-difference (c-lang-const c-block-prefix-disallowed-chars)
  2516. '(?\( ?\)))
  2517. ;; Allow '"' for extern clauses (e.g. extern "C" {...}).
  2518. (c c++ objc) (c--set-difference (c-lang-const c-block-prefix-disallowed-chars)
  2519. '(?\" ?')))
  2520. (c-lang-defconst c-block-prefix-charset
  2521. ;; `c-block-prefix-disallowed-chars' as an inverted charset suitable
  2522. ;; for `c-syntactic-skip-backward'.
  2523. t (c-make-bare-char-alt (c-lang-const c-block-prefix-disallowed-chars) t))
  2524. (c-lang-defvar c-block-prefix-charset (c-lang-const c-block-prefix-charset))
  2525. (c-lang-defconst c-type-decl-prefix-key
  2526. "Regexp matching any declarator operator that might precede the
  2527. identifier in a declaration, e.g. the \"*\" in \"char *argv\". This
  2528. regexp should match \"(\" if parentheses are valid in declarators.
  2529. The end of the first submatch is taken as the end of the operator.
  2530. Identifier syntax is in effect when this is matched \(see
  2531. `c-identifier-syntax-table')."
  2532. t (if (c-lang-const c-type-modifier-kwds)
  2533. (concat (regexp-opt (c-lang-const c-type-modifier-kwds) t) "\\>")
  2534. ;; Default to a regexp that never matches.
  2535. "\\<\\>")
  2536. ;; Check that there's no "=" afterwards to avoid matching tokens
  2537. ;; like "*=".
  2538. (c objc) (concat "\\("
  2539. "[*(]"
  2540. "\\|"
  2541. (c-lang-const c-type-decl-prefix-key)
  2542. "\\)"
  2543. "\\([^=]\\|$\\)")
  2544. c++ (concat "\\("
  2545. "[*(&]"
  2546. "\\|"
  2547. (c-lang-const c-type-decl-prefix-key)
  2548. "\\|"
  2549. (concat "\\(" ; 3
  2550. ;; If this matches there's special treatment in
  2551. ;; `c-font-lock-declarators' and
  2552. ;; `c-font-lock-declarations' that check for a
  2553. ;; complete name followed by ":: *".
  2554. (c-lang-const c-identifier-start)
  2555. "\\)")
  2556. "\\)"
  2557. "\\([^=]\\|$\\)")
  2558. pike "\\(\\*\\)\\([^=]\\|$\\)")
  2559. (c-lang-defvar c-type-decl-prefix-key (c-lang-const c-type-decl-prefix-key)
  2560. 'dont-doc)
  2561. (c-lang-defconst c-type-decl-suffix-key
  2562. "Regexp matching the declarator operators that might follow after the
  2563. identifier in a declaration, e.g. the \"[\" in \"char argv[]\". This
  2564. regexp should match \")\" if parentheses are valid in declarators. If
  2565. it matches an open paren of some kind, the type declaration check
  2566. continues at the corresponding close paren, otherwise the end of the
  2567. first submatch is taken as the end of the operator. Identifier syntax
  2568. is in effect when this is matched (see `c-identifier-syntax-table')."
  2569. ;; Default to a regexp that matches `c-type-modifier-kwds' and a
  2570. ;; function argument list parenthesis.
  2571. t (if (c-lang-const c-type-modifier-kwds)
  2572. (concat "\\((\\|"
  2573. (regexp-opt (c-lang-const c-type-modifier-kwds) t) "\\>"
  2574. "\\)")
  2575. "\\((\\)")
  2576. (c c++ objc) (concat
  2577. "\\("
  2578. "[)[(]"
  2579. (if (c-lang-const c-type-modifier-kwds)
  2580. (concat
  2581. "\\|"
  2582. ;; "throw" in `c-type-modifier-kwds' is followed
  2583. ;; by a parenthesis list, but no extra measures
  2584. ;; are necessary to handle that.
  2585. (regexp-opt (c-lang-const c-type-modifier-kwds) t)
  2586. "\\>")
  2587. "")
  2588. "\\)")
  2589. java "\\([[()]\\)"
  2590. idl "\\([[(]\\)")
  2591. (c-lang-defvar c-type-decl-suffix-key (c-lang-const c-type-decl-suffix-key)
  2592. 'dont-doc)
  2593. (c-lang-defconst c-after-suffixed-type-decl-key
  2594. "This regexp is matched after a declarator expression where
  2595. `c-type-decl-suffix-key' has matched. If it matches then the
  2596. construct is taken as a declaration. It's typically used to match the
  2597. beginning of a function body or whatever might occur after the
  2598. function header in a function declaration or definition. It's
  2599. undefined whether identifier syntax (see `c-identifier-syntax-table')
  2600. is in effect or not.
  2601. Note that it's used in cases like after \"foo (bar)\" so it should
  2602. only match when it's certain that it's a declaration, e.g., \"{\" but
  2603. not \",\" or \";\"."
  2604. t "{"
  2605. ;; If K&R style declarations should be recognized then one could
  2606. ;; consider to match the start of any symbol since we want to match
  2607. ;; the start of the first declaration in the "K&R region". That
  2608. ;; could however produce false matches on code like "FOO(bar) x"
  2609. ;; where FOO is a cpp macro, so it's better to leave it out and rely
  2610. ;; on the other heuristics in that case.
  2611. t (if (c-lang-const c-postfix-spec-kwds)
  2612. ;; Add on the keywords in `c-postfix-spec-kwds'.
  2613. (concat (c-lang-const c-after-suffixed-type-decl-key)
  2614. "\\|"
  2615. (c-make-keywords-re t (c-lang-const c-postfix-spec-kwds)))
  2616. (c-lang-const c-after-suffixed-type-decl-key))
  2617. ;; Also match the colon that starts a base class initializer list in
  2618. ;; C++. That can be confused with a function call before the colon
  2619. ;; in a ? : operator, but we count on that `c-decl-prefix-re' won't
  2620. ;; match before such a thing (as a declaration-level construct;
  2621. ;; matches inside arglist contexts are already excluded).
  2622. c++ "[{:]")
  2623. (c-lang-defvar c-after-suffixed-type-decl-key
  2624. (c-lang-const c-after-suffixed-type-decl-key)
  2625. 'dont-doc)
  2626. (c-lang-defconst c-after-suffixed-type-maybe-decl-key
  2627. ;; Regexp that in addition to `c-after-suffixed-type-decl-key'
  2628. ;; matches ";" and ",".
  2629. t (concat "\\(" (c-lang-const c-after-suffixed-type-decl-key) "\\)"
  2630. "\\|[;,]"))
  2631. (c-lang-defvar c-after-suffixed-type-maybe-decl-key
  2632. (c-lang-const c-after-suffixed-type-maybe-decl-key))
  2633. (c-lang-defconst c-opt-type-concat-key
  2634. "Regexp matching operators that concatenate types, e.g. the \"|\" in
  2635. \"int|string\" in Pike. The end of the first submatch is taken as the
  2636. end of the operator. nil in languages without such operators. It's
  2637. undefined whether identifier syntax (see `c-identifier-syntax-table')
  2638. is in effect or not."
  2639. t nil
  2640. pike "\\([|.&]\\)\\($\\|[^|.&]\\)")
  2641. (c-lang-defvar c-opt-type-concat-key (c-lang-const c-opt-type-concat-key)
  2642. 'dont-doc)
  2643. (c-lang-defconst c-opt-type-suffix-key
  2644. "Regexp matching operators that might follow after a type, or nil in
  2645. languages that don't have such operators. The end of the first
  2646. submatch is taken as the end of the operator. This should not match
  2647. things like C++ template arglists if `c-recognize-<>-arglists' is set.
  2648. It's undefined whether identifier syntax (see `c-identifier-syntax-table')
  2649. is in effect or not."
  2650. t nil
  2651. (c c++ objc pike) "\\(\\.\\.\\.\\)"
  2652. java (concat "\\(\\[" (c-lang-const c-simple-ws) "*\\]\\|\\.\\.\\.\\)"))
  2653. (c-lang-defvar c-opt-type-suffix-key (c-lang-const c-opt-type-suffix-key))
  2654. (c-lang-defvar c-known-type-key
  2655. ;; Regexp matching the known type identifiers. This is initialized
  2656. ;; from the type keywords and `*-font-lock-extra-types'. The first
  2657. ;; submatch is the one that matches the type. Note that this regexp
  2658. ;; assumes that symbol constituents like '_' and '$' have word
  2659. ;; syntax.
  2660. (let* ((extra-types
  2661. (when (boundp (c-mode-symbol "font-lock-extra-types"))
  2662. (c-mode-var "font-lock-extra-types")))
  2663. (regexp-strings
  2664. (delq nil (mapcar (lambda (re)
  2665. (when (string-match "[][.*+?^$\\]" re)
  2666. re))
  2667. extra-types)))
  2668. (plain-strings
  2669. (delq nil (mapcar (lambda (re)
  2670. (unless (string-match "[][.*+?^$\\]" re)
  2671. re))
  2672. extra-types))))
  2673. (concat "\\<\\("
  2674. (c-concat-separated
  2675. (append (list (c-make-keywords-re nil
  2676. (append (c-lang-const c-primitive-type-kwds)
  2677. plain-strings)))
  2678. regexp-strings)
  2679. "\\|")
  2680. "\\)\\>")))
  2681. (c-lang-defconst c-special-brace-lists
  2682. "List of open- and close-chars that makes up a pike-style brace list,
  2683. i.e. for a ([ ]) list there should be a cons (?\\[ . ?\\]) in this
  2684. list."
  2685. t nil
  2686. pike '((?{ . ?}) (?\[ . ?\]) (?< . ?>)))
  2687. (c-lang-defvar c-special-brace-lists (c-lang-const c-special-brace-lists))
  2688. (c-lang-defconst c-recognize-knr-p
  2689. "Non-nil means K&R style argument declarations are valid."
  2690. t nil
  2691. c t)
  2692. (c-lang-defvar c-recognize-knr-p (c-lang-const c-recognize-knr-p))
  2693. (c-lang-defconst c-recognize-typeless-decls
  2694. "Non-nil means function declarations without return type should be
  2695. recognized. That can introduce an ambiguity with parenthesized macro
  2696. calls before a brace block. This setting does not affect declarations
  2697. that are preceded by a declaration starting keyword, so
  2698. e.g. `c-typeless-decl-kwds' may still be used when it's set to nil."
  2699. t nil
  2700. (c c++ objc java) t)
  2701. (c-lang-defvar c-recognize-typeless-decls
  2702. (c-lang-const c-recognize-typeless-decls))
  2703. (c-lang-defconst c-recognize-<>-arglists
  2704. "Non-nil means C++ style template arglists should be handled. More
  2705. specifically, this means a comma separated list of types or
  2706. expressions surrounded by \"<\" and \">\". It's always preceded by an
  2707. identifier or one of the keywords on `c-<>-type-kwds' or
  2708. `c-<>-arglist-kwds'. If there's an identifier before then the whole
  2709. expression is considered to be a type."
  2710. t (or (consp (c-lang-const c-<>-type-kwds))
  2711. (consp (c-lang-const c-<>-arglist-kwds)))
  2712. java t) ; 2008-10-19. This is crude. The syntax for java
  2713. ; generics is not yet coded in CC Mode.
  2714. (c-lang-defvar c-recognize-<>-arglists (c-lang-const c-recognize-<>-arglists))
  2715. (c-lang-defconst c-enums-contain-decls
  2716. "Non-nil means that an enum structure can contain declarations."
  2717. t nil
  2718. java t)
  2719. (c-lang-defvar c-enums-contain-decls (c-lang-const c-enums-contain-decls))
  2720. (c-lang-defconst c-recognize-paren-inits
  2721. "Non-nil means that parenthesis style initializers exist,
  2722. i.e. constructs like
  2723. Foo bar (gnu);
  2724. in addition to the more classic
  2725. Foo bar = gnu;"
  2726. t nil
  2727. c++ t)
  2728. (c-lang-defvar c-recognize-paren-inits (c-lang-const c-recognize-paren-inits))
  2729. (c-lang-defconst c-recognize-paren-inexpr-blocks
  2730. "Non-nil to recognize gcc style in-expression blocks,
  2731. i.e. compound statements surrounded by parentheses inside expressions."
  2732. t nil
  2733. (c c++) t)
  2734. (c-lang-defvar c-recognize-paren-inexpr-blocks
  2735. (c-lang-const c-recognize-paren-inexpr-blocks))
  2736. (c-lang-defconst c-opt-<>-arglist-start
  2737. ;; Regexp matching the start of angle bracket arglists in languages
  2738. ;; where `c-recognize-<>-arglists' is set. Does not exclude
  2739. ;; keywords outside `c-<>-arglist-kwds'. The first submatch is
  2740. ;; assumed to surround the preceding symbol. The whole match is
  2741. ;; assumed to end directly after the opening "<".
  2742. t (if (c-lang-const c-recognize-<>-arglists)
  2743. (concat "\\("
  2744. (c-lang-const c-symbol-key)
  2745. "\\)"
  2746. (c-lang-const c-syntactic-ws)
  2747. "<")))
  2748. (c-lang-defvar c-opt-<>-arglist-start (c-lang-const c-opt-<>-arglist-start))
  2749. (c-lang-defconst c-opt-<>-arglist-start-in-paren
  2750. ;; Regexp that in addition to `c-opt-<>-arglist-start' matches close
  2751. ;; parens. The first submatch is assumed to surround
  2752. ;; `c-opt-<>-arglist-start'.
  2753. t (if (c-lang-const c-opt-<>-arglist-start)
  2754. (concat "\\("
  2755. (c-lang-const c-opt-<>-arglist-start)
  2756. "\\)\\|\\s)")))
  2757. (c-lang-defvar c-opt-<>-arglist-start-in-paren
  2758. (c-lang-const c-opt-<>-arglist-start-in-paren))
  2759. (c-lang-defconst c-opt-postfix-decl-spec-key
  2760. ;; Regexp matching the beginning of a declaration specifier in the
  2761. ;; region between the header and the body of a declaration.
  2762. ;;
  2763. ;; TODO: This is currently not used uniformly; c++-mode and
  2764. ;; java-mode each have their own ways of using it.
  2765. t nil
  2766. c++ (concat ":?"
  2767. (c-lang-const c-simple-ws) "*"
  2768. "\\(virtual" (c-lang-const c-simple-ws) "+\\)?\\("
  2769. (c-make-keywords-re nil (c-lang-const c-protection-kwds))
  2770. "\\)" (c-lang-const c-simple-ws) "+"
  2771. "\\(" (c-lang-const c-symbol-key) "\\)")
  2772. java (c-make-keywords-re t (c-lang-const c-postfix-spec-kwds)))
  2773. (c-lang-defvar c-opt-postfix-decl-spec-key
  2774. (c-lang-const c-opt-postfix-decl-spec-key))
  2775. (c-lang-defconst c-recognize-colon-labels
  2776. "Non-nil if generic labels ending with \":\" should be recognized.
  2777. That includes labels in code and access keys in classes. This does
  2778. not apply to labels recognized by `c-label-kwds' and
  2779. `c-opt-extra-label-key'."
  2780. t nil
  2781. (c c++ objc java pike) t)
  2782. (c-lang-defvar c-recognize-colon-labels
  2783. (c-lang-const c-recognize-colon-labels))
  2784. (c-lang-defconst c-label-prefix-re
  2785. "Regexp like `c-decl-prefix-re' that matches any token that can precede
  2786. a generic colon label. Not used if `c-recognize-colon-labels' is
  2787. nil."
  2788. t "\\([{};]+\\)")
  2789. (c-lang-defvar c-label-prefix-re
  2790. (c-lang-const c-label-prefix-re))
  2791. (c-lang-defconst c-nonlabel-token-key
  2792. "Regexp matching things that can't occur in generic colon labels,
  2793. neither in a statement nor in a declaration context. The regexp is
  2794. tested at the beginning of every sexp in a suspected label,
  2795. i.e. before \":\". Only used if `c-recognize-colon-labels' is set."
  2796. t (concat
  2797. ;; All keywords except `c-label-kwds' and `c-protection-kwds'.
  2798. (c-make-keywords-re t
  2799. (c--set-difference (c-lang-const c-keywords)
  2800. (append (c-lang-const c-label-kwds)
  2801. (c-lang-const c-protection-kwds))
  2802. :test 'string-equal)))
  2803. ;; Don't allow string literals, except in AWK. Character constants are OK.
  2804. (c objc java pike idl) (concat "\"\\|"
  2805. (c-lang-const c-nonlabel-token-key))
  2806. ;; Also check for open parens in C++, to catch member init lists in
  2807. ;; constructors. We normally allow it so that macros with arguments
  2808. ;; work in labels.
  2809. c++ (concat "\\s(\\|\"\\|" (c-lang-const c-nonlabel-token-key)))
  2810. (c-lang-defvar c-nonlabel-token-key (c-lang-const c-nonlabel-token-key))
  2811. (c-lang-defconst c-nonlabel-token-2-key
  2812. "Regexp matching things that can't occur two symbols before a colon in
  2813. a label construct. This catches C++'s inheritance construct \"class foo
  2814. : bar\". Only used if `c-recognize-colon-labels' is set."
  2815. t "\\<\\>" ; matches nothing
  2816. c++ (c-make-keywords-re t '("class")))
  2817. (c-lang-defvar c-nonlabel-token-2-key (c-lang-const c-nonlabel-token-2-key))
  2818. (c-lang-defconst c-opt-extra-label-key
  2819. "Optional regexp matching labels.
  2820. Normally, labels are detected according to `c-nonlabel-token-key',
  2821. `c-decl-prefix-re' and `c-nonlabel-decl-prefix-re'. This regexp can
  2822. be used if there are additional labels that aren't recognized that
  2823. way."
  2824. t nil
  2825. objc (c-make-keywords-re t (c-lang-const c-protection-kwds)))
  2826. (c-lang-defvar c-opt-extra-label-key (c-lang-const c-opt-extra-label-key))
  2827. (c-lang-defconst c-opt-friend-key
  2828. ;; Regexp describing friend declarations classes, or nil in
  2829. ;; languages that don't have such things.
  2830. ;;
  2831. ;; TODO: Ought to use `c-prefix-spec-kwds-re' or similar, and the
  2832. ;; template skipping isn't done properly. This will disappear soon.
  2833. t nil
  2834. c++ (concat "friend" (c-lang-const c-simple-ws) "+"
  2835. "\\|"
  2836. (concat "template"
  2837. (c-lang-const c-simple-ws) "*"
  2838. "<.+>"
  2839. (c-lang-const c-simple-ws) "*"
  2840. "friend"
  2841. (c-lang-const c-simple-ws) "+")))
  2842. (c-lang-defvar c-opt-friend-key (c-lang-const c-opt-friend-key))
  2843. (c-lang-defconst c-opt-method-key
  2844. ;; Special regexp to match the start of Objective-C methods. The
  2845. ;; first submatch is assumed to end after the + or - key.
  2846. t nil
  2847. objc (concat
  2848. ;; TODO: Ought to use a better method than anchoring on bol.
  2849. "^\\s *"
  2850. "\\([+-]\\)"
  2851. (c-lang-const c-simple-ws) "*"
  2852. (concat "\\(" ; Return type.
  2853. "([^)]*)"
  2854. (c-lang-const c-simple-ws) "*"
  2855. "\\)?")
  2856. "\\(" (c-lang-const c-symbol-key) "\\)"))
  2857. (c-lang-defvar c-opt-method-key (c-lang-const c-opt-method-key))
  2858. (c-lang-defconst c-type-decl-end-used
  2859. ;; Must be set in buffers where the `c-type' text property might be
  2860. ;; used with the value `c-decl-end'.
  2861. ;;
  2862. ;; `c-decl-end' is used to mark the ends of labels and access keys
  2863. ;; to make interactive refontification work better.
  2864. t (or (c-lang-const c-recognize-colon-labels)
  2865. (and (c-lang-const c-label-kwds) t))
  2866. ;; `c-decl-end' is used to mark the end of the @-style directives in
  2867. ;; Objective-C.
  2868. objc t)
  2869. (c-lang-defvar c-type-decl-end-used (c-lang-const c-type-decl-end-used))
  2870. ;;; Wrap up the `c-lang-defvar' system.
  2871. ;; Compile in the list of language variables that has been collected
  2872. ;; with the `c-lang-defvar' and `c-lang-setvar' macros. Note that the
  2873. ;; first element of each is nil.
  2874. (defconst c-lang-variable-inits (cc-eval-when-compile c-lang-variable-inits))
  2875. (defconst c-emacs-variable-inits (cc-eval-when-compile c-emacs-variable-inits))
  2876. ;; Make the `c-lang-setvar' variables buffer local in the current buffer.
  2877. ;; These are typically standard emacs variables such as `comment-start'.
  2878. (defmacro c-make-emacs-variables-local ()
  2879. `(progn
  2880. ,@(mapcar (lambda (init)
  2881. `(make-local-variable ',(car init)))
  2882. (cdr c-emacs-variable-inits))))
  2883. (defun c-make-init-lang-vars-fun (mode)
  2884. "Create a function that initializes all the language dependent variables
  2885. for the given mode.
  2886. This function should be evaluated at compile time, so that the
  2887. function it returns is byte compiled with all the evaluated results
  2888. from the language constants. Use the `c-init-language-vars' macro to
  2889. accomplish that conveniently."
  2890. (if (cc-bytecomp-is-compiling)
  2891. ;; No need to byte compile this lambda since the byte compiler is
  2892. ;; smart enough to detect the `funcall' construct in the
  2893. ;; `c-init-language-vars' macro below and compile it all straight
  2894. ;; into the function that contains `c-init-language-vars'.
  2895. `(lambda ()
  2896. ;; This let sets up the context for `c-mode-var' and similar
  2897. ;; that could be in the result from `c--macroexpand-all'.
  2898. (let ((c-buffer-is-cc-mode ',mode)
  2899. current-var source-eval)
  2900. (c-make-emacs-variables-local)
  2901. (condition-case err
  2902. (if (eq c-version-sym ',c-version-sym)
  2903. (setq ,@(let ((c-buffer-is-cc-mode mode)
  2904. (c-lang-const-expansion 'immediate))
  2905. ;; `c-lang-const' will expand to the evaluated
  2906. ;; constant immediately in `c--macroexpand-all'
  2907. ;; below.
  2908. (c--mapcan
  2909. (lambda (init)
  2910. `(current-var ',(car init)
  2911. ,(car init) ,(c--macroexpand-all
  2912. (elt init 1))))
  2913. ;; Note: The following `append' copies the
  2914. ;; first argument. That list is small, so
  2915. ;; this doesn't matter too much.
  2916. (append (cdr c-emacs-variable-inits)
  2917. (cdr c-lang-variable-inits)))))
  2918. ;; This diagnostic message isn't useful for end
  2919. ;; users, so it's disabled.
  2920. ;;(unless (get ',mode 'c-has-warned-lang-consts)
  2921. ;; (message ,(concat "%s compiled with CC Mode %s "
  2922. ;; "but loaded with %s - evaluating "
  2923. ;; "language constants from source")
  2924. ;; ',mode ,c-version c-version)
  2925. ;; (put ',mode 'c-has-warned-lang-consts t))
  2926. (setq source-eval t)
  2927. (let ((init ',(append (cdr c-emacs-variable-inits)
  2928. (cdr c-lang-variable-inits))))
  2929. (dolist (var-init init)
  2930. (setq current-var (car var-init))
  2931. (set (car var-init) (eval (cadr var-init))))))
  2932. (error
  2933. (if current-var
  2934. (message "Eval error in the `c-lang-defvar' or `c-lang-setvar' for `%s'%s: %S"
  2935. current-var
  2936. (if source-eval
  2937. (format "\
  2938. (fallback source eval - %s compiled with CC Mode %s but loaded with %s)"
  2939. ',mode ,c-version c-version)
  2940. "")
  2941. err)
  2942. (signal (car err) (cdr err)))))))
  2943. ;; Being evaluated from source. Always use the dynamic method to
  2944. ;; work well when `c-lang-defvar's in this file are reevaluated
  2945. ;; interactively.
  2946. `(lambda ()
  2947. (require 'cc-langs)
  2948. (let ((c-buffer-is-cc-mode ',mode)
  2949. (init (append (cdr c-emacs-variable-inits)
  2950. (cdr c-lang-variable-inits)))
  2951. current-var)
  2952. (c-make-emacs-variables-local)
  2953. (condition-case err
  2954. (dolist (var-init init)
  2955. (setq current-var (car var-init))
  2956. (set (car var-init) (eval (cadr var-init))))
  2957. (error
  2958. (if current-var
  2959. (message
  2960. "Eval error in the `c-lang-defvar' or `c-lang-setver' for `%s' (source eval): %S"
  2961. current-var err)
  2962. (signal (car err) (cdr err)))))))
  2963. ))
  2964. (defmacro c-init-language-vars (mode)
  2965. "Initialize all the language dependent variables for the given mode.
  2966. This macro is expanded at compile time to a form tailored for the mode
  2967. in question, so MODE must be a constant. Therefore MODE is not
  2968. evaluated and should not be quoted."
  2969. `(funcall ,(c-make-init-lang-vars-fun mode)))
  2970. (cc-provide 'cc-langs)
  2971. ;; Local Variables:
  2972. ;; indent-tabs-mode: t
  2973. ;; tab-width: 8
  2974. ;; End:
  2975. ;;; cc-langs.el ends here