Last active
November 26, 2018 23:23
-
-
Save evgenyneu/57bb61317b9b2d24311a05a6ec13e262 to your computer and use it in GitHub Desktop.
Syntax file for Yorick language for Sublime Text 3. Copy the file into "Sublime Text 3/Packages/User/" directory. Credit https://github.com/facelessuser/sublime-languages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%YAML 1.2 | |
--- | |
# http://www.sublimetext.com/docs/3/syntax.html | |
name: C/C++(11) | |
file_extensions: | |
- i | |
first_line_match: |- | |
(?x) | |
-[*]-( Mode:)? C -[*]- | |
| | |
-\*- C\+\+ -\*- | |
scope: source.i | |
contexts: | |
main: | |
- include: comments | |
- include: preprocessor-rule-enabled | |
- include: preprocessor-rule-disabled | |
- include: preprocessor-rule-other | |
- include: pragma-mark | |
- include: disabled | |
- match: (R|Ru|RU|uR|UR)(\"\+\*\()\.* | |
captures: | |
1: prefix | |
2: begin | |
push: | |
- meta_scope: raw.string.ccpp | |
- match: (\)\+\*\") | |
captures: | |
0: end | |
pop: true | |
- include: comments | |
- match: (R|Ru|RU|uR|UR)(\"\()\.* | |
captures: | |
1: prefix | |
2: begin | |
push: | |
- meta_scope: raw.string.ccpp | |
- match: (\)\") | |
captures: | |
0: end | |
pop: true | |
- include: comments | |
- match: '(\:)\s*(\w+\(\w+\))+(?:\s*(?:/\*|//|\{))' | |
captures: | |
1: begin | |
2: variable | |
push: | |
- meta_scope: member.initializer | |
- match: '\{' | |
captures: | |
0: open.curly.bracket.block | |
pop: true | |
- include: comments | |
- match: \b(break|case|continue|default|do|else|for|goto|if|_Pragma|return|switch|while)\b | |
scope: keyword.control.c | |
- match: \b(catch|operator|try|throw|using|namespace)\b | |
scope: keyword.control.c++ | |
- match: '\bdelete\b(\s*\[\])?|\bnew\b(?!])' | |
scope: keyword.control.c++ | |
- match: \b(and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|typeid|xor|xor_eq)\b | |
scope: keyword.operator.c++ | |
- match: \b(const_cast|dynamic_cast|reinterpret_cast|static_cast)\b\s* | |
scope: keyword.operator.cast.c++ | |
- match: \b(asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|_Imaginary|string|int|long|short|signed|struct|typedef|union|unsigned|void)\b | |
scope: storage.type.c | |
- match: \b(class|wchar_t|nullptr_t)\b | |
scope: storage.type.c++ | |
- match: \b(size_t|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|char16_t|char32_t)\b | |
scope: storage.type.c++11 | |
- match: \btemplate\b\s* | |
scope: storage.type.template.c++ | |
- match: \b(const|extern|register|restrict|static|volatile|inline)\b | |
scope: storage.modifier.c | |
- match: \b(export|mutable|typename)\b | |
scope: storage.modifier.c++ | |
- match: \b(friend|explicit|virtual)\b | |
scope: storage.modifier.c++ | |
- match: \b(private:|protected:|public:) | |
scope: storage.modifier.c++ | |
- match: \b(export|mutable|typename)\b | |
scope: storage.modifier.c++ | |
- match: \b(constexpr|auto)\b | |
scope: storage.modifier.c++ | |
- match: \b(override|final|noexcept)\b | |
scope: storage.modifier.c++ | |
- match: '\bk[A-Z]\w*\b' | |
comment: common C constant naming idiom -- kConstantVariable | |
scope: constant.other.variable.mac-classic.c | |
- match: '\bg[A-Z]\w*\b' | |
scope: variable.other.readwrite.global.mac-classic.c | |
- match: '\bs[A-Z]\w*\b' | |
scope: variable.other.readwrite.static.mac-classic.c | |
- match: '\b(f|m)[A-Z]\w*\b' | |
comment: common C++ instance var naming idiom -- fMemberName | |
scope: variable.other.readwrite.member.c++ | |
- match: \bthis\b | |
scope: variable.language.c++ | |
- match: \b(NULL|true|false|TRUE|FALSE)\b | |
scope: constant.language.c | |
- match: \bnullptr\b | |
scope: constant.language.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' | |
scope: constant.numeric.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 | |
scope: support.type.sys-types.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 | |
scope: support.type.pthread.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 | |
scope: support.type.stdint.c | |
- match: \b(noErr|kNilOptions|kInvalidID|kVariableLengthArray)\b | |
scope: support.constant.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 | |
scope: support.type.mac-classic.c | |
- match: \~\w+ | |
scope: deconstructor.ccpp | |
- match: \w+\:\:\w+(\*) | |
scope: pointer.ccpp | |
captures: | |
1: keyword.operator.pointer.ccp | |
- match: (\*)\(\w+\) | |
scope: pointer.ccpp | |
captures: | |
1: keyword.operator.pointer.ccp | |
- match: \(\w+\)(\*) | |
scope: pointer.ccpp | |
captures: | |
1: keyword.operator.pointer.ccp | |
- match: \w+(\*) | |
scope: pointer.ccpp | |
captures: | |
1: keyword.operator.pointer.ccp | |
- match: (\*)\w+ | |
scope: pointer.ccpp | |
captures: | |
1: keyword.operator.pointer.ccp | |
- match: (\&)\w+ | |
scope: address.ccpp | |
captures: | |
1: keyword.operator.address.ccp | |
- match: '\w+(?=\[)' | |
scope: array.ccpp | |
- match: (?<=class|wchar_t|nullptr_t)\s\w+ | |
scope: meta.class-struct.c++ entity.name.type.c++ | |
- match: \w+\s*(?=\() | |
scope: meta.function.c entity.name.function.c | |
- match: '(?<=\.)\w+(?=[^\w|\.])' | |
scope: meta.function.c meta.block.c meta.function-call.c support.function.any-method.c | |
- match: (?<=\:\:)\w+ | |
scope: meta.function.c entity.name.function.c | |
- match: '\w+\:\:' | |
scope: meta.function.c entity.name.function.c | |
- match: \:\:\w+ | |
scope: meta.function.c entity.name.function.c | |
- match: \+\=|\-\=|\*\=|\/\=|\%\=|\&\=|\|\=|\^\=|\<\<\=|\>\>\= | |
scope: keyword.operator.compound.ccpp | |
- match: '\?|\:' | |
scope: keyword.operator.conditional.ccpp | |
- match: \!\s*(?=\w|\() | |
scope: keyword.operator.logical.ccpp | |
- match: \&\&|\|\| | |
scope: keyword.operator.logical.ccpp | |
- match: ~(?=\w) | |
scope: keyword.operator.bitwise.ccpp | |
- match: \&|\||\^|\<\<|\>\> | |
scope: keyword.operator.bitwise.ccpp | |
- match: \>\= | |
scope: keyword.operator.comparison.ccpp | |
- match: \<\= | |
scope: keyword.operator.comparison.ccpp | |
- match: \=\=|\!\=|\<|\> | |
scope: keyword.operator.comparison.ccpp | |
- match: \=|\+|\-|\*|\/|\% | |
scope: keyword.operator.arithmetic.ccpp | |
- match: '(?<=\s)\}(?=break|case|continue|default|do|else|for|goto|if|_Pragma|return|switch|while)' | |
scope: open.curly.bracket.block.ccpp | |
- match: '\}(?=[^\;\s\r\n])' | |
scope: close.curly.bracket.ccpp | |
- match: '(?<=[^\s\r\n])\s*\}' | |
scope: close.curly.bracket.ccpp | |
- match: '\{(?=(\s*|\t*)\/\/\s*.*(\r|\n))' | |
scope: open.curly.bracket.block.ccpp | |
- match: '\{(?=(\s*|\t*)(\r|\n))' | |
scope: open.curly.bracket.block.ccpp | |
- match: '(?<=\s)\}(?=\;?)' | |
scope: close.curly.bracket.block.ccpp | |
- match: '^\}' | |
scope: close.curly.bracket.block.ccpp | |
- match: '\{' | |
scope: open.curly.bracket.ccpp | |
- match: '\}' | |
scope: close.curly.bracket.ccpp | |
- match: \( | |
scope: open.round.bracket.ccpp | |
- match: \) | |
scope: close.round.bracket.ccpp | |
- match: '\[' | |
scope: open.angle.bracket.ccpp | |
- match: '\]' | |
scope: close.angle.bracket.ccpp | |
- match: \. | |
scope: period.ccpp | |
- match: \, | |
scope: coma.ccpp | |
- match: \;(?=(\s*|\t*)\/\/\s*.*) | |
scope: semi_colon.eol.ccpp | |
- match: \;(?=(\s*)(\r|\n)) | |
scope: semi_colon.eol.ccpp | |
- match: \s*?\;\s*?$ | |
scope: semi_colon.eol.ccpp | |
- match: \; | |
scope: semi_colon.ccpp | |
- match: '"' | |
captures: | |
0: punctuation.definition.string.begin.c | |
push: | |
- meta_scope: string.quoted.double.c | |
- match: '"' | |
captures: | |
0: punctuation.definition.string.end.c | |
pop: true | |
- include: string_escaped_char | |
- include: string_placeholder | |
- match: "'" | |
captures: | |
0: punctuation.definition.string.begin.c | |
push: | |
- meta_scope: string.quoted.single.c | |
- match: "'" | |
captures: | |
0: punctuation.definition.string.end.c | |
pop: true | |
- include: string_escaped_char | |
- match: |- | |
(?x) | |
^\s*\#\s*(define)\s+ # define | |
((?:[a-zA-Z_][a-zA-Z0-9_]*)) # macro name | |
(?: # and optionally: | |
(\() # an open parenthesis | |
( | |
\s* [a-zA-Z_][a-zA-Z0-9_]* \s* # first argument | |
(?:(,) \s* [a-zA-Z_][a-zA-Z0-9_]* \s*)* # additional arguments | |
(?:\.\.\.)? # varargs ellipsis? | |
) | |
(\)) # a close parenthesis | |
)? | |
captures: | |
1: keyword.control.import.define.c | |
2: entity.name.function.preprocessor.c | |
4: variable.parameter.preprocessor.c | |
5: punctuation.definition.parameters.c | |
6: punctuation.separator.parameters.c | |
8: punctuation.definition.parameters.c | |
push: | |
- meta_scope: meta.preprocessor.macro.c | |
- match: (?=(?://|/\*))|$ | |
pop: true | |
- match: (?>\\\s*\n) | |
scope: punctuation.separator.continuation.c | |
- include: $top_level_main | |
- match: (\w+) | |
scope: "" | |
- match: ^\s*#\s*(error|warning)\b | |
captures: | |
1: keyword.control.import.error.c | |
push: | |
- meta_scope: meta.preprocessor.diagnostic.c | |
- match: $ | |
pop: true | |
- match: (?>\\\s*\n) | |
scope: punctuation.separator.continuation.c | |
- match: ^\s*#\s*(include|import)\b\s+ | |
captures: | |
1: keyword.control.import.include.c | |
push: | |
- meta_scope: meta.preprocessor.c.include | |
- match: (?=(?://|/\*))|$ | |
pop: true | |
- match: (?>\\\s*\n) | |
scope: punctuation.separator.continuation.c | |
- match: '"' | |
captures: | |
0: punctuation.definition.string.begin.c | |
push: | |
- meta_scope: string.quoted.double.include.c | |
- match: '"' | |
captures: | |
0: punctuation.definition.string.end.c | |
pop: true | |
- match: < | |
captures: | |
0: punctuation.definition.string.begin.c | |
push: | |
- meta_scope: string.quoted.other.lt-gt.include.c | |
- match: ">" | |
captures: | |
0: punctuation.definition.string.end.c | |
pop: true | |
- match: ^\s*#\s*(define|defined|elif|else|if|ifdef|ifndef|line|pragma|undef)\b | |
captures: | |
1: keyword.control.import.c | |
push: | |
- meta_scope: meta.preprocessor.c | |
- match: (?=(?://|/\*))|$ | |
pop: true | |
- match: (?>\\\s*\n) | |
scope: punctuation.separator.continuation.c | |
comments: | |
- match: ^/\* =(\s*.*?)\s*= \*/$\n? | |
scope: comment.block.c | |
captures: | |
1: meta.toc-list.banner.block.c | |
- match: /\* | |
captures: | |
0: punctuation.definition.comment.c | |
push: | |
- meta_scope: comment.block.c | |
- match: \*/ | |
pop: true | |
- match: \*/.*\n | |
scope: invalid.illegal.stray-comment-end.c | |
- match: ^// =(\s*.*?)\s*=\s*$\n? | |
scope: comment.line.banner.c++ | |
captures: | |
1: meta.toc-list.banner.line.c | |
- match: // | |
captures: | |
0: punctuation.definition.comment.c | |
push: | |
- meta_scope: comment.line.double-slash.c++ | |
- match: $\n? | |
pop: true | |
- match: (?>\\\s*\n) | |
scope: punctuation.separator.continuation.c++ | |
disabled: | |
- match: ^\s*#\s*if(n?def)?\b.*$ | |
comment: eat nested preprocessor if(def)s | |
push: | |
- match: ^\s*#\s*endif\b | |
pop: true | |
- include: disabled | |
- include: pragma-mark | |
pragma-mark: | |
- match: ^\s*(#\s*(pragma\s+mark)\s+(.*)) | |
scope: meta.section | |
captures: | |
1: meta.preprocessor.c | |
2: keyword.control.import.pragma.c | |
3: meta.toc-list.pragma-mark.c | |
preprocessor-rule-disabled: | |
- match: ^\s*(#(if)\s+(0)\b).* | |
captures: | |
1: meta.preprocessor.c | |
2: keyword.control.import.if.c | |
3: constant.numeric.preprocessor.c | |
push: | |
- match: ^\s*(#\s*(endif)\b) | |
captures: | |
1: meta.preprocessor.c | |
2: keyword.control.import.endif.c | |
pop: true | |
- match: ^\s*(#\s*(else)\b) | |
captures: | |
1: meta.preprocessor.c | |
2: keyword.control.import.else.c | |
push: | |
- match: (?=^\s*#\s*endif\b) | |
pop: true | |
- include: $top_level_main | |
- match: "" | |
push: | |
- meta_scope: comment.block.preprocessor.if-branch | |
- match: (?=^\s*#\s*(else|endif)\b) | |
pop: true | |
- include: disabled | |
- include: pragma-mark | |
preprocessor-rule-enabled: | |
- match: ^\s*(#(if)\s+(0*1)\b) | |
captures: | |
1: meta.preprocessor.c | |
2: keyword.control.import.if.c | |
3: constant.numeric.preprocessor.c | |
push: | |
- match: ^\s*(#\s*(endif)\b) | |
captures: | |
1: meta.preprocessor.c | |
2: keyword.control.import.endif.c | |
pop: true | |
- match: ^\s*(#\s*(else)\b).* | |
captures: | |
1: meta.preprocessor.c | |
2: keyword.control.import.else.c | |
push: | |
- meta_content_scope: comment.block.preprocessor.else-branch | |
- match: (?=^\s*#\s*endif\b) | |
pop: true | |
- include: disabled | |
- include: pragma-mark | |
- match: "" | |
push: | |
- match: (?=^\s*#\s*(else|endif)\b) | |
pop: true | |
- include: $top_level_main | |
preprocessor-rule-other: | |
- match: ^\s*(#\s*(if(n?def)?)\b.*?(?:(?=(?://|/\*))|$)) | |
captures: | |
1: meta.preprocessor.c | |
2: keyword.control.import.c | |
push: | |
- match: ^\s*(#\s*(endif)\b) | |
captures: | |
1: meta.preprocessor.c | |
2: keyword.control.import.endif.c | |
pop: true | |
- include: $top_level_main | |
string_escaped_char: | |
- match: '\\(\\|[abefnprtv''"?]|[0-3]\d{,2}|[4-7]\d?|x[a-fA-F0-9]{,2}|u[a-fA-F0-9]{,4}|U[a-fA-F0-9]{,8})' | |
scope: constant.character.escape.c | |
- match: \\. | |
scope: invalid.illegal.unknown-escape.c | |
string_placeholder: | |
- match: |- | |
(?x)% | |
(\d+\$)? # field (argument #) | |
[#0\- +']* # flags | |
[,;:_]? # separator character (AltiVec) | |
((-?\d+)|\*(-?\d+\$)?)? # minimum field width | |
(\.((-?\d+)|\*(-?\d+\$)?)?)? # precision | |
(hh|h|ll|l|j|t|z|q|L|vh|vl|v|hv|hl)? # length modifier | |
[diouxXDOUeEfFgGaACcSspn%] # conversion type | |
scope: constant.other.placeholder.c | |
- match: "%" | |
scope: invalid.illegal.placeholder.c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment