{ "name": "C", "scopeName": "source.c", "patterns": [ { "include": "#preprocessor-rule-enabled" }, { "include": "#preprocessor-rule-disabled" }, { "include": "#preprocessor-rule-other" }, { "include": "#comments" }, { "include": "source.c.platform" }, { "name": "keyword.control.c", "match": "\\b(break|case|continue|default|do|else|for|goto|if|_Pragma|return|switch|while)\\b" }, { "name": "storage.type.c", "match": "\\b(asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void)\\b" }, { "name": "storage.modifier.c", "match": "\\b(const|extern|register|restrict|static|volatile|inline)\\b" }, { "name": "constant.other.variable.mac-classic.c", "match": "\\bk[A-Z]\\w*\\b" }, { "name": "variable.other.readwrite.global.mac-classic.c", "match": "\\bg[A-Z]\\w*\\b" }, { "name": "variable.other.readwrite.static.mac-classic.c", "match": "\\bs[A-Z]\\w*\\b" }, { "name": "constant.language.c", "match": "\\b(NULL|true|false|TRUE|FALSE)\\b" }, { "include": "#sizeof" }, { "name": "constant.numeric.c", "match": "(?x)\\b\n\t\t\t( (?i:\n\t\t\t 0x ( [0-9A-Fa-f]+ ( ' [0-9A-Fa-f]+ )* )? # Hexadecimal\n\t\t\t | 0b ( [0-1]+ ( ' [0-1]+ )* )? # Binary\n\t\t\t | 0 ( [0-7]+ ( ' [0-7]+ )* ) # Octal\n\t\t\t | ( [0-9]+ ( ' [0-9]+ )* ) # Decimal\n\t\t\t )\n\t\t\t ( ([uUfF] | u?ll? | U?LL?)\\b | (?\u003cinc\u003e') | \\b )\n\t\t\t| ( [0-9]+ ( ' [0-9]+ )* )?\n\t\t\t (?i:\n\t\t\t \\. ( [0-9]+ ( ' [0-9]+ )* ) E(\\+|-)? ( [0-9]+ ( ' [0-9]+ )* )\n\t\t\t | \\. ( [0-9]+ ( ' [0-9]+ )* )\n\t\t\t | E(\\+|-)? ( [0-9]+ ( ' [0-9]+ )* )\n\t\t\t )\n\t\t\t ( (?\u003cinc\u003e') | \\b )\n\t\t\t)", "captures": { "inc": { "name": "invalid.illegal.digit-separator-should-not-be-last.c++" } } }, { "name": "string.quoted.double.c", "begin": "\"", "end": "\"", "patterns": [ { "include": "#string_escaped_char" }, { "include": "#string_placeholder" } ], "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.c" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.c" } } }, { "name": "string.quoted.single.c", "begin": "'", "end": "'", "patterns": [ { "include": "#string_escaped_char" } ], "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.c" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.c" } } }, { "name": "meta.preprocessor.macro.c", "begin": "(?x)\n \t\t^\\s*\\#\\s*(define)\\s+ # define\n \t\t((?\u003cid\u003e[a-zA-Z_][a-zA-Z0-9_]*)) # macro name\n \t\t(?: # and optionally:\n \t\t (\\() # an open parenthesis\n \t\t (\n \t\t \\s* \\g\u003cid\u003e \\s* # first argument\n \t\t ((,) \\s* \\g\u003cid\u003e \\s*)* # additional arguments\n \t\t (?:\\.\\.\\.)? # varargs ellipsis?\n \t\t )\n \t\t (\\)) # a close parenthesis\n \t\t)?\n \t", "end": "(?=(?://|/\\*))|$", "patterns": [ { "name": "punctuation.separator.continuation.c", "match": "(?\u003e\\\\\\s*\\n)" }, { "include": "$base" } ], "beginCaptures": { "1": { "name": "keyword.control.import.define.c" }, "2": { "name": "entity.name.function.preprocessor.c" }, "4": { "name": "punctuation.definition.parameters.begin.c" }, "5": { "name": "variable.parameter.preprocessor.c" }, "7": { "name": "punctuation.separator.parameters.c" }, "8": { "name": "punctuation.definition.parameters.end.c" } } }, { "name": "meta.preprocessor.diagnostic.c", "begin": "^\\s*#\\s*(error|warning)\\b", "end": "$", "patterns": [ { "name": "punctuation.separator.continuation.c", "match": "(?\u003e\\\\\\s*\\n)" } ], "captures": { "1": { "name": "keyword.control.import.error.c" } } }, { "name": "meta.preprocessor.c.include", "begin": "^\\s*#\\s*(include|import)\\b", "end": "(?=(?://|/\\*))|$", "patterns": [ { "name": "punctuation.separator.continuation.c", "match": "(?\u003e\\\\\\s*\\n)" }, { "name": "string.quoted.double.include.c", "begin": "\"", "end": "\"", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.c" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.c" } } }, { "name": "string.quoted.other.lt-gt.include.c", "begin": "\u003c", "end": "\u003e", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.c" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.c" } } } ], "captures": { "1": { "name": "keyword.control.import.include.c" } } }, { "include": "#pragma-mark" }, { "name": "meta.preprocessor.c", "begin": "^\\s*#\\s*(define|defined|elif|else|if|ifdef|ifndef|line|pragma|undef)\\b", "end": "(?=(?://|/\\*))|$", "patterns": [ { "name": "punctuation.separator.continuation.c", "match": "(?\u003e\\\\\\s*\\n)" } ], "captures": { "1": { "name": "keyword.control.import.c" } } }, { "name": "support.type.posix-reserved.c", "match": "\\b([a-z0-9_]+_t)\\b" }, { "include": "#block" }, { "name": "meta.function.c", "begin": "(?x)\n \t\t(?: ^ # begin-of-line\n \t\t | \n \t\t (?: (?= \\s ) (?\u003c!else|new|return) (?\u003c=\\w) # or word + space before name\n \t\t | (?= \\s*[A-Za-z_] ) (?\u003c!\u0026\u0026) (?\u003c=[*\u0026\u003e]) # or type modifier before name\n \t\t )\n \t\t)\n \t\t(\\s*) (?!(while|for|do|if|else|switch|catch|enumerate|return|sizeof|[cr]?iterate)\\s*\\()\n \t\t(\n \t\t\t(?: [A-Za-z_][A-Za-z0-9_]*+ | :: )++ | # actual name\n \t\t\t(?: (?\u003c=operator) (?: [-*\u0026\u003c\u003e=+!]+ | \\(\\) | \\[\\] ) ) # if it is a C++ operator\n \t\t)\n \t\t \\s*(?=\\()", "end": "(?\u003c=\\})|(?=#)|(;)", "patterns": [ { "include": "#comments" }, { "include": "#parens" }, { "name": "storage.modifier.$1.c++", "match": "\\b(const|final|override|noexcept)\\b" }, { "include": "#block" } ], "beginCaptures": { "1": { "name": "punctuation.whitespace.function.leading.c" }, "3": { "name": "entity.name.function.c" }, "4": { "name": "punctuation.definition.parameters.c" } } } ], "repository": { "access": { "match": "(\\.)([a-zA-Z_][a-zA-Z_0-9]*)\\b(?!\\s*\\()", "captures": { "1": { "name": "punctuation.separator.variable-access.c" }, "2": { "name": "variable.other.dot-access.c" } } }, "block": { "patterns": [ { "name": "meta.block.c", "begin": "\\{", "end": "\\}", "patterns": [ { "include": "#block_innards" } ], "beginCaptures": { "0": { "name": "punctuation.section.block.begin.c" } }, "endCaptures": { "0": { "name": "punctuation.section.block.end.c" } } } ] }, "block_innards": { "patterns": [ { "include": "#preprocessor-rule-enabled-block" }, { "include": "#preprocessor-rule-disabled-block" }, { "include": "#preprocessor-rule-other-block" }, { "include": "#sizeof" }, { "include": "#access" }, { "include": "source.c.platform#functions" }, { "include": "#c_function_call" }, { "name": "meta.initialization.c", "match": "(?x)\n\t\t\t (?x)\n\t\t\t(?: \n\t\t\t (?: (?= \\s ) (?\u003c!else|new|return) (?\u003c=\\w)\\s+ # or word + space before name\n\t\t\t )\n\t\t\t)\n\t\t\t(\n\t\t\t\t(?: [A-Za-z_][A-Za-z0-9_]*+ | :: )++ | # actual name\n\t\t\t\t(?: (?\u003c=operator) (?: [-*\u0026\u003c\u003e=+!]+ | \\(\\) | \\[\\] ) )? # if it is a C++ operator\n\t\t\t)\n\t\t\t \\s*(\\()", "captures": { "1": { "name": "variable.other.c" }, "2": { "name": "punctuation.definition.parameters.c" } } }, { "include": "#block" }, { "include": "$base" } ] }, "c_function_call": { "name": "meta.function-call.c", "match": "(?x) (?: (?= \\s ) (?:(?\u003c=else|new|return) | (?\u003c!\\w)) (\\s+))?\n\t\t\t(\\b \n\t\t\t\t(?!(while|for|do|if|else|switch|catch|enumerate|return|sizeof|[cr]?iterate)\\s*\\()(?:(?!NS)[A-Za-z_][A-Za-z0-9_]*+\\b | :: )++ # actual name\n\t\t\t)\n\t\t\t \\s*(\\()", "captures": { "1": { "name": "punctuation.whitespace.function-call.leading.c" }, "2": { "name": "support.function.any-method.c" }, "3": { "name": "punctuation.definition.parameters.c" } } }, "comments": { "patterns": [ { "name": "comment.block.c", "match": "^/\\* =(\\s*.*?)\\s*= \\*/$\\n?", "captures": { "1": { "name": "meta.toc-list.banner.block.c" } } }, { "name": "comment.block.c", "begin": "/\\*", "end": "\\*/", "beginCaptures": { "0": { "name": "punctuation.definition.comment.begin.c" } }, "endCaptures": { "0": { "name": "punctuation.definition.comment.end.c" } } }, { "name": "invalid.illegal.stray-comment-end.c", "match": "\\*/.*\\n" }, { "name": "comment.line.banner.c++", "match": "^// =(\\s*.*?)\\s*=\\s*$\\n?", "captures": { "1": { "name": "meta.toc-list.banner.line.c" } } }, { "begin": "(^[ \\t]+)?(?=//)", "end": "(?!\\G)", "patterns": [ { "name": "comment.line.double-slash.c++", "begin": "//", "end": "\\n", "patterns": [ { "name": "punctuation.separator.continuation.c++", "match": "(?\u003e\\\\\\s*\\n)" } ], "beginCaptures": { "0": { "name": "punctuation.definition.comment.c++" } } } ], "beginCaptures": { "1": { "name": "punctuation.whitespace.comment.leading.c++" } } } ] }, "disabled": { "begin": "^\\s*#\\s*if(n?def)?\\b.*$", "end": "^\\s*#\\s*endif\\b", "patterns": [ { "include": "#disabled" }, { "include": "#pragma-mark" } ] }, "parens": { "name": "meta.parens.c", "begin": "\\(", "end": "\\)", "patterns": [ { "include": "$base" } ], "beginCaptures": { "0": { "name": "punctuation.section.parens.begin.c" } }, "endCaptures": { "0": { "name": "punctuation.section.parens.end.c" } } }, "pragma-mark": { "name": "meta.section", "match": "^\\s*(#\\s*(pragma\\s+mark)\\s+(.*))", "captures": { "1": { "name": "meta.preprocessor.c" }, "2": { "name": "keyword.control.import.pragma.c" }, "3": { "name": "meta.toc-list.pragma-mark.c" } } }, "preprocessor-rule-disabled": { "begin": "^\\s*(#(if)\\s+(0)\\b).*", "end": "^\\s*(#\\s*(endif)\\b)", "patterns": [ { "begin": "^\\s*(#\\s*(else)\\b)", "end": "(?=^\\s*#\\s*endif\\b)", "patterns": [ { "include": "$base" } ], "captures": { "1": { "name": "meta.preprocessor.c" }, "2": { "name": "keyword.control.import.else.c" } } }, { "name": "comment.block.preprocessor.if-branch", "end": "(?=^\\s*#\\s*(else|endif)\\b)", "patterns": [ { "include": "#disabled" }, { "include": "#pragma-mark" } ] } ], "captures": { "1": { "name": "meta.preprocessor.c" }, "2": { "name": "keyword.control.import.if.c" }, "3": { "name": "constant.numeric.preprocessor.c" } } }, "preprocessor-rule-disabled-block": { "begin": "^\\s*(#(if)\\s+(0)\\b).*", "end": "^\\s*(#\\s*(endif)\\b)", "patterns": [ { "begin": "^\\s*(#\\s*(else)\\b)", "end": "(?=^\\s*#\\s*endif\\b)", "patterns": [ { "include": "#block_innards" } ], "captures": { "1": { "name": "meta.preprocessor.c" }, "2": { "name": "keyword.control.import.else.c" } } }, { "name": "comment.block.preprocessor.if-branch.in-block", "end": "(?=^\\s*#\\s*(else|endif)\\b)", "patterns": [ { "include": "#disabled" }, { "include": "#pragma-mark" } ] } ], "captures": { "1": { "name": "meta.preprocessor.c" }, "2": { "name": "keyword.control.import.if.c" }, "3": { "name": "constant.numeric.preprocessor.c" } } }, "preprocessor-rule-enabled": { "begin": "^\\s*(#(if)\\s+(0*1)\\b)", "end": "^\\s*(#\\s*(endif)\\b)", "patterns": [ { "contentName": "comment.block.preprocessor.else-branch", "begin": "^\\s*(#\\s*(else)\\b).*", "end": "(?=^\\s*#\\s*endif\\b)", "patterns": [ { "include": "#disabled" }, { "include": "#pragma-mark" } ], "captures": { "1": { "name": "meta.preprocessor.c" }, "2": { "name": "keyword.control.import.else.c" } } }, { "end": "(?=^\\s*#\\s*(else|endif)\\b)", "patterns": [ { "include": "$base" } ] } ], "captures": { "1": { "name": "meta.preprocessor.c" }, "2": { "name": "keyword.control.import.if.c" }, "3": { "name": "constant.numeric.preprocessor.c" } } }, "preprocessor-rule-enabled-block": { "begin": "^\\s*(#(if)\\s+(0*1)\\b)", "end": "^\\s*(#\\s*(endif)\\b)", "patterns": [ { "contentName": "comment.block.preprocessor.else-branch.in-block", "begin": "^\\s*(#\\s*(else)\\b).*", "end": "(?=^\\s*#\\s*endif\\b)", "patterns": [ { "include": "#disabled" }, { "include": "#pragma-mark" } ], "captures": { "1": { "name": "meta.preprocessor.c" }, "2": { "name": "keyword.control.import.else.c" } } }, { "end": "(?=^\\s*#\\s*(else|endif)\\b)", "patterns": [ { "include": "#block_innards" } ] } ], "captures": { "1": { "name": "meta.preprocessor.c" }, "2": { "name": "keyword.control.import.if.c" }, "3": { "name": "constant.numeric.preprocessor.c" } } }, "preprocessor-rule-other": { "begin": "^\\s*(#\\s*(if(n?def)?)\\b.*?(?:(?=(?://|/\\*))|$))", "end": "^\\s*(#\\s*(endif)\\b)", "patterns": [ { "include": "$base" } ], "captures": { "1": { "name": "meta.preprocessor.c" }, "2": { "name": "keyword.control.import.c" } } }, "preprocessor-rule-other-block": { "begin": "^\\s*(#\\s*(if(n?def)?)\\b.*?(?:(?=(?://|/\\*))|$))", "end": "^\\s*(#\\s*(endif)\\b)", "patterns": [ { "include": "#block_innards" } ], "captures": { "1": { "name": "meta.preprocessor.c" }, "2": { "name": "keyword.control.import.c" } } }, "sizeof": { "name": "keyword.operator.sizeof.c", "match": "\\b(sizeof)\\b" }, "string_escaped_char": { "patterns": [ { "name": "constant.character.escape.c", "match": "\\\\(\\\\|[abefnprtv'\"?]|[0-3]\\d{0,2}|[4-7]\\d?|x[a-fA-F0-9]{0,2}|u[a-fA-F0-9]{0,4}|U[a-fA-F0-9]{0,8})" }, { "name": "invalid.illegal.unknown-escape.c", "match": "\\\\." } ] }, "string_placeholder": { "patterns": [ { "name": "constant.other.placeholder.c", "match": "(?x)%\n \t\t\t\t\t\t(\\d+\\$)? # field (argument #)\n \t\t\t\t\t\t[#0\\- +']* # flags\n \t\t\t\t\t\t[,;:_]? # separator character (AltiVec)\n \t\t\t\t\t\t((-?\\d+)|\\*(-?\\d+\\$)?)? # minimum field width\n \t\t\t\t\t\t(\\.((-?\\d+)|\\*(-?\\d+\\$)?)?)? # precision\n \t\t\t\t\t\t(hh|h|ll|l|j|t|z|q|L|vh|vl|v|hv|hl)? # length modifier\n \t\t\t\t\t\t[diouxXDOUeEfFgGaACcSspn%] # conversion type\n \t\t\t\t\t" } ] } } }