@@ -270,6 +270,25 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
270
270
"static else struct switch extern typedef union for goto while enum const " +
271
271
"volatile inline restrict asm fortran" ;
272
272
273
+ // Keywords from https://en.cppreference.com/w/cpp/keyword includes C++20.
274
+ var cppKeywords = "alignas alignof and and_eq audit axiom bitand bitor catch " +
275
+ "class compl concept constexpr const_cast decltype delete dynamic_cast " +
276
+ "explicit export final friend import module mutable namespace new noexcept " +
277
+ "not not_eq operator or or_eq override private protected public " +
278
+ "reinterpret_cast requires static_assert static_cast template this " +
279
+ "thread_local throw try typeid typename using virtual xor xor_eq" ;
280
+
281
+ var objCKeywords = "bycopy byref in inout oneway out self super atomic nonatomic retain copy " +
282
+ "readwrite readonly strong weak assign typeof nullable nonnull null_resettable _cmd " +
283
+ "@interface @implementation @end @protocol @encode @property @synthesize @dynamic @class " +
284
+ "@public @package @private @protected @required @optional @try @catch @finally @import " +
285
+ "@selector @encode @defs @synchronized @autoreleasepool @compatibility_alias @available" ;
286
+
287
+ var objCBuiltins = "FOUNDATION_EXPORT FOUNDATION_EXTERN NS_INLINE NS_FORMAT_FUNCTION " +
288
+ " NS_RETURNS_RETAINEDNS_ERROR_ENUM NS_RETURNS_NOT_RETAINED NS_RETURNS_INNER_POINTER " +
289
+ "NS_DESIGNATED_INITIALIZER NS_ENUM NS_OPTIONS NS_REQUIRES_NIL_TERMINATION " +
290
+ "NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_END NS_SWIFT_NAME NS_REFINED_FOR_SWIFT"
291
+
273
292
// Do not use this. Use the cTypes function below. This is global just to avoid
274
293
// excessive calls when cTypes is being called multiple times during a parse.
275
294
var basicCTypes = words ( "int long char short double float unsigned signed " +
@@ -420,13 +439,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
420
439
421
440
def ( [ "text/x-c++src" , "text/x-c++hdr" ] , {
422
441
name : "clike" ,
423
- // Keywords from https://en.cppreference.com/w/cpp/keyword includes C++20.
424
- keywords : words ( cKeywords + "alignas alignof and and_eq audit axiom bitand bitor catch " +
425
- "class compl concept constexpr const_cast decltype delete dynamic_cast " +
426
- "explicit export final friend import module mutable namespace new noexcept " +
427
- "not not_eq operator or or_eq override private protected public " +
428
- "reinterpret_cast requires static_assert static_cast template this " +
429
- "thread_local throw try typeid typename using virtual xor xor_eq" ) ,
442
+ keywords : words ( cKeywords + " " + cppKeywords ) ,
430
443
types : cTypes ,
431
444
blockKeywords : words ( cBlockKeywords + " class try catch" ) ,
432
445
defKeywords : words ( cDefKeywords + " class namespace" ) ,
@@ -769,16 +782,9 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
769
782
770
783
def ( "text/x-objectivec" , {
771
784
name : "clike" ,
772
- keywords : words ( cKeywords + " bycopy byref in inout oneway out self super atomic nonatomic retain copy " +
773
- "readwrite readonly strong weak assign typeof nullable nonnull null_resettable _cmd " +
774
- "@interface @implementation @end @protocol @encode @property @synthesize @dynamic @class " +
775
- "@public @package @private @protected @required @optional @try @catch @finally @import " +
776
- "@selector @encode @defs @synchronized @autoreleasepool @compatibility_alias @available" ) ,
785
+ keywords : words ( cKeywords + " " + objCKeywords ) ,
777
786
types : objCTypes ,
778
- builtin : words ( "FOUNDATION_EXPORT FOUNDATION_EXTERN NS_INLINE NS_FORMAT_FUNCTION NS_RETURNS_RETAINED " +
779
- "NS_ERROR_ENUM NS_RETURNS_NOT_RETAINED NS_RETURNS_INNER_POINTER NS_DESIGNATED_INITIALIZER " +
780
- "NS_ENUM NS_OPTIONS NS_REQUIRES_NIL_TERMINATION NS_ASSUME_NONNULL_BEGIN " +
781
- "NS_ASSUME_NONNULL_END NS_SWIFT_NAME NS_REFINED_FOR_SWIFT" ) ,
787
+ builtin : words ( objCBuiltins ) ,
782
788
blockKeywords : words ( cBlockKeywords + " @synthesize @try @catch @finally @autoreleasepool @synchronized" ) ,
783
789
defKeywords : words ( cDefKeywords + " @interface @implementation @protocol @class" ) ,
784
790
dontIndentStatements : / ^ @ .* $ / ,
@@ -792,6 +798,46 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
792
798
modeProps : { fold : [ "brace" , "include" ] }
793
799
} ) ;
794
800
801
+ def ( "text/x-objectivec++" , {
802
+ name : "clike" ,
803
+ keywords : words ( cKeywords + " " + objCKeywords + " " + cppKeywords ) ,
804
+ types : objCTypes ,
805
+ builtin : words ( objCBuiltins ) ,
806
+ blockKeywords : words ( cBlockKeywords + " @synthesize @try @catch @finally @autoreleasepool @synchronized class try catch" ) ,
807
+ defKeywords : words ( cDefKeywords + " @interface @implementation @protocol @class class namespace" ) ,
808
+ dontIndentStatements : / ^ @ .* $ | ^ t e m p l a t e $ / ,
809
+ typeFirstDefinitions : true ,
810
+ atoms : words ( "YES NO NULL Nil nil true false nullptr" ) ,
811
+ isReservedIdentifier : cIsReservedIdentifier ,
812
+ hooks : {
813
+ "#" : cppHook ,
814
+ "*" : pointerHook ,
815
+ "u" : cpp11StringHook ,
816
+ "U" : cpp11StringHook ,
817
+ "L" : cpp11StringHook ,
818
+ "R" : cpp11StringHook ,
819
+ "0" : cpp14Literal ,
820
+ "1" : cpp14Literal ,
821
+ "2" : cpp14Literal ,
822
+ "3" : cpp14Literal ,
823
+ "4" : cpp14Literal ,
824
+ "5" : cpp14Literal ,
825
+ "6" : cpp14Literal ,
826
+ "7" : cpp14Literal ,
827
+ "8" : cpp14Literal ,
828
+ "9" : cpp14Literal ,
829
+ token : function ( stream , state , style ) {
830
+ if ( style == "variable" && stream . peek ( ) == "(" &&
831
+ ( state . prevToken == ";" || state . prevToken == null ||
832
+ state . prevToken == "}" ) &&
833
+ cppLooksLikeConstructor ( stream . current ( ) ) )
834
+ return "def" ;
835
+ }
836
+ } ,
837
+ namespaceSeparator : "::" ,
838
+ modeProps : { fold : [ "brace" , "include" ] }
839
+ } ) ;
840
+
795
841
def ( "text/x-squirrel" , {
796
842
name : "clike" ,
797
843
keywords : words ( "base break clone continue const default delete enum extends function in class" +
0 commit comments