Skip to content

Commit

Permalink
Merge remote-tracking branch 'sublimehq/master' into sql
Browse files Browse the repository at this point in the history
  • Loading branch information
keith-hall committed Nov 2, 2023
2 parents c49b7f8 + 375ccbf commit 5d51874
Show file tree
Hide file tree
Showing 49 changed files with 5,560 additions and 1,531 deletions.
2 changes: 1 addition & 1 deletion AppleScript/AppleScript.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ file_extensions:

first_line_match: |-
(?xi:
^ \#! .* \bosascript\b # shebang
^ \#! .* \bosascript(?!\s+-l\s+JavaScript)\b # shebang
| ^ \s* \# .*? -\*- .*? \bosascript\b .*? -\*- # editorconfig
)
Expand Down
4 changes: 2 additions & 2 deletions Batch File/Batch File.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,9 @@ contexts:
pop: 1
- match: (:)?(?={{label_start}})
scope: punctuation.definition.label.dosbatch
set: clt-goto-label
set: ctl-goto-label

clt-goto-label:
ctl-goto-label:
- meta_scope: variable.label.dosbatch
- include: line-continuations
- include: label-name
Expand Down
48 changes: 33 additions & 15 deletions C++/C++.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -282,21 +282,7 @@ contexts:
- include: keywords-angle-brackets
- match: '(?={{path_lookahead}}\s*<)'
push: global-modifier
# Take care of comments just before a function definition.
- match: /\*
scope: punctuation.definition.comment.c
push:
- - match: \s*(?=\w)
set: global-modifier
- match: ""
pop: true
- - meta_scope: comment.block.c
- match: \*/
scope: punctuation.definition.comment.c
pop: true
- match: ^\s*(\*)(?!/)
captures:
1: punctuation.definition.comment.c
- include: global-block-comments
- include: early-expressions
- match: ^\s*\b(extern)(?=\s+"C(\+\+)?")
scope: storage.modifier.c++
Expand Down Expand Up @@ -328,6 +314,38 @@ contexts:
push: global-modifier
- include: late-expressions

global-block-comments:
# NOTE: This context overrides `comments` context, which re-uses scopes
# from `source.c#comments`. So keep the trailing `c` for consistency reasons!
- match: ^(/\*) =\s*(.*?)\s*= (\*/)$\n?
scope: comment.block.banner.c
captures:
1: punctuation.definition.comment.begin.c
2: meta.toc-list.banner.block.c
3: punctuation.definition.comment.end.c
# empty block comments
- match: /\*\*+/
scope: comment.block.empty.c punctuation.definition.comment.c
push: global-block-comment-after
# documentation block comments
- match: (?:/\*!|/\*{2,})
scope: punctuation.definition.comment.begin.c
push:
- global-block-comment-after
- scope:source.c#block-comment-documentation-body
# normal block comments
- match: /\*
scope: punctuation.definition.comment.begin.c
push:
- global-block-comment-after
- scope:source.c#block-comment-body

global-block-comment-after:
- match: \s*(?=\w)
set: global-modifier
- match: ''
pop: true

statements:
- include: preprocessor-statements
- include: scope:source.c#label
Expand Down
109 changes: 85 additions & 24 deletions C++/C.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ variables:
type_qualifier: 'const|volatile'
compiler_directive: 'inline|restrict|__restrict__|__restrict'
modifiers: '{{storage_classes}}|{{type_qualifier}}|{{compiler_directive}}'
non_func_keywords: 'if|for|switch|while|decltype|sizeof|__declspec|__attribute__'
non_func_keywords: 'if|for|switch|while|decltype|typeof|typeof_unqual|sizeof|__declspec|__attribute__'

contexts:
main:
Expand All @@ -65,35 +65,82 @@ contexts:
#############################################################################

comments:
- match: ^/\* =(\s*.*?)\s*= \*/$\n?
scope: comment.block.c
- include: block-comments
- include: line-comments

