@@ -269,7 +269,29 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
269
269
var cKeywords = "auto if break case register continue return default do sizeof " +
270
270
"static else struct switch extern typedef union for goto while enum const " +
271
271
"volatile inline restrict asm fortran" ;
272
- var cTypes = "int long char short double float unsigned signed void size_t ptrdiff_t" ;
272
+
273
+ // Do not use this. Use the cTypes function below. This is global just to avoid
274
+ // excessive calls when cTypes is being called multiple times during a parse.
275
+ var basicCTypes = words ( "int long char short double float unsigned signed " +
276
+ "void bool" ) ;
277
+
278
+ // Do not use this. Use the objCTypes function below. This is global just to avoid
279
+ // excessive calls when objCTypes is being called multiple times during a parse.
280
+ var basicObjCTypes = words ( "SEL instancetype id Class Protocol BOOL" ) ;
281
+
282
+ // Returns true if identifier is a "C" type.
283
+ // C type is defined as those that are reserved by the compiler (basicTypes),
284
+ // and those that end in _t (Reserved by POSIX for types)
285
+ // http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html
286
+ function cTypes ( identifier ) {
287
+ return contains ( basicCTypes , identifier ) || / .+ _ t / . test ( identifier ) ;
288
+ }
289
+
290
+ // Returns true if identifier is a "Objective C" type.
291
+ function objCTypes ( identifier ) {
292
+ return cTypes ( identifier ) || contains ( basicObjCTypes , identifier ) ;
293
+ }
294
+
273
295
var cBlockKeywords = "case do else for if switch while struct enum union" ;
274
296
var cDefKeywords = "struct enum union" ;
275
297
@@ -383,8 +405,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
383
405
def ( [ "text/x-csrc" , "text/x-c" , "text/x-chdr" ] , {
384
406
name : "clike" ,
385
407
keywords : words ( cKeywords ) ,
386
- types : words ( cTypes + " bool float_t double_t intptr_t intmax_t int8_t int16_t " +
387
- "int32_t int64_t uintptr_t uintmax_t uint8_t uint16_t uint32_t uint64_t" ) ,
408
+ types : cTypes ,
388
409
blockKeywords : words ( cBlockKeywords ) ,
389
410
defKeywords : words ( cDefKeywords ) ,
390
411
typeFirstDefinitions : true ,
@@ -404,7 +425,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
404
425
"this using const_cast public throw virtual delete mutable protected " +
405
426
"alignas alignof constexpr decltype nullptr noexcept thread_local final " +
406
427
"static_assert override" ) ,
407
- types : words ( cTypes + " bool wchar_t" ) ,
428
+ types : cTypes ,
408
429
blockKeywords : words ( cBlockKeywords + " class try catch finally" ) ,
409
430
defKeywords : words ( cDefKeywords + " class namespace" ) ,
410
431
typeFirstDefinitions : true ,
@@ -532,7 +553,6 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
532
553
def ( "text/x-scala" , {
533
554
name : "clike" ,
534
555
keywords : words (
535
-
536
556
/* scala */
537
557
"abstract case catch class def do else extends final finally for forSome if " +
538
558
"implicit import lazy match new null object override package private protected return " +
@@ -730,7 +750,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
730
750
keywords : words ( cKeywords + " as atomic async call command component components configuration event generic " +
731
751
"implementation includes interface module new norace nx_struct nx_union post provides " +
732
752
"signal task uses abstract extends" ) ,
733
- types : words ( cTypes ) ,
753
+ types : cTypes ,
734
754
blockKeywords : words ( cBlockKeywords ) ,
735
755
atoms : words ( "null true false" ) ,
736
756
hooks : { "#" : cppHook } ,
@@ -744,7 +764,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
744
764
"@interface @implementation @end @protocol @encode @property @synthesize @dynamic @class " +
745
765
"@public @package @private @protected @required @optional @try @catch @finally @import " +
746
766
"@selector @encode @defs @synchronized @autoreleasepool @compatibility_alias @available" ) ,
747
- types : words ( cTypes + " instancetype SEL id BOOL IMP Class" ) ,
767
+ types : objCTypes ,
748
768
builtin : words ( "FOUNDATION_EXPORT FOUNDATION_EXTERN NS_INLINE NS_FORMAT_FUNCTION NS_RETURNS_RETAINED " +
749
769
"NS_ERROR_ENUM NS_RETURNS_NOT_RETAINED NS_RETURNS_INNER_POINTER NS_DESIGNATED_INITIALIZER " +
750
770
"NS_ENUM NS_OPTIONS NS_REQUIRES_NIL_TERMINATION NS_ASSUME_NONNULL_BEGIN " +
@@ -753,7 +773,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
753
773
defKeywords : words ( cDefKeywords + " @interface @implementation @protocol @class" ) ,
754
774
dontIndentStatements : / ^ @ .* $ / ,
755
775
typeFirstDefinitions : true ,
756
- atoms : words ( "YES NO NULL Nil nil true false" ) ,
776
+ atoms : words ( "YES NO NULL Nil nil true false nullptr " ) ,
757
777
isReservedIdentifier : cIsReservedIdentifier ,
758
778
hooks : {
759
779
"#" : cppHook ,
@@ -766,7 +786,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
766
786
name : "clike" ,
767
787
keywords : words ( "base break clone continue const default delete enum extends function in class" +
768
788
" foreach local resume return this throw typeof yield constructor instanceof static" ) ,
769
- types : words ( cTypes ) ,
789
+ types : cTypes ,
770
790
blockKeywords : words ( "case catch class else for foreach if switch try while" ) ,
771
791
defKeywords : words ( "function local class" ) ,
772
792
typeFirstDefinitions : true ,
0 commit comments