--- name: C fileTypes: - c - h firstLineMatch: -[*]-( Mode:)? C -[*]- scopeName: source.c repository: pragma-mark: name: meta.section captures: "1": name: meta.preprocessor.c "2": name: keyword.control.import.pragma.c "3": name: meta.toc-list.pragma-mark.c match: ^\s*(#\s*(pragma\s+mark)\s+(.*)) preprocessor-rule-enabled: captures: "1": name: meta.preprocessor.c "2": name: keyword.control.import.if.c "3": name: constant.numeric.preprocessor.c begin: ^\s*(#(if)\s+(0*1)\b) end: ^\s*(#\s*(endif)\b) patterns: - captures: "1": name: meta.preprocessor.c "2": name: keyword.control.import.else.c begin: | ^\s*(#\s*(else)\b).* contentName: comment.block.preprocessor.else-branch end: (?=^\s*#\s*endif\b.*$) patterns: - include: "#disabled" - include: "#pragma-mark" - begin: "" end: (?=^\s*#\s*(else|endif)\b.*$) patterns: - include: $base string_escaped_char: patterns: - name: constant.character.escape.c match: \\(\\|[abefnprtv'"?]|[0-3]\d{,2}|[4-7]\d?|x[a-fA-F0-9]{,2}) - name: invalid.illegal.unknown-escape.c match: \\. disabled: begin: ^\s*#\s*if(n?def)?\b.*$ end: ^\s*#\s*endif\b.*$ patterns: - include: "#disabled" - include: "#pragma-mark" comment: eat nested preprocessor if(def)s preprocessor-rule-other: captures: "1": name: meta.preprocessor.c "2": name: keyword.control.import.c begin: ^\s*(#\s*(if(n?def)?)\b.*?(?:(?=(?://|/\*))|$)) end: ^\s*(#\s*(endif)\b).*$ patterns: - include: $base preprocessor-rule-disabled: captures: "1": name: meta.preprocessor.c "2": name: keyword.control.import.if.c "3": name: constant.numeric.preprocessor.c begin: | ^\s*(#(if)\s+(0)\b).* end: ^\s*(#\s*(endif)\b) patterns: - captures: "1": name: meta.preprocessor.c "2": name: keyword.control.import.else.c begin: ^\s*(#\s*(else)\b) end: (?=^\s*#\s*endif\b.*$) patterns: - include: $base - name: comment.block.preprocessor.if-branch begin: "" end: (?=^\s*#\s*(else|endif)\b.*$) patterns: - include: "#disabled" - include: "#pragma-mark" 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" - name: invalid.illegal.placeholder.c match: "%" uuid: 25066DC2-6B1D-11D9-9D5B-000D93589AF6 foldingStartMarker: "(?x)\n\ \t\t /\\*\\*(?!\\*)\n\ \t\t|^(?![^{]*?//|[^{]*?/\\*(?!.*?\\*/.*?\\{)).*?\\{\\s*($|//|/\\*(?!.*?\\*/.*\\S))\n\ \t" patterns: - include: "#preprocessor-rule-enabled" - include: "#preprocessor-rule-disabled" - include: "#preprocessor-rule-other" - name: comment.block.c captures: "0": name: punctuation.definition.comment.c begin: /\* end: \*/ - name: comment.line.double-slash.c++ begin: // beginCaptures: "0": name: punctuation.definition.comment.c end: $\n? patterns: - name: punctuation.separator.continuation.c++ match: (?>\\\s*\n) - 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 comment: common C constant naming idiom -- kConstantVariable - 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 - name: keyword.operator.sizeof.c match: \b(sizeof)\b - name: constant.numeric.c match: \b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\b - name: string.quoted.double.c endCaptures: "0": name: punctuation.definition.string.end.c begin: "\"" beginCaptures: "0": name: punctuation.definition.string.begin.c end: "\"" patterns: - include: "#string_escaped_char" - include: "#string_placeholder" - name: string.quoted.single.c endCaptures: "0": name: punctuation.definition.string.end.c begin: "'" beginCaptures: "0": name: punctuation.definition.string.begin.c end: "'" patterns: - include: "#string_escaped_char" - name: meta.preprocessor.macro.c begin: "(?x)\n\ \t\t\t\t^\\s*\\#\\s*(define)\\s+ # define\n\ \t\t\t\t((?[a-zA-Z_][a-zA-Z0-9_]*)) # macro name\n\ \t\t\t\t(?: # and optionally:\n\ \t\t\t\t (\\() # an open parenthesis\n\ \t\t\t\t (\n\ \t\t\t\t \\s* \\g \\s* # first argument\n\ \t\t\t\t ((,) \\s* \\g \\s*)* # additional arguments\n\ \t\t\t\t (?:\\.\\.\\.)? # varargs ellipsis?\n\ \t\t\t\t )\n\ \t\t\t\t (\\)) # a close parenthesis\n\ \t\t\t\t)?\n\ \t\t\t" beginCaptures: "7": name: punctuation.separator.parameters.c "8": name: punctuation.definition.parameters.c "1": name: keyword.control.import.define.c "2": name: entity.name.function.preprocessor.c "4": name: punctuation.definition.parameters.c "5": name: variable.parameter.preprocessor.c end: (?=(?://|/\*))|$ patterns: - name: punctuation.separator.continuation.c match: (?>\\\s*\n) - include: $base - name: meta.preprocessor.diagnostic.c captures: "1": name: keyword.control.import.error.c begin: ^\s*#\s*(error|warning)\b end: $ patterns: - name: punctuation.separator.continuation.c match: (?>\\\s*\n) - name: meta.preprocessor.c.include captures: "1": name: keyword.control.import.include.c begin: ^\s*#\s*(include|import)\b\s+ end: (?=(?://|/\*))|$ patterns: - name: punctuation.separator.continuation.c match: (?>\\\s*\n) - name: string.quoted.double.include.c endCaptures: "0": name: punctuation.definition.string.end.c begin: "\"" beginCaptures: "0": name: punctuation.definition.string.begin.c end: "\"" - name: string.quoted.other.lt-gt.include.c endCaptures: "0": name: punctuation.definition.string.end.c begin: < beginCaptures: "0": name: punctuation.definition.string.begin.c end: ">" - include: "#pragma-mark" - name: meta.preprocessor.c captures: "1": name: keyword.control.import.c begin: ^\s*#\s*(define|defined|elif|else|if|ifdef|ifndef|line|pragma|undef)\b end: (?=(?://|/\*))|$ patterns: - name: punctuation.separator.continuation.c match: (?>\\\s*\n) - name: support.type.sys-types.c match: \b(u_char|u_short|u_int|u_long|ushort|uint|u_quad_t|quad_t|qaddr_t|caddr_t|daddr_t|dev_t|fixpt_t|blkcnt_t|blksize_t|gid_t|in_addr_t|in_port_t|ino_t|key_t|mode_t|nlink_t|id_t|pid_t|off_t|segsz_t|swblk_t|uid_t|id_t|clock_t|size_t|ssize_t|time_t|useconds_t|suseconds_t)\b - name: support.type.pthread.c match: \b(pthread_attr_t|pthread_cond_t|pthread_condattr_t|pthread_mutex_t|pthread_mutexattr_t|pthread_once_t|pthread_rwlock_t|pthread_rwlockattr_t|pthread_t|pthread_key_t)\b - name: support.type.stdint.c match: \b(int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|int_least8_t|int_least16_t|int_least32_t|int_least64_t|uint_least8_t|uint_least16_t|uint_least32_t|uint_least64_t|int_fast8_t|int_fast16_t|int_fast32_t|int_fast64_t|uint_fast8_t|uint_fast16_t|uint_fast32_t|uint_fast64_t|intptr_t|uintptr_t|intmax_t|intmax_t|uintmax_t|uintmax_t)\b - name: support.constant.mac-classic.c match: \b(noErr|kNilOptions|kInvalidID|kVariableLengthArray)\b - name: support.type.mac-classic.c match: \b(AbsoluteTime|Boolean|Byte|ByteCount|ByteOffset|BytePtr|CompTimeValue|ConstLogicalAddress|ConstStrFileNameParam|ConstStringPtr|Duration|Fixed|FixedPtr|Float32|Float32Point|Float64|Float80|Float96|FourCharCode|Fract|FractPtr|Handle|ItemCount|LogicalAddress|OptionBits|OSErr|OSStatus|OSType|OSTypePtr|PhysicalAddress|ProcessSerialNumber|ProcessSerialNumberPtr|ProcHandle|Ptr|ResType|ResTypePtr|ShortFixed|ShortFixedPtr|SignedByte|SInt16|SInt32|SInt64|SInt8|Size|StrFileName|StringHandle|StringPtr|TimeBase|TimeRecord|TimeScale|TimeValue|TimeValue64|UInt16|UInt32|UInt64|UInt8|UniChar|UniCharCount|UniCharCountPtr|UniCharPtr|UnicodeScalarValue|UniversalProcHandle|UniversalProcPtr|UnsignedFixed|UnsignedFixedPtr|UnsignedWide|UTF16Char|UTF32Char|UTF8Char)\b - name: support.function.C99.c match: \b(hypot(f|l)?|s(scanf|ystem|nprintf|ca(nf|lb(n(f|l)?|ln(f|l)?))|i(n(h(f|l)?|f|l)?|gn(al|bit))|tr(s(tr|pn)|nc(py|at|mp)|c(spn|hr|oll|py|at|mp)|to(imax|d|u(l(l)?|max)|k|f|l(d|l)?)|error|pbrk|ftime|len|rchr|xfrm)|printf|et(jmp|vbuf|locale|buf)|qrt(f|l)?|w(scanf|printf)|rand)|n(e(arbyint(f|l)?|xt(toward(f|l)?|after(f|l)?))|an(f|l)?)|c(s(in(h(f|l)?|f|l)?|qrt(f|l)?)|cos(h(f)?|f|l)?|imag(f|l)?|t(ime|an(h(f|l)?|f|l)?)|o(s(h(f|l)?|f|l)?|nj(f|l)?|pysign(f|l)?)|p(ow(f|l)?|roj(f|l)?)|e(il(f|l)?|xp(f|l)?)|l(o(ck|g(f|l)?)|earerr)|a(sin(h(f|l)?|f|l)?|cos(h(f|l)?|f|l)?|tan(h(f|l)?|f|l)?|lloc|rg(f|l)?|bs(f|l)?)|real(f|l)?|brt(f|l)?)|t(ime|o(upper|lower)|an(h(f|l)?|f|l)?|runc(f|l)?|gamma(f|l)?|mp(nam|file))|i(s(space|n(ormal|an)|cntrl|inf|digit|u(nordered|pper)|p(unct|rint)|finite|w(space|c(ntrl|type)|digit|upper|p(unct|rint)|lower|al(num|pha)|graph|xdigit|blank)|l(ower|ess(equal|greater)?)|al(num|pha)|gr(eater(equal)?|aph)|xdigit|blank)|logb(f|l)?|max(div|abs))|di(v|fftime)|_Exit|unget(c|wc)|p(ow(f|l)?|ut(s|c(har)?|wc(har)?)|error|rintf)|e(rf(c(f|l)?|f|l)?|x(it|p(2(f|l)?|f|l|m1(f|l)?)?))|v(s(scanf|nprintf|canf|printf|w(scanf|printf))|printf|f(scanf|printf|w(scanf|printf))|w(scanf|printf)|a_(start|copy|end|arg))|qsort|f(s(canf|e(tpos|ek))|close|tell|open|dim(f|l)?|p(classify|ut(s|c|w(s|c))|rintf)|e(holdexcept|set(e(nv|xceptflag)|round)|clearexcept|testexcept|of|updateenv|r(aiseexcept|ror)|get(e(nv|xceptflag)|round))|flush|w(scanf|ide|printf|rite)|loor(f|l)?|abs(f|l)?|get(s|c|pos|w(s|c))|re(open|e|ad|xp(f|l)?)|m(in(f|l)?|od(f|l)?|a(f|l|x(f|l)?)?))|l(d(iv|exp(f|l)?)|o(ngjmp|cal(time|econv)|g(1(p(f|l)?|0(f|l)?)|2(f|l)?|f|l|b(f|l)?)?)|abs|l(div|abs|r(int(f|l)?|ound(f|l)?))|r(int(f|l)?|ound(f|l)?)|gamma(f|l)?)|w(scanf|c(s(s(tr|pn)|nc(py|at|mp)|c(spn|hr|oll|py|at|mp)|to(imax|d|u(l(l)?|max)|k|f|l(d|l)?|mbs)|pbrk|ftime|len|r(chr|tombs)|xfrm)|to(b|mb)|rtomb)|printf|mem(set|c(hr|py|mp)|move))|a(s(sert|ctime|in(h(f|l)?|f|l)?)|cos(h(f|l)?|f|l)?|t(o(i|f|l(l)?)|exit|an(h(f|l)?|2(f|l)?|f|l)?)|b(s|ort))|g(et(s|c(har)?|env|wc(har)?)|mtime)|r(int(f|l)?|ound(f|l)?|e(name|alloc|wind|m(ove|quo(f|l)?|ainder(f|l)?))|a(nd|ise))|b(search|towc)|m(odf(f|l)?|em(set|c(hr|py|mp)|move)|ktime|alloc|b(s(init|towcs|rtowcs)|towc|len|r(towc|len))))\b - name: meta.function.c endCaptures: "0": name: punctuation.definition.parameters.c begin: "(?x)\n\ \t\t\t\t(?: ^ # begin-of-line\n\ \t\t\t\t | \n\ \t\t\t\t (?: (?= \\s ) (?])\\s* # or type modifier before name\n\ \t\t\t\t )\n\ \t\t\t\t)\n\ \t\t\t\t(\n\ \t\t\t\t\t([A-Za-z_][A-Za-z0-9_]|::)* # actual name\n\ \t\t\t\t\t(?: (?<=operator) (?: [-*&<>=+!]+ | \\(\\) | \\[\\] ) )? # if it is a C++ operator\n\ \t\t\t\t)\n\ \t\t\t\t \\s*(\\() (?= # match \"(\"\n\ \t\t\t\t (? [^()]++ | \\( \\g*+ \\) )*+ # function arguments\n\ \t\t\t\t \\) \t\t # match \")\"\n\ \t\t\t\t (\\s+const)?\\s* # optional const modifier\n\ \t\t\t\t (\\{|\\n|//|/\\*)) # start bracket or end-of-line\n\ \t\t\t" beginCaptures: "1": name: entity.name.function.c "2": name: punctuation.definition.parameters.c end: \) patterns: - include: $base - name: meta.function.prototype.c endCaptures: "0": name: punctuation.definition.parameters.c begin: "(?x)\n\ \t\t\t\t(?: ^ # begin-of-line\n\ \t\t\t\t | (?: (?= \\s ) (?=+!]+ | \\(\\) | \\[\\] ) )? # if it is a C++ operator\n\ \t\t\t\t)\n\ \t\t\t\t \\s+(\\() (?= # match \"(\"\n\ \t\t\t\t (? [^()]++ | \\( \\g*+ \\) )*+ # function arguments\n\ \t\t\t\t \\) # match \")\"\n\ \t\t\t\t (\\s+const)?\\s* # optional const modifier\n\ \t\t\t\t ;) # terminating semi-colon\n\ \t\t\t" beginCaptures: "1": name: entity.name.function.c "2": name: punctuation.definition.parameters.c end: \) patterns: - include: $base foldingStopMarker: (?