block-comments:
- match: ^(/\*) =\s*(.*?)\s*= (\*/)$\n?
scope: comment.block.banner.c
captures:
1: meta.toc-list.banner.block.c
1: punctuation.definition.comment.begin.c
2: meta.toc-list.banner.block.c
3: punctuation.definition.comment.end.c
# empty block comments
- match: /\*\*+/
scope: comment.block.empty.c punctuation.definition.comment.c
# documentation block comments
- match: (?:/\*!|/\*{2,})
scope: punctuation.definition.comment.begin.c
push: block-comment-documentation-body
# normal block comments
- match: /\*
scope: punctuation.definition.comment.c
push:
- meta_scope: comment.block.c
- match: \*/
scope: punctuation.definition.comment.c
pop: true
- match: ^\s*(\*)(?!/)
captures:
1: punctuation.definition.comment.c
- match: \*/(?!\*)
scope: punctuation.definition.comment.begin.c
push: block-comment-body
# stray block comment end
- match: \*+/(?!\*)
scope: invalid.illegal.stray-comment-end.c
- match: ^// =(\s*.*?)\s*=\s*$\n?

block-comment-documentation-body:
- meta_include_prototype: false
- meta_scope: comment.block.documentation.c
- match: \*+/
scope: punctuation.definition.comment.end.c
pop: true
- match: ^\s*(\*)(?!\**/)
captures:
1: punctuation.definition.comment.c

block-comment-body:
- meta_include_prototype: false
- meta_scope: comment.block.c
- match: \*/
scope: punctuation.definition.comment.end.c
pop: true
- match: ^\s*(\*)(?!\**/)
captures:
1: punctuation.definition.comment.c

line-comments:
- match: ^(//) =\s*(.*?)\s*=\s*$\n?
scope: comment.line.banner.c
captures:
1: meta.toc-list.banner.line.c
- match: //
1: punctuation.definition.comment.c
2: meta.toc-list.banner.line.c
- match: //(?:!|/(?!/))
scope: punctuation.definition.comment.c
push:
- meta_scope: comment.line.double-slash.c
- match: '(\\)$\n'
captures:
1: punctuation.separator.continuation.c
- match: \n
pop: true
push: line-comment-documentation-body
- match: //+
scope: punctuation.definition.comment.c
push: line-comment-body

line-comment-body:
- meta_include_prototype: false
- meta_scope: comment.line.double-slash.c
- include: line-comment-end

line-comment-documentation-body:
- meta_include_prototype: false
- meta_scope: comment.line.documentation.c
- include: line-comment-end

line-comment-end:
- match: (?:(//+)\s*)?$\n?
captures:
1: punctuation.definition.comment.c
pop: 1
- match: (\\)$\n?
captures:
1: punctuation.separator.continuation.c

strings:
- match: '(L|u8|u|U)?(")'
Expand Down Expand Up @@ -195,6 +242,19 @@ contexts:
scope: support.type.windows.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
- include: types-parens

types-parens:
- match: '\b(typeof|__typeof|__typeof__|typeof_unqual)\b\s*(\()'
captures:
1: keyword.declaration.type.c
2: meta.group.c punctuation.section.group.begin.c
push:
- meta_content_scope: meta.group.c
- match: '\)'
scope: meta.group.c punctuation.section.group.end.c
pop: true
- include: expressions

numbers:
# https://en.cppreference.com/w/c/language/floating_constant
Expand Down Expand Up @@ -448,6 +508,7 @@ contexts:

global-type:
- include: comments
- include: types-parens
- match: \*
scope: keyword.operator.c
- match: |-
Expand Down
127 changes: 124 additions & 3 deletions C++/syntax_test_c.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,86 @@
/* SYNTAX TEST "Packages/C++/C.sublime-syntax" */

// =Banner=
/* ^^^^^^ comment.line.banner.c meta.toc-list.banner.line.c */

// = Banner =
/* ^^^^^^^^^^^ comment.line.banner.c */
/*^^^ - meta.toc-list */
/* ^^^^^^ meta.toc-list.banner.line.c */
/* ^^^ - meta.toc-list */

// Comment //
/* <- comment.line.double-slash.c punctuation.definition.comment.c */
/* <- comment.line.double-slash.c punctuation.definition.comment.c */
/*^^^^^^^^^ comment.line.double-slash.c - punctuation */
/* ^^ comment.line.double-slash.c punctuation.definition.comment.c */

//! Comment
/* <- comment.line.documentation.c punctuation.definition.comment.c */
/* <- comment.line.documentation.c punctuation.definition.comment.c */
/* <- comment.line.documentation.c punctuation.definition.comment.c */
/*^^^^^^^^^ comment.line.documentation.c - punctuation */

/// Comment ///
/* <- comment.line.documentation.c punctuation.definition.comment.c */
/* <- comment.line.documentation.c punctuation.definition.comment.c */
/* <- comment.line.documentation.c punctuation.definition.comment.c */
/*^^^^^^^^^ comment.line.documentation.c - punctuation */
/* ^^^ comment.line.documentation.c punctuation.definition.comment.c */

//// Comment ////
/* <- comment.line.double-slash.c punctuation.definition.comment.c */
/* <- comment.line.double-slash.c punctuation.definition.comment.c */
/*^^ comment.line.double-slash.c punctuation.definition.comment.c */
/* ^^^^^^^^^ comment.line.double-slash.c - punctuation */
/* ^^^^ comment.line.double-slash.c punctuation.definition.comment.c */
/* ^^ comment.line.double-slash.c - punctuation */

/* =Banner= */
/* <- comment.block.banner.c punctuation.definition.comment.begin.c */
/*^^^^^^^^^^ comment.block.banner.c - punctuation */
/* ^^^^^^ meta.toc-list.banner.block.c */
/* ^^ comment.block.banner.c punctuation.definition.comment.end.c */

/* = Banner = */
/* <- comment.block.banner.c punctuation.definition.comment.begin.c */
/*^^^^^^^^^^^^ comment.block.banner.c - punctuation */
/*^^^ - meta.toc-list */
/* ^^^^^^ meta.toc-list.banner.block.c */
/* ^^^^^ - meta.toc-list */
/* ^^ comment.block.banner.c punctuation.definition.comment.end.c */

/*****/
/* ^^^^^^^ comment.block.empty.c punctuation.definition.comment.c */

/**
/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */

/***
/* ^^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */

/*!
/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */

/*!****
/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */
/* ^^^^^ comment.block.documentation.c - punctuation */

/*!****/
/* ^^^ comment.block.documentation.c punctuation.definition.comment.begin.c */
/* ^^^^^ comment.block.documentation.c punctuation.definition.comment.end.c */

/*!
* docstring
**/
/* ^^^ comment.block.documentation.c */

*/
/* ^^ invalid.illegal.stray-comment-end.c */

**/
/* ^^^ invalid.illegal.stray-comment-end.c */

int main(){
int a=5,b=0;
while(a-->0)++b;
Expand Down Expand Up @@ -40,11 +121,11 @@ enum { kFoo = FOO, kBar = BAR };
/* ^ keyword.operator.assignment.c */
/* ^^^ - entity.name.constant */

enum {
FOO,
enum {
FOO,
/* ^^^ entity.name.constant.c */
/* ^ punctuation.separator.c */
BAR
BAR
/* ^^^ entity.name.constant.c */
};

Expand Down Expand Up @@ -120,6 +201,42 @@ struct foo {
int i;
/* <- storage.type */

typeof(i) dt;
/* <- keyword.declaration.type */
/* ^ punctuation.section.group.begin */
/* ^ punctuation.section.group.end */
__typeof(i) dt;
/* <- keyword.declaration.type */
/* ^ punctuation.section.group.begin */
/* ^ punctuation.section.group.end */
__typeof__(i) dt;
/* <- keyword.declaration.type */
/* ^ punctuation.section.group.begin */
/* ^ punctuation.section.group.end */
typeof_unqual(i) dt;
/* <- keyword.declaration.type */
/* ^ punctuation.section.group.begin */
/* ^ punctuation.section.group.end */

void build_default_prototype(Function *ret) {
static typeof(*ret->params) params[4];
/* <- keyword.declaration.type */
/* ^ punctuation.section.group.begin */
/* ^ punctuation.section.group.end */
static __typeof(*ret->params) params[4];
/* <- keyword.declaration.type */
/* ^ punctuation.section.group.begin */
/* ^ punctuation.section.group.end */
static __typeof__(*ret->params) params[4];
/* <- keyword.declaration.type */
/* ^ punctuation.section.group.begin */
/* ^ punctuation.section.group.end */
static typeof_unqual(*ret->params) params[4];
/* <- keyword.declaration.type */
/* ^ punctuation.section.group.begin */
/* ^ punctuation.section.group.end */
}

// The following example ensures that comments at the end of preprocessor
// directives don't mess with context transitions
int func() {
Expand Down Expand Up @@ -306,6 +423,10 @@ struct X

/**
*
/* ^ comment.block.documentation.c punctuation.definition.comment.c */

/*
*
/* ^ comment.block.c punctuation.definition.comment.c */

/////////////////////////////////////////////
Expand Down
Loading

0 comments on commit 5d51874

Please sign in to comment.