From 697d7c6c97fcd8c598d1f281ddcb294e641dff3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Andr=C3=A9s=20Margffoy=20Tuay?= Date: Wed, 5 May 2021 12:01:30 -0500 Subject: [PATCH 1/2] Start theme re-creation --- themes/Chromodynamics.tmTheme | 14 +- themes/Monokai.tmTheme | 60 +++- themes/Solarized (dark).tmTheme | 58 ++++ themes/Solarized (light).tmTheme | 57 ++++ themes/Spyder (dark).tmTheme | 516 ++++++++++++++++++++++++++++++ themes/Spyder (light).tmTheme | 527 +++++++++++++++++++++++++++++++ themes/zenburn.tmTheme | 61 +++- 7 files changed, 1286 insertions(+), 7 deletions(-) create mode 100644 themes/Spyder (dark).tmTheme create mode 100644 themes/Spyder (light).tmTheme diff --git a/themes/Chromodynamics.tmTheme b/themes/Chromodynamics.tmTheme index 8b182a9..effb297 100644 --- a/themes/Chromodynamics.tmTheme +++ b/themes/Chromodynamics.tmTheme @@ -33,7 +33,17 @@ #595959 - + + name + String + scope + meta.function-call.generic + settings + + foreground + #A6E22E + + name String @@ -229,7 +239,7 @@ name Class name scope - entity.name.class + entity.name.type.class settings foreground diff --git a/themes/Monokai.tmTheme b/themes/Monokai.tmTheme index c179cbe..196d45c 100644 --- a/themes/Monokai.tmTheme +++ b/themes/Monokai.tmTheme @@ -44,6 +44,17 @@ stippled_underline + + name + String + scope + meta.function-call.generic + settings + + foreground + #A6E22E + + name Comment @@ -152,7 +163,7 @@ name Class name scope - entity.name.class + entity.name.type.class settings fontStyle @@ -360,7 +371,17 @@ #E6DB74 - + + name + self and cls + scope + variable.language.special, variable.parameter.function.language.special + settings + + foreground + #CFCFC2 + + scope constant.numeric.line-number.find-in-files - match @@ -379,7 +400,40 @@ #E6DB74 - + + + name + comment/typehint: base color + scope + comment.typehint + settings + + foreground + #888A84 + + + + name + comment/typehint: ignore + scope + comment.typehint.ignore + settings + + foreground + #D34A7D + + + + name + comment/typehint: type name + scope + comment.typehint.type + settings + + foreground + #82C6D3 + + uuid D8D5E82E-3D5B-46B5-B38E-8C841C21347D diff --git a/themes/Solarized (dark).tmTheme b/themes/Solarized (dark).tmTheme index e0a5aa9..a46829d 100644 --- a/themes/Solarized (dark).tmTheme +++ b/themes/Solarized (dark).tmTheme @@ -38,6 +38,17 @@ #073642 + + name + String + scope + meta.function-call.generic + settings + + foreground + #268BD2 + + name Comment @@ -1911,6 +1922,53 @@ + + name + self and cls + scope + variable.language.special, variable.parameter.function.language.special + settings + + foreground + #268BD2 + + + + + + name + comment/typehint: base color + scope + comment.typehint + settings + + foreground + #586E75 + + + + name + comment/typehint: ignore + scope + comment.typehint.ignore + settings + + foreground + #2AA198 + + + + name + comment/typehint: type name + scope + comment.typehint.type + settings + + foreground + #3a7199 + + + name Markdown: Headings diff --git a/themes/Solarized (light).tmTheme b/themes/Solarized (light).tmTheme index 2aa60a2..34a5849 100644 --- a/themes/Solarized (light).tmTheme +++ b/themes/Solarized (light).tmTheme @@ -187,6 +187,17 @@ #b58900 + + name + self and cls + scope + variable.language.special, variable.parameter.function.language.special + settings + + foreground + #b58900 + + name Inherited Class @@ -231,6 +242,17 @@ #b58900 + + name + String + scope + meta.function-call.generic + settings + + foreground + #b58900 + + name Variable start @@ -1201,6 +1223,41 @@ #657b83 + + + + name + comment/typehint: base color + scope + comment.typehint + settings + + foreground + #93a1a1 + + + + name + comment/typehint: ignore + scope + comment.typehint.ignore + settings + + foreground + #a84745 + + + + name + comment/typehint: type name + scope + comment.typehint.type + settings + + foreground + #89991f + + uuid ca238b9c-28f7-42d4-9670-bd0829ef864e diff --git a/themes/Spyder (dark).tmTheme b/themes/Spyder (dark).tmTheme new file mode 100644 index 0000000..3075473 --- /dev/null +++ b/themes/Spyder (dark).tmTheme @@ -0,0 +1,516 @@ + + + + + name + Spyder (dark) + settings + + + settings + + background + #19232D + caret + #dfdfdf + foreground + #ffffff + invisibles + #3B3A32 + lineHighlight + #292d3e + selection + #509ea5 + findHighlight + #509ea5 + findHighlightForeground + #000000 + selectionBorder + #222b35 + gutter + #222b35 + gutterForeground + #808080 + + + + name + String + scope + meta.function-call.generic + settings + + foreground + #57d6e4 + + + + name + String + scope + text, source + settings + + foreground + #ffffff + + + + + name + Git Changed Line + scope + git_changes_change + settings + + foreground + #c5bb29 + + + + name + Git Added Line + scope + git_changes_add + settings + + foreground + #11a642 + + + + name + Git Remove Line + scope + git_changes_del- + settings + + foreground + #c80000 + + + + + name + Comment + scope + comment + settings + + foreground + #999999 + + + + name + String + scope + string + settings + + foreground + #b0e686 + + + + name + Docstring + scope + string.quoted.docstring + settings + + foreground + #b0e686 + + + + name + Docstring Quotes (specially for Atom) + scope + string.quoted.docstring string + settings + + foreground + #b0e686 + + + + name + Docstring Storage (r prefix) (specially for Atom) + scope + string.quoted.docstring storage + settings + + foreground + #179ae0 + + + + name + Number + scope + constant.numeric + settings + + foreground + #faed5c + + + + name + Built-in constant + scope + constant.language + settings + + foreground + #fab16c + + + + name + User-defined constant + scope + constant.character, constant.other + settings + + foreground + #fab16c + + + + name + Variable + scope + variable + settings + + fontStyle + + + + + name + Keyword + scope + keyword + settings + + foreground + #c670e0 + + + + name + Notes (XXX) + scope + comment.line.note, string.quoted.docstring.note + settings + + foreground + #fab16c + + + + name + Storage + scope + storage + settings + + fontStyle + + foreground + #e8364f + + + + name + Storage type + scope + storage.type + settings + + foreground + #c670e0 + + + + name + Class name + scope + entity.name.type.class + settings + + foreground + #57d6e4 + + + + name + Inherited class + scope + entity.other.inherited-class + settings + + foreground + #fab16c + + + + name + Function name + scope + entity.name.function + settings + + fontStyle + + foreground + #57d6e4 + + + + name + Function argument + scope + variable.parameter + settings + + foreground + #FA9D46 + + + + name + Tag name + scope + entity.name.tag.namespace + settings + + fontStyle + + foreground + #76263a + + + + name + Tag localname + scope + entity.name.tag, keyword.doctype.xml + settings + + fontStyle + + foreground + #d33c78 + + + + name + Tag attribute + scope + entity.other.attribute-name + settings + + fontStyle + + foreground + #D77C23 + + + + name + Library function + scope + support.function + settings + + fontStyle + + foreground + #57d6e4 + + + + name + Library constant + scope + support.constant + settings + + fontStyle + + foreground + #fab16c + + + + name + Library class/type + scope + support.type + settings + + foreground + #57d6e4 + + + + name + Special name + scope + support.class, support.other, support.variable + settings + + foreground + #57d6e4 + + + + name + Library variable + scope + support.other.variable + settings + + fontStyle + + + + + name + Invalid + scope + invalid + settings + + background + #7c3636 + fontStyle + + foreground + #F8F8F0 + + + + name + Invalid deprecated + scope + invalid.deprecated + settings + + background + #99732b + foreground + #F8F8F0 + + + + name + JSON String + scope + meta.structure.dictionary.json string.quoted.double.json + settings + + foreground + #CFCFC2 + + + + + name + diff.header + scope + meta.diff, meta.diff.header + settings + + foreground + #75715E + + + + name + diff.deleted + scope + markup.deleted + settings + + foreground + #ee6772 + + + + name + diff.inserted + scope + markup.inserted + settings + + foreground + #A6E22E + + + + name + diff.changed + scope + markup.changed + settings + + foreground + #E6DB74 + + + + name + self and cls + scope + variable.language.special, variable.parameter.function.language.special + settings + + foreground + #ff4340 + + + + + + name + comment/typehint: base color + scope + comment.typehint + settings + + foreground + #888A84 + + + + name + comment/typehint: ignore + scope + comment.typehint.ignore + settings + + foreground + #7E6461 + + + + name + comment/typehint: type name + scope + comment.typehint.type + settings + + foreground + #44727B + + + + uuid + 72d2f21e-76c9-11e5-8275-000c6c071bb8 + + diff --git a/themes/Spyder (light).tmTheme b/themes/Spyder (light).tmTheme new file mode 100644 index 0000000..beb1d1b --- /dev/null +++ b/themes/Spyder (light).tmTheme @@ -0,0 +1,527 @@ + + + + + name + Spyder (light) + settings + + + settings + + background + #ffffff + caret + #adadad + foreground + #000000 + invisibles + #3B3A32 + lineHighlight + #f7ecf8 + selection + #ffff99 + findHighlight + #ffff99 + findHighlightForeground + #000000 + selectionBorder + #efefef + gutter + #efefef + gutterForeground + #808080 + + + + name + String + scope + meta.function-call.generic + settings + + foreground + #807904 + + + + + + name + Git Changed Line + scope + git_changes_change + settings + + foreground + #ffff99 + + + + name + Git Added Line + scope + git_changes_add + settings + + foreground + #00aa00 + + + + name + Git Remove Line + scope + git_changes_del- + settings + + foreground + #800000 + + + + + name + Comment + scope + comment + settings + + foreground + #adadad + + + + name + String + scope + string + settings + + foreground + #00aa00 + + + + name + Docstring + scope + string.quoted.docstring + settings + + foreground + #00aa00 + + + + name + Docstring Quotes (specially for Atom) + scope + string.quoted.docstring string + settings + + foreground + #00aa00 + + + + name + Docstring Storage (r prefix) (specially for Atom) + scope + string.quoted.docstring storage + settings + + foreground + #0000ff + + + + name + Number + scope + constant.numeric + settings + + foreground + #800000 + + + + name + Built-in constant + scope + constant.language + settings + + foreground + #900090 + + + + name + User-defined constant + scope + constant.character, constant.other + settings + + foreground + #900090 + + + + name + Variable + scope + variable + settings + + fontStyle + + + + + name + Keyword + scope + keyword + settings + + foreground + #0000ff + + + + name + Notes (XXX) + scope + comment.line.note, string.quoted.docstring.note + settings + + foreground + #900090 + + + + name + Storage + scope + storage + settings + + fontStyle + + foreground + #e8364f + + + + name + Storage type + scope + storage.type + settings + + foreground + #0000ff + + + + name + Class name + scope + entity.name.type.class + settings + + foreground + #146380 + + + + name + Inherited class + scope + entity.other.inherited-class + settings + + foreground + #900090 + + + + name + Function name + scope + entity.name.function + settings + + fontStyle + + foreground + #807904 + + + + name + Function argument + scope + variable.parameter + settings + + foreground + #cc6d14 + + + + name + Tag name + scope + entity.name.tag.namespace + settings + + fontStyle + + foreground + #76263a + + + + name + Tag localname + scope + entity.name.tag, keyword.doctype.xml + settings + + fontStyle + + foreground + #d33c78 + + + + name + Tag attribute + scope + entity.other.attribute-name + settings + + fontStyle + + foreground + #D77C23 + + + + name + Library function + scope + support.function + settings + + fontStyle + + foreground + #807904 + + + + name + Library constant + scope + support.constant + settings + + fontStyle + + foreground + #900090 + + + + name + Library class/type + scope + support.type + settings + + foreground + #900090 + + + + name + Special name + scope + support.class, support.other, support.variable + settings + + foreground + #900090 + + + + name + Library variable + scope + support.other.variable + settings + + fontStyle + + + + + name + Invalid + scope + invalid + settings + + background + #7c3636 + fontStyle + + foreground + #F8F8F0 + + + + name + Invalid deprecated + scope + invalid.deprecated + settings + + background + #99732b + foreground + #F8F8F0 + + + + name + JSON String + scope + meta.structure.dictionary.json string.quoted.double.json + settings + + foreground + #CFCFC2 + + + + + name + diff.header + scope + meta.diff, meta.diff.header + settings + + foreground + #75715E + + + + name + diff.deleted + scope + markup.deleted + settings + + foreground + #ee6772 + + + + name + diff.inserted + scope + markup.inserted + settings + + foreground + #A6E22E + + + + name + diff.changed + scope + markup.changed + settings + + foreground + #E6DB74 + + + + name + self and cls + scope + variable.language.special, variable.parameter.function.language.special + settings + + foreground + #924900 + + + + name + Notes (XXX) + scope + comment.line.note, string.quoted.docstring.note + settings + + foreground + #146380 + + + + + + name + comment/typehint: base color + scope + comment.typehint + settings + + foreground + #888A84 + + + + name + comment/typehint: ignore + scope + comment.typehint.ignore + settings + + foreground + #7E6461 + + + + name + comment/typehint: type name + scope + comment.typehint.type + settings + + foreground + #146380 + + + + uuid + 72d2f21e-76c9-11e5-8275-000c6c071bb8 + + diff --git a/themes/zenburn.tmTheme b/themes/zenburn.tmTheme index ec1bdc7..148d347 100644 --- a/themes/zenburn.tmTheme +++ b/themes/zenburn.tmTheme @@ -25,6 +25,17 @@ #8383839C + + name + String + scope + meta.function-call.generic + settings + + foreground + #FFFD87 + + name Comment @@ -423,9 +434,20 @@ settings foreground - #FFFD87 + #FED6AF + + name + self and cls + scope + variable.language.special, variable.parameter.function.language.special + settings + + foreground + #CC9495 + + name built-in function @@ -737,7 +759,42 @@ foreground #D02000 - + + + + name + comment/typehint: base color + scope + comment.typehint + settings + + foreground + #75715E + + + + name + comment/typehint: ignore + scope + comment.typehint.ignore + settings + + foreground + #DDB700 + + + + name + comment/typehint: type name + scope + comment.typehint.type + settings + + foreground + #CA7172 + + + uuid A34A7407-68B9-48E5-883E-E551F7561026 From 180d6dc20845d58a22b00bcb3abe3785fc9bb61b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Andr=C3=A9s=20Margffoy=20Tuay?= Date: Wed, 5 May 2021 12:02:41 -0500 Subject: [PATCH 2/2] Try to read syntax from a thread --- src/lib.rs | 43 +- syntect/__init__.py | 10 +- syntect/minimal_grammars/C++.sublime-syntax | 242 ++ syntect/minimal_grammars/C.sublime-syntax | 466 +++ .../minimal_grammars/Cython.sublime-syntax | 961 +++++ syntect/minimal_grammars/Diff.sublime-syntax | 90 + .../Fortran - Modern.sublime-syntax | 168 + syntect/minimal_grammars/JSON.sublime-syntax | 102 + syntect/minimal_grammars/Java.sublime-syntax | 549 +++ .../JavaScript (Babel).sublime-syntax | 1288 ++++++ .../MagicPython.sublime-syntax | 2930 ++++++++++++++ syntect/minimal_grammars/PHP.sublime-syntax | 1113 ++++++ syntect/minimal_grammars/Perl.sublime-syntax | 1327 +++++++ .../PowerShellSyntax.sublime-syntax | 447 +++ syntect/minimal_grammars/R.sublime-syntax | 105 + syntect/minimal_grammars/SQL.sublime-syntax | 251 ++ syntect/minimal_grammars/TOML.sublime-syntax | 254 ++ .../TypeScript.sublime-syntax | 3340 ++++++++++++++++ .../TypeScriptReact.sublime-syntax | 3494 +++++++++++++++++ syntect/minimal_grammars/XML.sublime-syntax | 204 + .../minimal_grammars/batchfile.sublime-syntax | 328 ++ syntect/minimal_grammars/css.sublime-syntax | 1392 +++++++ syntect/minimal_grammars/gfm.sublime-syntax | 882 +++++ .../minimal_grammars/gitignore.sublime-syntax | 107 + syntect/minimal_grammars/html.sublime-syntax | 486 +++ .../javascript.sublime-syntax | 1121 ++++++ syntect/minimal_grammars/ruby.sublime-syntax | 1531 ++++++++ syntect/minimal_grammars/rust.sublime-syntax | 368 ++ .../shell-unix-bash.sublime-syntax | 659 ++++ syntect/minimal_grammars/yaml.sublime-syntax | 219 ++ syntect/syntect.pyi | 3 +- 31 files changed, 24469 insertions(+), 11 deletions(-) create mode 100644 syntect/minimal_grammars/C++.sublime-syntax create mode 100644 syntect/minimal_grammars/C.sublime-syntax create mode 100644 syntect/minimal_grammars/Cython.sublime-syntax create mode 100644 syntect/minimal_grammars/Diff.sublime-syntax create mode 100644 syntect/minimal_grammars/Fortran - Modern.sublime-syntax create mode 100644 syntect/minimal_grammars/JSON.sublime-syntax create mode 100644 syntect/minimal_grammars/Java.sublime-syntax create mode 100644 syntect/minimal_grammars/JavaScript (Babel).sublime-syntax create mode 100644 syntect/minimal_grammars/MagicPython.sublime-syntax create mode 100644 syntect/minimal_grammars/PHP.sublime-syntax create mode 100644 syntect/minimal_grammars/Perl.sublime-syntax create mode 100644 syntect/minimal_grammars/PowerShellSyntax.sublime-syntax create mode 100644 syntect/minimal_grammars/R.sublime-syntax create mode 100644 syntect/minimal_grammars/SQL.sublime-syntax create mode 100644 syntect/minimal_grammars/TOML.sublime-syntax create mode 100644 syntect/minimal_grammars/TypeScript.sublime-syntax create mode 100644 syntect/minimal_grammars/TypeScriptReact.sublime-syntax create mode 100644 syntect/minimal_grammars/XML.sublime-syntax create mode 100644 syntect/minimal_grammars/batchfile.sublime-syntax create mode 100644 syntect/minimal_grammars/css.sublime-syntax create mode 100644 syntect/minimal_grammars/gfm.sublime-syntax create mode 100644 syntect/minimal_grammars/gitignore.sublime-syntax create mode 100644 syntect/minimal_grammars/html.sublime-syntax create mode 100644 syntect/minimal_grammars/javascript.sublime-syntax create mode 100644 syntect/minimal_grammars/ruby.sublime-syntax create mode 100644 syntect/minimal_grammars/rust.sublime-syntax create mode 100644 syntect/minimal_grammars/shell-unix-bash.sublime-syntax create mode 100644 syntect/minimal_grammars/yaml.sublime-syntax diff --git a/src/lib.rs b/src/lib.rs index dd62551..492139d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,6 +7,11 @@ /// Rust bindings to syntect library in Python +// Std imports +use std::sync::mpsc; +use std::thread; +// use std::time::Instant; + // PyO3 imports use pyo3::create_exception; use pyo3::exceptions; @@ -546,15 +551,37 @@ fn highlight( /// LoadingError: /// If there was some error trying to read any of the files. #[pyfunction] -fn load_syntax_folder(folder: String) -> PyResult { - let syn_set = SyntaxSet::load_from_folder(&folder); - match syn_set { - Ok(result) => { - // let syntaxes = result.syntaxes(); - let syn_handle = SyntaxSetHandle { syntax_set: result }; - Ok(syn_handle) +fn load_syntax_folder(folder: String, use_thread: bool, py: Python<'_>) -> PyResult { + // let (tx, rx) = mpsc::channel(); + if use_thread { + return py.allow_threads(move || { + let (tx, rx) = mpsc::channel(); + thread::spawn(move || { + let syn_set = SyntaxSet::load_from_folder(&folder); + tx.send(syn_set).unwrap(); + }); + let syn_set = rx.recv().unwrap(); + match syn_set { + Ok(result) => { + // let syntaxes = result.syntaxes(); + let syn_handle = SyntaxSetHandle { syntax_set: result }; + Ok(syn_handle) + } + Err(err) => Err(LoadingError::py_err(err.to_string())), + } + }); + } else { + // let now = Instant::now(); + let syn_set = SyntaxSet::load_from_folder(&folder); + // println!("{}", now.elapsed().as_secs()); + match syn_set { + Ok(result) => { + // let syntaxes = result.syntaxes(); + let syn_handle = SyntaxSetHandle { syntax_set: result }; + Ok(syn_handle) + } + Err(err) => Err(LoadingError::py_err(err.to_string())), } - Err(err) => Err(LoadingError::py_err(err.to_string())), } } diff --git a/syntect/__init__.py b/syntect/__init__.py index 387c282..a0839ad 100644 --- a/syntect/__init__.py +++ b/syntect/__init__.py @@ -21,6 +21,7 @@ HERE = osp.dirname(osp.abspath(__file__)) GRAMMARS = osp.join(HERE, 'grammars') +MIN_GRAMMARS = osp.join(HERE, 'minimal_grammars') class FontStyle: @@ -30,9 +31,14 @@ class FontStyle: UNDERLINE = FontStyleConst.underline() -def load_default_syntax(): +def load_minimum_syntax(use_thread): + """Load a minimum set of language grammars.""" + return load_syntax_folder(MIN_GRAMMARS, use_thread) + + +def load_default_syntax(use_thread): """Load the default syntax definitions included with pysyntect.""" - return load_syntax_folder(GRAMMARS) + return load_syntax_folder(GRAMMARS, use_thread) # Package functions diff --git a/syntect/minimal_grammars/C++.sublime-syntax b/syntect/minimal_grammars/C++.sublime-syntax new file mode 100644 index 0000000..27d2b57 --- /dev/null +++ b/syntect/minimal_grammars/C++.sublime-syntax @@ -0,0 +1,242 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: C++ +comment: I don't think anyone uses .hp. .cp tends to be paired with .h. (I could be wrong. :) -- chris +file_extensions: + - cc + - cpp + - cp + - cxx + - c++ + - C + - h + - hh + - hpp + - hxx + - h++ +first_line_match: '-\*- C\+\+ -\*-' +scope: source.c++ +contexts: + main: + - include: special_block + - include: strings + - match: \b(if)\s+(constexpr)\b + captures: + 1: keyword.control.c++ + 2: keyword.control.c++ + - match: (::)\s*(template)\b + captures: + 1: punctuation.separator.scope.c++ + 2: storage.modifier.template.c++ + - include: scope:source.c + - match: \b(friend|explicit|virtual)\b + scope: storage.modifier.$1.c++ + - match: '\b(private|protected|public):' + scope: storage.modifier.$1.c++ + - match: \b(catch|operator|try|throw|using)\b + scope: keyword.control.c++ + - match: '\bdelete\b(\s*\[\])?|\bnew\b(?!])' + scope: keyword.control.c++ + - match: '\b(f|m)[A-Z]\w*\b' + comment: common C++ instance var naming idiom -- fMemberName + scope: variable.other.readwrite.member.c++ + - match: \b(this|nullptr)\b + scope: variable.language.c++ + - match: \btemplate\b\s* + scope: storage.type.template.c++ + - match: \b(const_cast|dynamic_cast|reinterpret_cast|static_cast)\b\s* + scope: keyword.operator.cast.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(class|wchar_t)\b + scope: storage.type.c++ + - match: \b(constexpr|export|mutable|typename|thread_local|noexcept)\b + scope: storage.modifier.c++ + - match: |- + (?x) + (?: ^ # begin-of-line + | (?: (?" + pop: true + - include: angle_brackets + - include: $top_level_main + block: + - match: '\{' + captures: + 0: punctuation.section.block.begin.c + push: + - meta_scope: meta.block.c++ + - match: '\}' + captures: + 0: punctuation.section.block.end.c + pop: true + - match: |- + (?x) + ( + (?!while|for|do|if|else|switch|catch|return)(?: \b[A-Za-z_][A-Za-z0-9_]*+\b | :: )*+ # actual name + ) + \s*(\() + scope: meta.function-call.c + captures: + 1: support.function.any-method.c + 2: punctuation.definition.parameters.c + - include: $top_level_main + constructor: + - match: |- + (?x) + (?: ^\s*) # begin-of-line + ((?!while|for|do|if|else|switch|catch)[A-Za-z_][A-Za-z0-9_:]*) # actual name + \s*(\() # start bracket or end-of-line + captures: + 1: entity.name.function.c++ + 2: punctuation.definition.parameters.begin.c + push: + - meta_scope: meta.function.constructor.c++ + - match: \) + captures: + 0: punctuation.definition.parameters.end.c + pop: true + - include: $top_level_main + - match: |- + (?x) + (:) # begin-of-line + ((?=\s*[A-Za-z_][A-Za-z0-9_:]* # actual name + \s*(\())) # start bracket or end-of-line + captures: + 1: punctuation.definition.parameters.c + push: + - meta_scope: meta.function.constructor.initializer-list.c++ + - match: '(?=\{)' + pop: true + - include: $top_level_main + special_block: + - match: '\b(namespace)\b\s*([_A-Za-z][_A-Za-z0-9]*\b)?+' + captures: + 1: storage.type.c++ + 2: entity.name.type.c++ + push: + - meta_scope: "meta.namespace-block${2:+.$2}.c++" + - match: '(?<=\})|(?=(;|,|\(|\)|>|\[|\]|=))' + captures: + 1: keyword.control.namespace.$2 + pop: true + - match: '\{' + captures: + 0: punctuation.definition.scope.c++ + push: + - match: '\}' + captures: + 0: punctuation.definition.scope.c++ + pop: true + - include: special_block + - include: constructor + - include: $top_level_main + - include: $top_level_main + - match: '\b(class|struct)\b\s*([_A-Za-z][_A-Za-z0-9]*\b)?+(\s*:\s*(public|protected|private)\b\s*([_A-Za-z][_A-Za-z0-9]*\b)((\s*,\s*(public|protected|private)\b\s*[_A-Za-z][_A-Za-z0-9]*\b)*))?' + captures: + 1: storage.type.c++ + 2: entity.name.type.c++ + 4: storage.type.modifier.c++ + 5: entity.name.type.inherited.c++ + push: + - meta_scope: meta.class-struct-block.c++ + - match: '(?<=\})|(?=(;|\(|\)|>|\[|\]|=))' + pop: true + - include: angle_brackets + - match: '\{' + captures: + 0: punctuation.section.block.begin.c++ + push: + - match: '(\})(\s*\n)?' + captures: + 1: punctuation.definition.invalid.c++ + 2: invalid.illegal.you-forgot-semicolon.c++ + pop: true + - include: special_block + - include: constructor + - include: $top_level_main + - include: $top_level_main + - match: \b(extern)(?=\s*") + captures: + 1: storage.modifier.c++ + push: + - meta_scope: meta.extern-block.c++ + - match: '(?<=\})|(?=\w)' + pop: true + - match: '\{' + captures: + 0: punctuation.section.block.begin.c + push: + - match: '\}' + captures: + 0: punctuation.section.block.end.c + pop: true + - include: special_block + - include: $top_level_main + - include: $top_level_main + strings: + - match: (u|u8|U|L)?" + captures: + 0: punctuation.definition.string.begin.c++ + 1: meta.encoding.c++ + push: + - meta_scope: string.quoted.double.c++ + - match: '"' + captures: + 0: punctuation.definition.string.end.c++ + pop: true + - match: '\\u[0-9A-Fa-f]{4}|\\U[0-9A-Fa-f]{8}' + scope: constant.character.escape.c++ + - match: '\\[''"?\\abfnrtv]' + scope: constant.character.escape.c++ + - match: '\\[0-7]{1,3}' + scope: constant.character.escape.c++ + - match: '\\x[0-9A-Fa-f]+' + scope: constant.character.escape.c++ + - match: '(u|u8|U|L)?R"(?:([^ ()\\\t]{0,16})|([^ ()\\\t]*))\(' + captures: + 0: punctuation.definition.string.begin.c++ + 1: meta.encoding.c++ + 3: invalid.illegal.delimiter-too-long.c++ + push: + - meta_scope: string.quoted.double.raw.c++ + - match: \)\2(\3)" + captures: + 0: punctuation.definition.string.end.c++ + 1: invalid.illegal.delimiter-too-long.c++ + pop: true diff --git a/syntect/minimal_grammars/C.sublime-syntax b/syntect/minimal_grammars/C.sublime-syntax new file mode 100644 index 0000000..1614770 --- /dev/null +++ b/syntect/minimal_grammars/C.sublime-syntax @@ -0,0 +1,466 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: C +file_extensions: + - c + - h +first_line_match: "-[*]-( Mode:)? C -[*]-" +scope: source.c +contexts: + main: + - include: preprocessor-rule-enabled + - include: preprocessor-rule-disabled + - include: preprocessor-rule-other + - include: comments + - include: scope:source.c.platform + - match: \b(break|case|continue|default|do|else|for|goto|if|_Pragma|return|switch|while)\b + scope: keyword.control.c + - match: \b(asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void)\b + scope: storage.type.c + - match: \b(const|extern|register|restrict|static|volatile|inline)\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(NULL|true|false|TRUE|FALSE)\b + scope: constant.language.c + - include: sizeof + - match: |- + (?x)\b + ( (?i: + 0x ( [0-9A-Fa-f]+ ( ' [0-9A-Fa-f]+ )* )? # Hexadecimal + | 0b ( [0-1]+ ( ' [0-1]+ )* )? # Binary + | 0 ( [0-7]+ ( ' [0-7]+ )* ) # Octal + | ( [0-9]+ ( ' [0-9]+ )* ) # Decimal + ) + ( ([uUfF] | u?ll? | U?LL?)\b | (?') | \b ) + | ( [0-9]+ ( ' [0-9]+ )* )? + (?i: + \. ( [0-9]+ ( ' [0-9]+ )* ) E(\+|-)? ( [0-9]+ ( ' [0-9]+ )* ) + | \. ( [0-9]+ ( ' [0-9]+ )* ) + | E(\+|-)? ( [0-9]+ ( ' [0-9]+ )* ) + ) + ( (?') | \b ) + ) + scope: constant.numeric.c + captures: + inc: invalid.illegal.digit-separator-should-not-be-last.c++ + - 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* \g \s* # first argument + ((,) \s* \g \s*)* # additional arguments + (?:\.\.\.)? # varargs ellipsis? + ) + (\)) # a close parenthesis + )? + captures: + 1: keyword.control.import.define.c + 2: entity.name.function.preprocessor.c + 4: punctuation.definition.parameters.begin.c + 5: variable.parameter.preprocessor.c + 7: punctuation.separator.parameters.c + 8: punctuation.definition.parameters.end.c + push: + - meta_scope: meta.preprocessor.macro.c + - match: (?=(?://|/\*))|$ + pop: true + - match: (?>\\\s*\n) + scope: punctuation.separator.continuation.c + - include: $top_level_main + - match: ^\s*#\s*(error|warning)\b + captures: + 1: keyword.control.import.error.c + push: + - meta_scope: meta.preprocessor.diagnostic.c + - match: $ + captures: + 1: keyword.control.import.error.c + pop: true + - match: (?>\\\s*\n) + scope: punctuation.separator.continuation.c + - match: ^\s*#\s*(include|import)\b + captures: + 1: keyword.control.import.include.c + push: + - meta_scope: meta.preprocessor.c.include + - match: (?=(?://|/\*))|$ + captures: + 1: keyword.control.import.include.c + 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 + - include: pragma-mark + - 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: (?=(?://|/\*))|$ + captures: + 1: keyword.control.import.c + pop: true + - match: (?>\\\s*\n) + scope: punctuation.separator.continuation.c + - match: '\b([a-z0-9_]+_t)\b' + comment: Reserved POSIX types + scope: support.type.posix-reserved.c + - include: block + - match: |- + (?x) + (?: ^ # begin-of-line + | + (?: (?= \s ) (?]) # or type modifier before name + ) + ) + (\s*) (?!(while|for|do|if|else|switch|catch|enumerate|return|sizeof|[cr]?iterate|(?:::)?new|(?:::)?delete)\s*\() + ( + (?: [A-Za-z_][A-Za-z0-9_]*+ | :: )++ | # actual name + (?: (?<=operator) (?: [-*&<>=+!]+ | \(\) | \[\] ) ) # if it is a C++ operator + ) + \s*(?=\() + captures: + 1: punctuation.whitespace.function.leading.c + 3: entity.name.function.c + 4: punctuation.definition.parameters.c + push: + - meta_scope: meta.function.c + - match: '(?<=\})|(?=#)|(;)' + pop: true + - include: comments + - include: parens + - match: \b(const|final|override|noexcept)\b + scope: storage.modifier.$1.c++ + - include: block + access: + - match: '(\.|\->)(?:\s*(template)\s+)?([a-zA-Z_][a-zA-Z_0-9]*)\b(?!\s*\()' + captures: + 1: punctuation.separator.variable-access.c + 2: storage.modifier.template.c++ + 3: variable.other.dot-access.c + block: + - match: '\{' + captures: + 0: punctuation.section.block.begin.c + push: + - meta_scope: meta.block.c + - match: '\}' + captures: + 0: punctuation.section.block.end.c + pop: true + - include: block_innards + block_innards: + - include: preprocessor-rule-enabled-block + - include: preprocessor-rule-disabled-block + - include: preprocessor-rule-other-block + - include: sizeof + - include: access + - include: scope:source.c.platform#functions + - include: c_function_call + - match: |- + (?x) + (?x) + (?: + (?: (?= \s ) (?=+!]+ | \(\) | \[\] ) )? # if it is a C++ operator + ) + \s*(\() + scope: meta.initialization.c + captures: + 1: variable.other.c + 2: punctuation.definition.parameters.c + - include: block + - include: $top_level_main + c_function_call: + - match: |- + (?x) (?: (?= \s ) (?:(?<=else|new|return) | (?\\\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 + parens: + - match: \( + captures: + 0: punctuation.section.parens.begin.c + push: + - meta_scope: meta.parens.c + - match: \) + captures: + 0: punctuation.section.parens.end.c + pop: true + - include: $top_level_main + 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.if.c + 3: constant.numeric.preprocessor.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) + captures: + 1: meta.preprocessor.c + 2: keyword.control.import.else.c + 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-disabled-block: + - 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.if.c + 3: constant.numeric.preprocessor.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) + captures: + 1: meta.preprocessor.c + 2: keyword.control.import.else.c + pop: true + - include: block_innards + - match: "" + push: + - meta_scope: comment.block.preprocessor.if-branch.in-block + - 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.if.c + 3: constant.numeric.preprocessor.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) + captures: + 1: meta.preprocessor.c + 2: keyword.control.import.else.c + pop: true + - include: disabled + - include: pragma-mark + - match: "" + push: + - match: (?=^\s*#\s*(else|endif)\b) + pop: true + - include: $top_level_main + preprocessor-rule-enabled-block: + - 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.if.c + 3: constant.numeric.preprocessor.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.in-block + - match: (?=^\s*#\s*endif\b) + captures: + 1: meta.preprocessor.c + 2: keyword.control.import.else.c + pop: true + - include: disabled + - include: pragma-mark + - match: "" + push: + - match: (?=^\s*#\s*(else|endif)\b) + pop: true + - include: block_innards + 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.c + pop: true + - include: $top_level_main + preprocessor-rule-other-block: + - 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.c + pop: true + - include: block_innards + sizeof: + - match: \b(sizeof)\b + scope: keyword.operator.sizeof.c + string_escaped_char: + - 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})' + 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 diff --git a/syntect/minimal_grammars/Cython.sublime-syntax b/syntect/minimal_grammars/Cython.sublime-syntax new file mode 100644 index 0000000..6d49852 --- /dev/null +++ b/syntect/minimal_grammars/Cython.sublime-syntax @@ -0,0 +1,961 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: Cython +comment: | + todo: + list comprehension / generator comprehension scope. +file_extensions: + - pyx + - pxi + - pxd +first_line_match: ^#!/.*\bcython\b +scope: source.cython +contexts: + main: + - match: '(^[ \t]+)?(?=#)' + captures: + 1: punctuation.whitespace.comment.leading.cython + push: + - match: (?!\G) + pop: true + - match: "#" + captures: + 0: punctuation.definition.comment.cython + push: + - meta_scope: comment.line.number-sign.cython + - match: \n + pop: true + - match: '\b(?i:(0x[0-9A-Fa-f]*)L)' + scope: constant.numeric.integer.long.hexadecimal.cython + - match: '\b(?i:(0x[0-9A-Fa-f]*))' + scope: constant.numeric.integer.hexadecimal.cython + - match: '\b(?i:(0[0-7]+)L)' + scope: constant.numeric.integer.long.octal.cython + - match: '\b(0[0-7]+)' + scope: constant.numeric.integer.octal.cython + - match: '\b(?i:(((\d+(\.(?=[^a-zA-Z_])\d*)?|(?<=[^0-9a-zA-Z_])\.\d+)(e[\-\+]?\d+)?))J)' + scope: constant.numeric.complex.cython + - match: '\b(?i:(\d+\.\d*(e[\-\+]?\d+)?))(?=[^a-zA-Z_])' + scope: constant.numeric.float.cython + - match: '(?<=[^0-9a-zA-Z_])(?i:(\.\d+(e[\-\+]?\d+)?))' + scope: constant.numeric.float.cython + - match: '\b(?i:(\d+e[\-\+]?\d+))' + scope: constant.numeric.float.cython + - match: '\b(?i:([1-9]+[0-9]*|0)L)' + scope: constant.numeric.integer.long.decimal.cython + - match: '\b([1-9]+[0-9]*|0)' + scope: constant.numeric.integer.decimal.cython + - match: \b(global)\b + captures: + 1: storage.modifier.global.cython + - match: \b(?:(import|include)|(from))\b + captures: + 1: keyword.control.import.cython + 2: keyword.control.import.from.cython + - match: \b(elif|else|except|finally|for|if|try|while|with|IF|ELIF|ELSE)\b + comment: keywords that delimit flow blocks + scope: keyword.control.flow.cython + - match: \b(break|continue|pass|raise|return|yield)\b + comment: keywords that alter flow from within a block + scope: keyword.control.flow.cython + - match: \b(and|in|is|not|or)\b + comment: keyword operators that evaluate to True or False + scope: keyword.operator.logical.cython + - match: \b(as|assert|del|exec|print)\b + comment: keywords that haven't fit into other groups (yet). + captures: + 1: keyword.other.cython + - match: \b(asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void)\b + scope: storage.type.cython + - match: <\=|>\=|\=\=|<|>|<> + scope: keyword.operator.comparison.cython + - match: \+\=|-\=|\*\=|/\=|//\=|%\=|&\=|\|\=|\^\=|>>\=|<<\=|\*\*\= + scope: keyword.operator.assignment.augmented.cython + - match: \+|\-|\*|\*\*|/|//|%|<<|>>|&|\||\^|~ + scope: keyword.operator.arithmetic.cython + - match: \= + scope: keyword.operator.assignment.cython + - match: '^\s*(class)\s+(?=[a-zA-Z_][a-zA-Z_0-9]*\s*\:)' + captures: + 1: storage.type.class.cython + push: + - meta_scope: meta.class.old-style.cython + - meta_content_scope: entity.name.type.class.cython + - match: \s*(:) + captures: + 1: punctuation.section.class.begin.cython + pop: true + - include: entity_name_class + - match: '^\s*(property)\s+(?=[a-zA-Z_][a-zA-Z_0-9]*\s*\:)' + captures: + 1: storage.type.property.cython + push: + - meta_scope: meta.property.cython + - meta_content_scope: entity.name.type.property.cython + - match: \s*(:) + captures: + 1: punctuation.section.property.begin.cython + pop: true + - match: '^\s*(class)\s+(?=[a-zA-Z_][a-zA-Z_0-9]*\s*\()' + captures: + 1: storage.type.class.cython + push: + - meta_scope: meta.class.cython + - match: (\))\s*(?:(\:)|(.*$\n?)) + captures: + 1: punctuation.definition.inheritance.end.cython + 2: punctuation.section.class.begin.cython + 3: invalid.illegal.missing-section-begin.cython + pop: true + - match: "(?=[A-Za-z_][A-Za-z0-9_]*)" + push: + - meta_content_scope: entity.name.type.class.cython + - match: "(?![A-Za-z0-9_])" + pop: true + - include: entity_name_class + - match: (\() + captures: + 1: punctuation.definition.inheritance.begin.cython + push: + - meta_content_scope: meta.class.inheritance.cython + - match: (?=\)|:) + pop: true + - match: (?<=\(|,)\s* + push: + - meta_content_scope: entity.other.inherited-class.cython + - match: \s*(?:(,)|(?=\))) + captures: + 1: punctuation.separator.inheritance.cython + pop: true + - include: main + - match: '^\s*(class)\s+(?=[a-zA-Z_][a-zA-Z_0-9])' + captures: + 1: storage.type.class.cython + push: + - meta_scope: meta.class.cython + - match: (\()|\s*($\n?|#.*$\n?) + captures: + 1: punctuation.definition.inheritance.begin.cython + 2: invalid.illegal.missing-inheritance.cython + pop: true + - match: "(?=[A-Za-z_][A-Za-z0-9_]*)" + push: + - meta_content_scope: entity.name.type.class.cython + - match: "(?![A-Za-z0-9_])" + pop: true + - include: entity_name_function + - match: '^\s*(def)\s+(?=[A-Za-z_][A-Za-z0-9_]*\s*\()' + captures: + 1: storage.type.function.cython + push: + - meta_scope: meta.function.cython + - match: (\))\s*(?:(\:)|(.*$\n?)) + captures: + 1: punctuation.definition.parameters.end.cython + 2: punctuation.section.function.begin.cython + 3: invalid.illegal.missing-section-begin.cython + pop: true + - match: "(?=[A-Za-z_][A-Za-z0-9_]*)" + push: + - meta_content_scope: entity.name.function.cython + - match: "(?![A-Za-z0-9_])" + pop: true + - include: entity_name_function + - match: (\() + captures: + 1: punctuation.definition.parameters.begin.cython + push: + - meta_content_scope: meta.function.parameters.cython + - match: (?=\)\s*\:) + pop: true + - include: keyword_arguments + - match: '\b([a-zA-Z_][a-zA-Z_0-9]*)\s*(?:(,)|(?=[\n\)]))' + captures: + 1: variable.parameter.function.cython + 2: punctuation.separator.parameters.cython + - match: '^\s*(def)\s+(?=[A-Za-z_][A-Za-z0-9_]*)' + captures: + 1: storage.type.function.cython + push: + - meta_scope: meta.function.cython + - match: (\()|\s*($\n?|#.*$\n?) + captures: + 1: punctuation.definition.parameters.begin.cython + 2: invalid.illegal.missing-parameters.cython + pop: true + - match: "(?=[A-Za-z_][A-Za-z0-9_]*)" + push: + - meta_content_scope: entity.name.function.cython + - match: "(?![A-Za-z0-9_])" + pop: true + - include: entity_name_function + - match: (lambda)(?=\s+) + captures: + 1: storage.type.function.inline.cython + push: + - meta_scope: meta.function.inline.cython + - match: (\:) + captures: + 1: punctuation.definition.parameters.end.cython + 2: punctuation.section.function.begin.cython + 3: invalid.illegal.missing-section-begin.cython + pop: true + - match: \s+ + push: + - meta_content_scope: meta.function.inline.parameters.cython + - match: (?=\:) + pop: true + - include: keyword_arguments + - match: '\b([a-zA-Z_][a-zA-Z_0-9]*)\s*(?:(,)|(?=[\n\)\:]))' + captures: + 1: variable.parameter.function.cython + 2: punctuation.separator.parameters.cython + - match: '^\s*(?=@\s*[A-Za-z_][A-Za-z0-9_]*(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*\s*\()' + comment: a decorator may be a function call which returns a decorator. + push: + - meta_scope: meta.function.decorator.cython + - match: (\)) + captures: + 1: punctuation.definition.arguments.end.cython + pop: true + - match: '(?=(@)\s*[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)*\s*\()' + captures: + 1: punctuation.definition.decorator.cython + push: + - meta_content_scope: entity.name.function.decorator.cython + - match: (?=\s*\() + pop: true + - include: dotted_name + - match: (\() + captures: + 1: punctuation.definition.arguments.begin.cython + push: + - meta_content_scope: meta.function.decorator.arguments.cython + - match: (?=\)) + pop: true + - include: keyword_arguments + - include: main + - match: '^\s*(?=@\s*[A-Za-z_][A-Za-z0-9_]*(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*)' + push: + - meta_scope: meta.function.decorator.cython + - meta_content_scope: entity.name.function.decorator.cython + - match: (?=\s|$\n?|#) + pop: true + - match: '(?=(@)\s*[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*)' + captures: + 1: punctuation.definition.decorator.cython + push: + - match: (?=\s|$\n?|#) + pop: true + - include: dotted_name + - match: '(?<=\)|\])\s*(\()' + captures: + 1: punctuation.definition.arguments.begin.cython + push: + - meta_scope: meta.function-call.cython + - meta_content_scope: meta.function-call.arguments.cython + - match: (\)) + captures: + 1: punctuation.definition.arguments.end.cython + pop: true + - include: keyword_arguments + - include: main + - match: '(?=[A-Za-z_][A-Za-z0-9_]*(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*\s*\()' + push: + - meta_scope: meta.function-call.cython + - match: (\)) + captures: + 1: punctuation.definition.arguments.end.cython + pop: true + - match: '(?=[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)*\s*\()' + push: + - match: (?=\s*\() + pop: true + - include: dotted_name + - match: (\() + captures: + 1: punctuation.definition.arguments.begin.cython + push: + - meta_content_scope: meta.function-call.arguments.cython + - match: (?=\)) + pop: true + - include: keyword_arguments + - include: main + - match: '(?=[A-Za-z_][A-Za-z0-9_]*(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*\s*\[)' + push: + - meta_scope: meta.item-access.cython + - match: '(\])' + captures: + 1: punctuation.definition.arguments.end.cython + pop: true + - match: '(?=[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)*\s*\[)' + push: + - match: '(?=\s*\[)' + pop: true + - include: dotted_name + - match: '(\[)' + captures: + 1: punctuation.definition.arguments.begin.cython + push: + - meta_content_scope: meta.item-access.arguments.cython + - match: '(?=\])' + pop: true + - include: main + - match: '(?<=\)|\])\s*(\[)' + captures: + 1: punctuation.definition.arguments.begin.cython + push: + - meta_scope: meta.item-access.cython + - meta_content_scope: meta.item-access.arguments.cython + - match: '(\])' + captures: + 1: punctuation.definition.arguments.end.cython + pop: true + - include: main + - match: \b(def|lambda)\b + captures: + 1: storage.type.function.cython + - match: \b(class)\b + captures: + 1: storage.type.class.cython + - include: line_continuation + - include: language_variables + - match: \b(None|True|False|Ellipsis|NotImplemented|NULL)\b + scope: constant.language.cython + - include: string_quoted_single + - include: string_quoted_double + - include: dotted_name + - match: (\() + push: + - match: (\)) + pop: true + - include: main + - match: '(\[)(\s*(\]))\b' + captures: + 1: punctuation.definition.list.begin.cython + 2: meta.empty-list.cython + 3: punctuation.definition.list.end.cython + - match: '(\[)' + captures: + 1: punctuation.definition.list.begin.cython + push: + - meta_scope: meta.structure.list.cython + - match: '(\])' + captures: + 1: punctuation.definition.list.end.cython + pop: true + - match: '(?<=\[|\,)\s*(?![\],])' + push: + - meta_content_scope: meta.structure.list.item.cython + - match: '\s*(?:(,)|(?=\]))' + captures: + 1: punctuation.separator.list.cython + pop: true + - include: main + - match: (\()(\s*(\))) + scope: meta.structure.tuple.cython + captures: + 1: punctuation.definition.tuple.begin.cython + 2: meta.empty-tuple.cython + 3: punctuation.definition.tuple.end.cython + - match: '(\{)(\s*(\}))' + scope: meta.structure.dictionary.cython + captures: + 1: punctuation.definition.dictionary.begin.cython + 2: meta.empty-dictionary.cython + 3: punctuation.definition.dictionary.end.cython + - match: '(\{)' + captures: + 1: punctuation.definition.dictionary.begin.cython + push: + - meta_scope: meta.structure.dictionary.cython + - match: '(\})' + captures: + 1: punctuation.definition.dictionary.end.cython + pop: true + - match: '(?<=\{|\,|^)\s*(?![\},])' + push: + - meta_content_scope: meta.structure.dictionary.key.cython + - match: '\s*(?:(?=\})|(\:))' + captures: + 1: punctuation.separator.valuepair.dictionary.cython + pop: true + - include: main + - match: (?<=\:|^)\s* + push: + - meta_content_scope: meta.structure.dictionary.value.cython + - match: '\s*(?:(?=\})|(,))' + captures: + 1: punctuation.separator.dictionary.cython + pop: true + - include: main + builtin_exceptions: + - match: (?x)\b((Arithmetic|Assertion|Attribute|EOF|Environment|FloatingPoint|IO|Import|Indentation|Index|Key|Lookup|Memory|Name|OS|Overflow|NotImplemented|Reference|Runtime|Standard|Syntax|System|Tab|Type|UnboundLocal|Unicode(Translate|Encode|Decode)?|Value|ZeroDivision)Error|(Deprecation|Future|Overflow|PendingDeprecation|Runtime|Syntax|User)?Warning|KeyboardInterrupt|NotImplemented|StopIteration|SystemExit|(Base)?Exception)\b + scope: support.type.exception.cython + builtin_functions: + - match: |- + (?x)\b( + __import__|all|abs|any|apply|callable|chr|cmp|coerce|compile|delattr|dir| + divmod|eval|execfile|filter|getattr|globals|hasattr|hash|hex|id| + input|intern|isinstance|issubclass|iter|len|locals|map|max|min|oct| + ord|pow|range|raw_input|reduce|reload|repr|round|setattr|sorted| + sum|unichr|vars|zip + )\b + scope: support.function.builtin.cython + builtin_types: + - match: |- + (?x)\b( + basestring|bool|buffer|classmethod|complex|dict|enumerate|file| + float|frozenset|int|list|long|object|open|reversed|set| + slice|staticmethod|str|super|tuple|type|unicode|xrange + )\b + scope: support.type.cython + constant_placeholder: + - match: '(?i:%(\([a-z_]+\))?#?0?\-?[ ]?\+?([0-9]*|\*)(\.([0-9]*|\*))?[hL]?[a-z%])' + scope: constant.other.placeholder.cython + docstrings: + - match: '^\s*(?=[uU]?[rR]?""")' + push: + - meta_scope: comment.block.cython + - match: (?<=""") + pop: true + - include: string_quoted_double + - match: '^\s*(?=[uU]?[rR]?'''''')' + push: + - meta_scope: comment.block.cython + - match: (?<=''') + pop: true + - include: string_quoted_single + dotted_name: + - match: '(?=[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)*)' + push: + - match: '(?![A-Za-z0-9_\.])' + pop: true + - match: '(\.)(?=[A-Za-z_][A-Za-z0-9_]*)' + push: + - match: "(?![A-Za-z0-9_])" + pop: true + - include: magic_function_names + - include: magic_variable_names + - include: illegal_names + - include: generic_names + - match: '(?)( .*)?)|((\+).*))$\n? + scope: markup.inserted.diff + captures: + 3: punctuation.definition.inserted.diff + 6: punctuation.definition.inserted.diff + - match: ^(!).*$\n? + scope: markup.changed.diff + captures: + 1: punctuation.definition.changed.diff + - match: ^(((<)( .*)?)|((-).*))$\n? + scope: markup.deleted.diff + captures: + 3: punctuation.definition.deleted.diff + 6: punctuation.definition.deleted.diff + - match: ^(#) + comment: Git produces unified diffs with embedded comments" + captures: + 1: punctuation.definition.comment.diff + push: + - meta_scope: comment.line.number-sign.diff + - match: \n + captures: + 1: punctuation.definition.comment.diff + pop: true + - match: '^index [0-9a-f]{7,40}\.\.[0-9a-f]{7,40}.*$\n?' + scope: meta.diff.index.git + - match: ^Index(:) (.+)$\n? + scope: meta.diff.index + captures: + 1: punctuation.separator.key-value.diff + 2: meta.toc-list.file-name.diff + - match: '^Only in .*: .*$\n?' + scope: meta.diff.only-in diff --git a/syntect/minimal_grammars/Fortran - Modern.sublime-syntax b/syntect/minimal_grammars/Fortran - Modern.sublime-syntax new file mode 100644 index 0000000..e6aff96 --- /dev/null +++ b/syntect/minimal_grammars/Fortran - Modern.sublime-syntax @@ -0,0 +1,168 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: Fortran - Modern +comment: Specificities of Fortran >= 90 +file_extensions: + - f90 + - F90 + - f95 + - F95 + - f03 + - F03 + - f08 + - F08 +first_line_match: "(?i)-[*]- mode: f90 -[*]-" +scope: source.fortran.modern +contexts: + main: + - include: scope:source.fortran + - match: |- + (?x: # extended mode + ^ + \s* # start of line and possibly some space + (?i:(interface)) # 1: word interface + \s+ # some space + (?i:(operator|assignment)) # 2: the words operator or assignment + \( # opening parenthesis + ((\.[a-zA-Z0-9_]+\.)|[\+\-\=\/\*]+) # 3: an operator + + \) # closing parenthesis + ) + comment: Interface declaration of operator/assignments + captures: + 1: storage.type.function.fortran + 2: storage.type.fortran + 3: keyword.operator.fortran + push: + - meta_scope: meta.function.interface.operator.fortran.modern + - match: |- + (?xi) + (end)(?=\s|\z) # 1: the word end + (?: + \s+ + (interface) # 2: possibly interface + )? + captures: + 1: keyword.other.fortran + 2: storage.type.function.fortran + pop: true + - include: main + - match: |- + (?x: # extended mode + ^ + \s* # start of line and possibly some space + (?i:(interface)) # 1: word interface + \s+ # some space + ([A-Za-z_][A-Za-z0-9_]*) # 1: name + ) + comment: Interface declaration of function/subroutines + captures: + 1: storage.type.function.fortran + 2: entity.name.function.fortran + push: + - meta_scope: meta.function.interface.fortran.modern + - match: |- + (?xi) + (end)(?=\s|\z) # 1: the word end + (?: + \s+ + (interface) # 2: possibly interface + )? + captures: + 1: keyword.other.fortran + 2: storage.type.function.fortran + pop: true + - include: main + - match: |- + (?x: # extended mode + ^\s* # begining of line and some space + (?i:(type)) # 1: word type + \s+ # some space + ([a-zA-Z_][a-zA-Z0-9_]*) # 2: type name + ) + comment: Type definition + captures: + 1: storage.type.fortran.modern + 2: entity.name.type.fortran.modern + push: + - meta_scope: meta.type-definition.fortran.modern + - match: |- + (?xi) + (end)(?=\s|\z) # 1: the word end + (?: + \s+ + (type) # 2: possibly the word type + (\s+[A-Za-z_][A-Za-z0-9_]*)? # 3: possibly the name + )? + captures: + 1: keyword.other.fortran + 2: storage.type.fortran.modern + 3: entity.name.type.end.fortran.modern + pop: true + - include: main + - match: '(^[ \t]+)?(?=!-)' + captures: + 1: punctuation.whitespace.comment.leading.fortran + push: + - match: (?!\G) + pop: true + - match: "!-" + captures: + 0: punctuation.definition.comment.fortran + push: + - meta_scope: comment.line.exclamation.mark.fortran.modern + - match: \n + pop: true + - match: \\\s*\n + - match: '(^[ \t]+)?(?=!)' + captures: + 1: punctuation.whitespace.comment.leading.fortran + push: + - match: (?!\G) + pop: true + - match: "!" + captures: + 0: punctuation.definition.comment.fortran + push: + - meta_scope: comment.line.exclamation.fortran.modern + - match: \n + pop: true + - match: \\\s*\n + - match: \b(?i:(select\s+case|case(\s+default)?|end\s+select|use|(end\s+)?forall))\b + comment: statements controling the flow of the program + scope: keyword.control.fortran.modern + - match: \b(?i:(access|action|advance|append|apostrophe|asis|blank|delete|delim|direct|end|eor|err|exist|file|fmt|form|formatted|iolength|iostat|keep|name|named|nextrec|new|nml|no|null|number|old|opened|pad|position|quote|read|readwrite|rec|recl|replace|scratch|sequential|size|status|undefined|unformatted|unit|unknown|write|yes|zero|namelist)(?=\()) + comment: input/output instrinsics + scope: keyword.control.io.fortran.modern + - match: \b(\=\=|\/\=|\>\=|\>|\<|\<\=)\b + comment: logical operators in symbolic format + scope: keyword.operator.logical.fortran.modern + - match: (\%|\=\>) + comment: operators + scope: keyword.operator.fortran.modern + - match: \b(?i:(ceiling|floor|modulo)(?=\()) + comment: numeric instrinsics + scope: keyword.other.instrinsic.numeric.fortran.modern + - match: \b(?i:(allocate|allocated|deallocate)(?=\()) + comment: matrix/vector/array instrinsics + scope: keyword.other.instrinsic.array.fortran.modern + - match: \b(?i:(associated)(?=\()) + comment: pointer instrinsics + scope: keyword.other.instrinsic.pointer.fortran.modern + - match: \b(?i:((end\s*)?(interface|procedure|module)))\b + comment: programming units + scope: keyword.other.programming-units.fortran.modern + - match: \b(?i:(type(?=\s*\()))\b(?=.*::) + comment: Line of type specification + captures: + 1: storage.type.fortran.modern + push: + - meta_scope: meta.specification.fortran.modern + - match: (?=!)|$ + pop: true + - include: $top_level_main + - match: \b(?i:(type(?=\s*\()))\b + scope: storage.type.fortran.modern + - match: \b(?i:(optional|recursive|pointer|allocatable|target|private|public))\b + scope: storage.modifier.fortran.modern diff --git a/syntect/minimal_grammars/JSON.sublime-syntax b/syntect/minimal_grammars/JSON.sublime-syntax new file mode 100644 index 0000000..2e042b0 --- /dev/null +++ b/syntect/minimal_grammars/JSON.sublime-syntax @@ -0,0 +1,102 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: JSON +file_extensions: + - json +scope: source.json +contexts: + main: + - include: value + array: + - match: '\[' + captures: + 0: punctuation.definition.array.begin.json + push: + - meta_scope: meta.structure.array.json + - match: '\]' + captures: + 0: punctuation.definition.array.end.json + pop: true + - include: value + - match: "," + scope: punctuation.separator.array.json + - match: '[^\s\]]' + scope: invalid.illegal.expected-array-separator.json + constant: + - match: \b(?:true|false|null)\b + scope: constant.language.json + number: + - match: |- + (?x: # turn on extended mode + -? # an optional minus + (?: + 0 # a zero + | # ...or... + [1-9] # a 1-9 character + \d* # followed by zero or more digits + ) + (?: + (?: + \. # a period + \d+ # followed by one or more digits + )? + (?: + [eE] # an e character + [+-]? # followed by an option +/- + \d+ # followed by one or more digits + )? # make exponent optional + )? # make decimal portion optional + ) + comment: handles integer and decimal numbers + scope: constant.numeric.json + object: + - match: '\{' + comment: a JSON object + captures: + 0: punctuation.definition.dictionary.begin.json + push: + - meta_scope: meta.structure.dictionary.json + - match: '\}' + captures: + 0: punctuation.definition.dictionary.end.json + pop: true + - include: string + - match: ":" + captures: + 0: punctuation.separator.dictionary.key-value.json + push: + - meta_scope: meta.structure.dictionary.value.json + - match: '(,)|(?=\})' + captures: + 1: punctuation.separator.dictionary.pair.json + pop: true + - include: value + - match: '[^\s,]' + scope: invalid.illegal.expected-dictionary-separator.json + - match: '[^\s\}]' + scope: invalid.illegal.expected-dictionary-separator.json + string: + - match: '"' + captures: + 0: punctuation.definition.string.begin.json + push: + - meta_scope: string.quoted.double.json + - match: '"' + captures: + 0: punctuation.definition.string.end.json + pop: true + - match: |- + (?x: # turn on extended mode + \\ # a literal backslash + (?: # ...followed by... + ["\\/bfnrt] # one of these characters + | # ...or... + u # a u + [0-9a-fA-F]{4} # and four hex digits + ) + ) + scope: constant.character.escape.json + - match: \\. + scope: invalid.illegal.unrecognized-string-escape.json + value: [] diff --git a/syntect/minimal_grammars/Java.sublime-syntax b/syntect/minimal_grammars/Java.sublime-syntax new file mode 100644 index 0000000..4462855 --- /dev/null +++ b/syntect/minimal_grammars/Java.sublime-syntax @@ -0,0 +1,549 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: Java +file_extensions: + - java + - bsh +scope: source.java +contexts: + main: + - match: '^\s*(package)\b(?:\s*([^ ;$]+)\s*(;)?)?' + scope: meta.package.java + captures: + 1: keyword.other.package.java + 2: storage.modifier.package.java + 3: punctuation.terminator.java + - match: (import static)\b\s* + captures: + 1: keyword.other.import.static.java + push: + - meta_scope: meta.import.java + - meta_content_scope: storage.modifier.import.java + - match: \s*(?:$|(;)) + captures: + 1: punctuation.terminator.java + pop: true + - match: \. + scope: punctuation.separator.java + - match: \s + scope: invalid.illegal.character_not_allowed_here.java + - match: (import)\b\s* + captures: + 1: keyword.other.import.java + push: + - meta_scope: meta.import.java + - meta_content_scope: storage.modifier.import.java + - match: \s*(?:$|(;)) + captures: + 1: punctuation.terminator.java + pop: true + - match: \. + scope: punctuation.separator.java + - match: \s + scope: invalid.illegal.character_not_allowed_here.java + - include: code + all-types: + - include: primitive-arrays + - include: primitive-types + - include: object-types + annotations: + - match: '(@[^ (]+)(\()' + captures: + 1: storage.type.annotation.java + 2: punctuation.definition.annotation-arguments.begin.java + push: + - meta_scope: meta.declaration.annotation.java + - match: (\)) + captures: + 1: punctuation.definition.annotation-arguments.end.java + pop: true + - match: (\w*)\s*(=) + captures: + 1: constant.other.key.java + 2: keyword.operator.assignment.java + - include: code + - match: "," + scope: punctuation.separator.property.java + - match: '@\w*' + scope: storage.type.annotation.java + anonymous-classes-and-new: + - match: \bnew\b + captures: + 0: keyword.control.new.java + push: + - match: '(?<=\)|\])(?!\s*{)|(?<=})|(?=;)' + pop: true + - match: '(\w+)\s*(?=\[)' + captures: + 1: storage.type.java + push: + - match: '(})|(?=\s*(?:,|;|\)))' + captures: + 1: punctuation.section.block.end.java + pop: true + - match: '\[' + push: + - match: '\]' + pop: true + - include: code + - match: "{" + captures: + 0: punctuation.section.block.begin.java + push: + - match: "(?=})" + pop: true + - include: code + - match: (?=\w.*\() + push: + - match: (?<=\)) + pop: true + - include: object-types + - match: \( + captures: + 1: storage.type.java + push: + - match: \) + pop: true + - include: code + - match: "{" + captures: + 0: punctuation.section.inner-class.begin.java + push: + - meta_scope: meta.inner-class.java + - match: "}" + captures: + 0: punctuation.section.inner-class.end.java + pop: true + - include: class-body + assertions: + - match: \b(assert)\s + captures: + 1: keyword.control.assert.java + push: + - meta_scope: meta.declaration.assertion.java + - match: $ + pop: true + - match: ":" + scope: keyword.operator.assert.expression-seperator.java + - include: code + class: + - match: '(?=\w?[\w\s]*(?:class|(?:@)?interface|enum)\s+\w+)' + push: + - meta_scope: meta.class.java + - match: "}" + captures: + 0: punctuation.section.class.end.java + pop: true + - include: storage-modifiers + - include: comments + - match: (class|(?:@)?interface|enum)\s+(\w+) + scope: meta.class.identifier.java + captures: + 1: storage.modifier.java + 2: entity.name.type.class.java + - match: extends + captures: + 0: storage.modifier.extends.java + push: + - meta_scope: meta.definition.class.inherited.classes.java + - match: "(?={|implements)" + pop: true + - include: object-types-inherited + - include: comments + - match: (implements)\s + captures: + 1: storage.modifier.implements.java + push: + - meta_scope: meta.definition.class.implemented.interfaces.java + - match: '(?=\s*extends|\{)' + pop: true + - include: object-types-inherited + - include: comments + - match: "{" + captures: + 0: punctuation.section.class.begin.java + push: + - meta_scope: meta.class.body.java + - match: "(?=})" + pop: true + - include: class-body + class-body: + - include: comments + - include: class + - include: enums + - include: variables + - include: methods + - include: annotations + - include: storage-modifiers + - include: code + code: + - include: comments + - include: class + - match: "{" + captures: + 0: punctuation.section.block.begin.java + push: + - match: "}" + captures: + 0: punctuation.section.block.end.java + pop: true + - include: code + - include: assertions + - include: parens + - include: constants-and-special-vars + - include: anonymous-classes-and-new + - include: annotations + - include: keywords + - include: storage-modifiers + - include: method-call + - include: strings + - include: all-types + comments: + - match: /\*\*/ + scope: comment.block.empty.java + captures: + 0: punctuation.definition.comment.java + - include: scope:text.html.javadoc + - include: comments-inline + comments-inline: + - match: /\* + captures: + 0: punctuation.definition.comment.java + push: + - meta_scope: comment.block.java + - match: \*/ + captures: + 0: punctuation.definition.comment.java + pop: true + - match: '(^[ \t]+)?(?=//)' + captures: + 1: punctuation.whitespace.comment.leading.java + push: + - match: (?!\G) + pop: true + - match: // + captures: + 0: punctuation.definition.comment.java + push: + - meta_scope: comment.line.double-slash.java + - match: \n + pop: true + constants-and-special-vars: + - match: \b(true|false|null)\b + scope: constant.language.java + - match: \b(this|super)\b + scope: variable.language.java + - match: '\b0[xX][0-9A-Fa-f]([0-9A-Fa-f_]*[0-9A-Fa-f])?[lL]?(?!\w|\.)' + scope: constant.numeric.hex.java + - match: '\b0[0-7_]*[0-7][lL]?\b' + scope: constant.numeric.octal.java + - match: '\b0[bB][01]([01_]*[01])?[lL]?\b' + scope: constant.numeric.binary.java + - match: '\b(0|[1-9]([0-9_]*[0-9])?)[lL]?(?!\w|\.)' + scope: constant.numeric.integer.java + - match: |- + (?x) + (? + 0[xX] # Start literal + ([0-9A-Fa-f]([0-9A-Fa-f_]*[0-9A-Fa-f])?)? # Optional Number + ( + (?<=[0-9A-Fa-f])\. # A number must exist on + | \.(?=[0-9A-Fa-f]) # one side of the decimal + | (?<=[0-9A-Fa-f]) # Decimal not required + ) + ([0-9A-Fa-f]([0-9A-Fa-f_]*[0-9A-Fa-f])?)? # Optional Number + [pP] # Exponent Indicator + [+-]?(0|[1-9]([0-9_]*[0-9])?) # Signed Integer + [fFdD]? # Float Type Suffix + ) + (?!\w) # Ensure word boundry + scope: constant.numeric.hex-float.java + - match: |- + (?x) + (? + ( + (0|[1-9]([0-9_]*[0-9])?) # Leading digits + (?=[eEfFdD.]) # Allow for numbers without . + )? + ( + (?<=[0-9])(?=[eEfFdD]) # Allow for numbers without . + | \. + ) + ( + [0-9]([0-9_]*[0-9])? # Numbers after . + )? + ( + [eE][+-]?(0|[1-9]([0-9_]*[0-9])?) # Exponent + )? + [fFdD]? # Float Type Suffix + ) + (?!\w) # Ensure word boundry + scope: constant.numeric.float.java + - match: '(\.)?\b([A-Z][A-Z0-9_]+)(?!<|\.class|\s*\w+\s*=)\b' + scope: constant.other.java + captures: + 1: keyword.operator.dereference.java + enums: + - match: '^(?=\s*[A-Z0-9_]+\s*({|\(|,))' + push: + - match: "(?=;|})" + pop: true + - match: \w+ + captures: + 0: constant.other.enum.java + push: + - meta_scope: meta.enum.java + - match: "(?=,|;|})" + pop: true + - include: parens + - match: "{" + captures: + 0: punctuation.section.enum.begin.java + push: + - match: "}" + captures: + 0: punctuation.section.enum.end.java + pop: true + - include: class-body + - include: comments + - include: annotations + keywords: + - match: \b(try|catch|finally|throw)\b + scope: keyword.control.catch-exception.java + - match: '\?|:' + scope: keyword.control.ternary.java + - match: \b(return|break|case|continue|default|do|while|for|switch|if|else)\b + scope: keyword.control.java + - match: \b(instanceof)\b + scope: keyword.operator.java + - match: (<<|>>>?|~|\^) + scope: keyword.operator.bitwise.java + - match: ((&|\^|\||<<|>>>?)=) + scope: keyword.operator.assignment.bitwise.java + - match: (===?|!=|<=|>=|<>|<|>) + scope: keyword.operator.comparison.java + - match: "([+*/%-]=)" + scope: keyword.operator.assignment.arithmetic.java + - match: (=) + scope: keyword.operator.assignment.java + - match: (\-\-|\+\+) + scope: keyword.operator.increment-decrement.java + - match: (\-|\+|\*|\/|%) + scope: keyword.operator.arithmetic.java + - match: (!|&&|\|\|) + scope: keyword.operator.logical.java + - match: (\||&) + scope: keyword.operator.bitwise.java + - match: (?<=\S)\.(?=\S) + scope: keyword.operator.dereference.java + - match: ; + scope: punctuation.terminator.java + method-call: + - match: '([\w$]+)(\()' + captures: + 1: meta.method.java + 2: punctuation.definition.method-parameters.begin.java + push: + - meta_scope: meta.method-call.java + - match: \) + captures: + 0: punctuation.definition.method-parameters.end.java + pop: true + - match: "," + scope: punctuation.definition.seperator.parameter.java + - include: code + methods: + - match: '(?!new)(?=[\w<].*\s+)(?=([^=/]|/(?!/))+\()' + push: + - meta_scope: meta.method.java + - match: "(})|(?=;)" + captures: + 1: punctuation.section.method.end.java + pop: true + - include: storage-modifiers + - match: (\w+)\s*\( + captures: + 1: entity.name.function.java + push: + - meta_scope: meta.method.identifier.java + - match: \) + pop: true + - include: parameters + - include: comments + - match: < + push: + - meta_scope: storage.type.token.java + - match: ">" + pop: true + - include: object-types + - match: < + comment: This is just to support <>'s with no actual type prefix + push: + - meta_scope: storage.type.generic.java + - match: '>|[^\w\s,\[\]<]' + pop: true + - match: (?=\w.*\s+\w+\s*\() + push: + - meta_scope: meta.method.return-type.java + - match: (?=\w+\s*\() + pop: true + - include: all-types + - include: comments + - include: throws + - match: "{" + captures: + 0: punctuation.section.method.begin.java + push: + - meta_scope: meta.method.body.java + - match: "(?=})" + pop: true + - include: code + - include: comments + object-types: + - match: '\b((?:[a-z]\w*\.)*[A-Z]+\w*)<' + push: + - meta_scope: storage.type.generic.java + - match: '>|[^\w\s,\?<\[\]]' + pop: true + - include: object-types + - match: < + comment: This is just to support <>'s with no actual type prefix + push: + - meta_scope: storage.type.generic.java + - match: '>|[^\w\s,\[\]<]' + pop: true + - match: '\b((?:[a-z]\w*\.)*[A-Z]+\w*)(?=\[)' + push: + - meta_scope: storage.type.object.array.java + - match: '(?=[^\]\s])' + pop: true + - match: '\[' + push: + - match: '\]' + pop: true + - include: code + - match: '\b(?:[a-z]\w*(\.))*[A-Z]+\w*\b' + scope: storage.type.java + captures: + 1: keyword.operator.dereference.java + object-types-inherited: + - match: '\b((?:[a-z]\w*\.)*[A-Z]+\w*)<' + push: + - meta_scope: entity.other.inherited-class.java + - match: '>|[^\w\s,<]' + pop: true + - include: object-types + - match: < + comment: This is just to support <>'s with no actual type prefix + push: + - meta_scope: storage.type.generic.java + - match: '>|[^\w\s,<]' + pop: true + - match: '\b(?:[a-z]\w*(\.))*[A-Z]+\w*' + scope: entity.other.inherited-class.java + captures: + 1: keyword.operator.dereference.java + parameters: + - match: final + scope: storage.modifier.java + - include: annotations + - include: primitive-arrays + - include: primitive-types + - include: object-types + - match: \w+ + scope: variable.parameter.java + parens: + - match: \( + push: + - match: \) + pop: true + - include: code + primitive-arrays: + - match: '\b(?:void|boolean|byte|char|short|int|float|long|double)(\[\])*\b' + scope: storage.type.primitive.array.java + primitive-types: + - match: \b(?:void|boolean|byte|char|short|int|float|long|double)\b + scope: storage.type.primitive.java + storage-modifiers: + - match: \b(public|private|protected|static|final|native|synchronized|volatile|abstract|threadsafe|transient)\b + captures: + 1: storage.modifier.java + strings: + - match: '"' + captures: + 0: punctuation.definition.string.begin.java + push: + - meta_scope: string.quoted.double.java + - match: '"' + captures: + 0: punctuation.definition.string.end.java + pop: true + - match: \\. + scope: constant.character.escape.java + - match: "'" + captures: + 0: punctuation.definition.string.begin.java + push: + - meta_scope: string.quoted.single.java + - match: "'" + captures: + 0: punctuation.definition.string.end.java + pop: true + - match: \\. + scope: constant.character.escape.java + throws: + - match: throws + captures: + 0: storage.modifier.java + push: + - meta_scope: meta.throwables.java + - match: "(?={|;)" + pop: true + - include: object-types + values: + - include: strings + - include: object-types + - include: constants-and-special-vars + variables: + - match: |- + (?x:(?= + (?: + (?:private|protected|public|native|synchronized|volatile|abstract|threadsafe|transient|static|final) # visibility/modifier + | + (?:def) + | + (?:void|boolean|byte|char|short|int|float|long|double) + | + (?:(?:[a-z]\w*\.)*[A-Z]+\w*) # object type + ) + \s+ + (?!private|protected|public|native|synchronized|volatile|abstract|threadsafe|transient|static|final|def|void|boolean|byte|char|short|int|float|long|double) + [\w\d_<>\[\],\?][\w\d_<>\[\],\? \t]* + (?:=|$) + + )) + push: + - meta_scope: meta.definition.variable.java + - match: (?=;) + pop: true + - match: \s + - match: '([A-Z_0-9]+)\s+(?=\=)' + captures: + 1: constant.other.variable.java + - match: '(\w[^\s,]*)\s+(?=\=)' + captures: + 1: meta.definition.variable.name.java + - match: "=" + captures: + 0: keyword.operator.assignment.java + push: + - match: (?=;) + pop: true + - include: code + - match: '(\w[^\s=]*)(?=\s*;)' + captures: + 1: meta.definition.variable.name.java + - include: code diff --git a/syntect/minimal_grammars/JavaScript (Babel).sublime-syntax b/syntect/minimal_grammars/JavaScript (Babel).sublime-syntax new file mode 100644 index 0000000..5a9916e --- /dev/null +++ b/syntect/minimal_grammars/JavaScript (Babel).sublime-syntax @@ -0,0 +1,1288 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: JavaScript (Babel) +file_extensions: + - js + - jsx + - babel + - es6 +first_line_match: ^#!\s*/.*\b(node|js)$\n? +scope: source.js.jsx +contexts: + main: + - include: core + brackets: + - include: round-brackets + - include: square-brackets + - include: curly-brackets + class-method-definition: + - match: '(@@[_$a-zA-Z][$\w]*|static|return)(?=\s*[<(])|(?=\s*<)' + captures: + 1: keyword.operator.flowtype.js + push: + - meta_scope: meta.short-method.flowtype.js + - match: '(?=\s*[;{])' + pop: true + - include: flowtype-polymorph + - include: function-declaration-parameters + - include: flowtype-annotation + - include: comments + - include: curly-brackets + - match: '(?<=[]"''])\s*(?=[<(])' + push: + - meta_scope: meta.class-method.computed.js + - match: '(?=\s*[;{])' + pop: true + - include: flowtype-polymorph + - include: function-declaration-parameters + - include: flowtype-annotation + - include: comments + - include: curly-brackets + - match: |- + (?x) + ((?>get|set)\s+) + (?> + ((')((?>[^'\\]|\\.)*)('))| + ((")((?>[^"\\]|\\.)*)("))| + (([_$a-zA-Z][$\w]*|\d+)) + )(?=\s*[<(]) + captures: + 1: storage.type.js + 2: string.quoted.js + 3: punctuation.definition.string.begin.js + 4: entity.name.function.js + 5: punctuation.definition.string.end.js + 6: string.quoted.js + 7: punctuation.definition.string.begin.js + 8: entity.name.function.js + 9: punctuation.definition.string.end.js + 10: string.unquoted.js + 11: entity.name.function.js + push: + - meta_scope: meta.class-accessor.js + - match: '(?=\s*[;{])' + pop: true + - include: flowtype-polymorph + - include: function-declaration-parameters + - include: flowtype-annotation + - include: comments + - include: curly-brackets + - match: |- + (?x) + (?> + ((')((?>[^'\\]|\\.)*)('))| + ((")((?>[^"\\]|\\.)*)("))| + (([_$a-zA-Z][$\w]*|\d+)) + )(?=\s*[<(]) + captures: + 1: string.quoted.js + 2: punctuation.definition.string.begin.js + 3: entity.name.function.js + 4: punctuation.definition.string.end.js + 5: string.quoted.js + 6: punctuation.definition.string.begin.js + 7: entity.name.function.js + 8: punctuation.definition.string.end.js + 9: string.unquoted.js + 10: entity.name.function.js + push: + - meta_scope: meta.class-method.js + - match: '(?=\s*[;{])' + pop: true + - include: flowtype-polymorph + - include: function-declaration-parameters + - include: flowtype-annotation + - include: comments + - include: curly-brackets + class-method-storage: + - match: (?static|declare)\b + scope: storage.modifier.js + - match: (?) + scope: comment.block.html.js + captures: + 0: punctuation.definition.comment.js + - match: (//).*$\n? + scope: comment.line.double-slash.js + captures: + 1: punctuation.definition.comment.js + - match: ^(#!).*$\n? + scope: comment.line.shebang.js + captures: + 1: punctuation.definition.comment.js + core: + - include: literal-function-labels + - include: literal-arrow-function-labels + - include: literal-labels + - include: literal-for + - include: literal-switch + - include: styled-components + - include: graphql + - include: expression + - include: literal-punctuation + curly-brackets: + - match: "{" + captures: + 0: meta.brace.curly.begin.js + push: + - meta_scope: meta.group.braces.curly.js + - match: "}" + captures: + 0: meta.brace.curly.end.js + pop: true + - include: main + es7-decorators: + - match: |- + (?x) + (@)([_$a-zA-Z][$\w]*)\b + scope: tag.decorator.js + captures: + 1: punctuation.definition.tag.js + 2: entity.name.tag.js + expression: + - include: merge-conflits + - include: literal-regexp + - include: literal-jsx + - include: es7-decorators + - include: support-class + - include: support-other + - include: literal-function + - include: literal-arrow-function + - include: literal-prototype + - include: literal-keywords + - include: literal-method + - include: literal-module + - include: literal-class + - include: flowtype-declaration + - include: literal-number + - include: literal-template-string + - include: literal-string + - include: literal-language-constant + - include: literal-language-variable + - include: literal-constructor + - include: literal-method-call + - include: literal-function-call + - include: comments + - include: brackets + - include: literal-operators + - include: literal-variable + flowtype-annotation: + - match: (?:(\?)\s*)?(:) + captures: + 1: keyword.operator.flowtype.optional.js + 2: keyword.operator.flowtype.annotation.js + push: + - meta_scope: meta.flowtype.annotation.js + - include: flowtype-tokens + - match: (?=\S) + pop: true + flowtype-brackets: + - match: "{" + captures: + 0: punctuation.section.flowtype.begin.js + push: + - match: "}" + captures: + 0: punctuation.section.flowtype.end.js + pop: true + - include: flowtype-tokens + flowtype-declaration: + - match: (?" + captures: + 0: punctuation.section.flowtype.end.js + pop: true + - include: flowtype-tokens + flowtype-tokens: + - match: '(?<=[:?|&=])(?=\s*{)' + push: + - match: "(?<=})" + pop: true + - include: flowtype-brackets + - match: '\s*([|&])\s*' + scope: meta.flowtype.set.js + captures: + 1: keyword.operator.flowtype.other.js + - match: '[*:?&|.]|\.\.\.|\b(typeof)\b' + scope: keyword.operator.flowtype.other.js + - match: < + captures: + 0: punctuation.section.flowtype.begin.js + push: + - match: ">" + captures: + 0: punctuation.section.flowtype.end.js + pop: true + - include: flowtype-tokens + - match: '\[' + captures: + 0: punctuation.section.flowtype.begin.js + push: + - match: '\]' + captures: + 0: punctuation.section.flowtype.end.js + pop: true + - include: flowtype-tokens + - match: \( + captures: + 0: punctuation.section.flowtype.begin.js + push: + - match: \) + captures: + 0: punctuation.section.flowtype.end.js + pop: true + - include: flowtype-tokens + - match: "=>" + captures: + 0: keyword.operator.flowtype.js + push: + - meta_scope: meta.flowtype.function.js + - match: "(?<=}|[_$a-zA-Z])" + pop: true + - include: flowtype-brackets + - include: flowtype-identifier + - include: comments + - include: flowtype-identifier + - include: literal-string + - include: comments + function-declaration-parameters: + - match: \( + captures: + 0: punctuation.definition.parameters.begin.js + push: + - match: \) + captures: + 0: punctuation.definition.parameters.end.js + pop: true + - include: comments + - include: flowtype-annotation + - match: (?" + captures: + 0: punctuation.definition.tag.end.jsx + push: + - match: (?=)|(/>) + captures: + 1: punctuation.definition.tag.begin.jsx + 2: entity.name.tag.html.jsx + 3: punctuation.definition.tag.end.jsx + 4: punctuation.definition.tag.end.jsx + pop: true + - include: jsx-tag-end + - include: jsx-attributes + - match: < + scope: invalid.illegal.tag.incomplete.jsx + literal-arrow-function: + - match: |- + (?x) + (?:([_$a-zA-Z][$\w]*)\s*(=)\s*)? + (?:\b(async)\s+)? + (?=(\((?>(?>[^()]+)|\g<-1>)*\))\s*(=>)) + captures: + 1: entity.name.function.js + 2: keyword.operator.assignment.js + 3: storage.type.js + push: + - meta_scope: meta.function.arrow.js + - match: (?<=\))\s*(=>) + captures: + 1: storage.type.function.arrow.js + pop: true + - include: function-declaration-parameters + - match: |- + (?x) + (?:([_$a-zA-Z][$\w]*)\s*(=)\s*)? + (?:(async)\s+)? + \b([_$a-zA-Z][$\w]*)\s*(=>) + scope: meta.function.arrow.js + captures: + 1: entity.name.function.js + 2: keyword.operator.assignment.js + 3: storage.type.js + 4: variable.parameter.function.js + 5: storage.type.function.arrow.js + - match: |- + (?x) + (\b_?[A-Z][$\w]*)? + (\.)(prototype) + (\.)([_$a-zA-Z][$\w]*) + \s*(=) + \s*(async)? + \s*(?=(\((?>(?>[^()]+)|\g<-1>)*\))\s*(=>)) + captures: + 1: entity.name.class.js + 2: keyword.operator.accessor.js + 3: variable.language.prototype.js + 4: keyword.operator.accessor.js + 5: entity.name.function.js + 6: keyword.operator.assignment.js + 7: storage.type.js + push: + - meta_scope: meta.prototype.function.arrow.js + - match: (?<=\))\s*(=>) + captures: + 1: storage.type.function.arrow.js + pop: true + - include: function-declaration-parameters + - match: |- + (?x) + (\b_?[A-Z][$\w]*)? + (\.)(prototype) + (\.)([_$a-zA-Z][$\w]*) + \s*(=) + \s*(async)? + \s*\b([_$a-zA-Z][$\w]*)\s*(=>) + scope: meta.prototype.function.arrow.js + captures: + 1: entity.name.class.js + 2: keyword.operator.accessor.js + 3: variable.language.prototype.js + 4: keyword.operator.accessor.js + 5: entity.name.function.js + 6: keyword.operator.assignment.js + 7: storage.type.js + 8: variable.parameter.function.js + 9: storage.type.function.arrow.js + - match: |- + (?x) + (\b_?[A-Z][$\w]*)? + (\.)([_$a-zA-Z][$\w]*) + \s*(=) + \s*(async)? + \s*(?=(\((?>(?>[^()]+)|\g<-1>)*\))\s*(=>)) + captures: + 1: entity.name.class.js + 2: keyword.operator.accessor.js + 3: entity.name.function.js + 4: keyword.operator.assignment.js + 5: storage.type.js + push: + - meta_scope: meta.function.static.arrow.js + - match: (?<=\))\s*(=>) + captures: + 1: storage.type.function.arrow.js + pop: true + - include: function-declaration-parameters + - match: |- + (?x) + (\b_?[A-Z][$\w]*)? + (\.)([_$a-zA-Z][$\w]*) + \s*(=) + \s*(async)? + \s*\b([_$a-zA-Z][$\w]*)\s*(=>) + scope: meta.function.static.arrow.js + captures: + 1: entity.name.class.js + 2: keyword.operator.accessor.js + 3: entity.name.function.js + 4: keyword.operator.assignment.js + 5: storage.type.js + 6: variable.parameter.function.js + 7: storage.type.function.arrow.js + literal-arrow-function-labels: + - match: |- + (?x) + (?> + ((')((?>[^'\\]|\\.)*)('))| + ((")((?>[^"\\]|\\.)*)("))| + (([_$a-zA-Z][$\w]*|\d+)) + ) + \s*(:) + \s*(?:\b(async)\s+)? + \s*(?=(\((?>(?>[^()]+)|\g<-1>)*\))\s*(=>)) + captures: + 1: string.quoted.js + 2: punctuation.definition.string.begin.js + 3: entity.name.function.js + 4: punctuation.definition.string.end.js + 5: string.quoted.js + 6: punctuation.definition.string.begin.js + 7: entity.name.function.js + 8: punctuation.definition.string.end.js + 9: string.unquoted.js + 10: entity.name.function.js + 11: punctuation.separator.key-value.js + 12: storage.type.js + push: + - meta_scope: meta.function.json.arrow.js + - match: (?<=\))\s*(=>) + captures: + 1: storage.type.function.arrow.js + pop: true + - include: function-declaration-parameters + - match: |- + (?x) + (?> + ((')((?>[^'\\]|\\.)*)('))| + ((")((?>[^"\\]|\\.)*)("))| + (([_$a-zA-Z][$\w]*|\d+)) + ) + \s*(:) + \s*(?:\b(async)\s+)? + \s*\b([_$a-zA-Z][$\w]*)\s*(=>) + scope: meta.function.json.arrow.js + captures: + 1: string.quoted.js + 2: punctuation.definition.string.begin.js + 3: entity.name.function.js + 4: punctuation.definition.string.end.js + 5: string.quoted.js + 6: punctuation.definition.string.begin.js + 7: entity.name.function.js + 8: punctuation.definition.string.end.js + 9: string.unquoted.js + 10: entity.name.function.js + 11: punctuation.separator.key-value.js + 12: storage.type.js + 13: variable.parameter.function.js + 14: storage.type.function.arrow.js + literal-class: + - match: (?\s*(\*)|(?=[\s(<])) + \s*([_$a-zA-Z][$\w]*)? + captures: + 1: entity.name.function.js + 2: keyword.operator.assignment.js + 3: storage.type.js + 4: storage.type.function.js + 5: keyword.generator.asterisk.js + 6: entity.name.function.js + push: + - meta_scope: meta.function.js + - match: (?<=\)) + pop: true + - include: flowtype-polymorph + - include: function-declaration-parameters + - match: |- + (?x) + (\b_?[A-Z][$\w]*)? + (\.)(prototype) + (\.)([_$a-zA-Z][$\w]*) + \s*(=) + \s*(?:(async)\s+)? + \s*(function)(?>\s*(\*)|(?=[\s(<])) + \s*([_$a-zA-Z][$\w]*)?\s* + captures: + 1: entity.name.class.js + 2: keyword.operator.accessor.js + 3: variable.language.prototype.js + 4: keyword.operator.accessor.js + 5: entity.name.function.js + 6: keyword.operator.assignment.js + 7: storage.type.js + 8: storage.type.function.js + 9: keyword.generator.asterisk.js + 10: entity.name.function.js + push: + - meta_scope: meta.function.prototype.js + - match: (?<=\)) + pop: true + - include: flowtype-polymorph + - include: function-declaration-parameters + - match: |- + (?x) + (\b_?[A-Z][$\w]*)? + (\.)([_$a-zA-Z][$\w]*) + \s*(=) + \s*(?:(async)\s+)? + \s*(function)(?>\s*(\*)|(?=[\s(<])) + \s*([_$a-zA-Z][$\w]*)?\s* + captures: + 1: entity.name.class.js + 2: keyword.operator.accessor.js + 3: entity.name.function.js + 4: keyword.operator.assignment.js + 5: storage.type.js + 6: storage.type.function.js + 7: keyword.generator.asterisk.js + 8: entity.name.function.js + push: + - meta_scope: meta.function.static.js + - match: (?<=\)) + pop: true + - include: flowtype-polymorph + - include: function-declaration-parameters + literal-function-call: + - match: '([_$a-zA-Z][$\w]*)\s*(\(\s*\))' + scope: meta.function-call.without-arguments.js + captures: + 1: entity.name.function.js + 2: meta.group.braces.round.function.arguments.js + - match: '([_$a-zA-Z][$\w]*)\s*(?=\()' + scope: meta.function-call.with-arguments.js + captures: + 1: entity.name.function.js + - match: '([_$a-zA-Z][$\w]*)\s*(?=`)' + scope: meta.function-call.tagged-template.js + captures: + 1: entity.name.function.js + literal-function-labels: + - match: |- + (?x) + (?> + ((')((?>[^'\\]|\\.)*)('))| + ((")((?>[^"\\]|\\.)*)("))| + (([_$a-zA-Z][$\w]*|\d+)) + ) + \s*(:) + \s*(?:\b(async)\s+)? + \s*(function)(?>\s*(\*)|(?=[\s(<])) + \s*([_$a-zA-Z][$\w]*)? + captures: + 1: string.quoted.js + 2: punctuation.definition.string.begin.js + 3: entity.name.function.js + 4: punctuation.definition.string.end.js + 5: string.quoted.js + 6: punctuation.definition.string.begin.js + 7: entity.name.function.js + 8: punctuation.definition.string.end.js + 9: string.unquoted.js + 10: entity.name.function.js + 11: punctuation.separator.key-value.js + 12: storage.type.js + 13: storage.type.function.js + 14: keyword.generator.asterisk.js + 15: entity.name.function.js + push: + - meta_scope: meta.function.json.js + - match: (?<=\)) + pop: true + - include: flowtype-polymorph + - include: function-declaration-parameters + literal-jsx: + - match: '(?<=\(|\{|\[|,|&&|\|\||\?|:|=|=>|\Wreturn|^return|\Wdefault|^)(?=\s*<[_$a-zA-Z])' + push: + - meta_content_scope: meta.jsx.js + - match: (?<=/>|>) + pop: true + - include: jsx-tag-start + literal-keyword-storage: + - match: (?const|let|var)\b + scope: storage.type.js + literal-keywords: + - include: literal-keyword-storage + - match: (?await|yield))\b(?:\s*(\*))? + captures: + 1: keyword.control.flow.js + 2: keyword.generator.asterisk.js + - match: (?if|else)\b + scope: keyword.control.conditional.js + - match: (?catch|finally|throw|try)\b + scope: keyword.control.trycatch.js + - match: (?break|continue|do|goto|while|case|default)\b + scope: keyword.control.loop.js + - match: (?enum|module|public|package|private|interface|protected)\b + scope: keyword.other.reserved.js + - match: (? + ((')((?>[^'\\]|\\.)*)('))| + ((")((?>[^"\\]|\\.)*)("))| + )\s*:) + push: + - match: ":" + captures: + 0: punctuation.separator.key-value.js + pop: true + - include: literal-string + - match: '(? + ((')((?>[^'\\]|\\.)*)('))| + ((")((?>[^"\\]|\\.)*)("))| + (([_$a-zA-Z][$\w]*|\d+)) + ) + (?=\s*(\((?>(?>[^()]+)|\g<-1>)*\))(?>\s|/\*.*\*/)*\{) + captures: + 1: storage.type.js + 2: storage.type.js + 3: keyword.generator.asterisk.js + 4: string.quoted.js + 5: punctuation.definition.string.begin.js + 6: entity.name.function.js + 7: punctuation.definition.string.end.js + 8: string.quoted.js + 9: punctuation.definition.string.begin.js + 10: entity.name.function.js + 11: punctuation.definition.string.end.js + 12: string.unquoted.js + 13: entity.name.function.js + push: + - meta_scope: meta.method.js + - match: (?<=\)) + pop: true + - include: function-declaration-parameters + - match: |- + (?x) + \b(?:(static)\s+)? + (get|set)\s+ + ([_$a-zA-Z][$\w]*|\d+)\s* + (?=(\((?>(?>[^()]+)|\g<-1>)*\))(?>\s|/\*.*\*/)*\{) + captures: + 1: storage.type.js + 2: storage.type.accessor.js + 3: entity.name.accessor.js + push: + - meta_scope: meta.accessor.js + - match: (?<=\)) + pop: true + - include: function-declaration-parameters + literal-method-call: + - match: |- + (?x) + (?:(?<=\.)|\b) + ([A-Z][$\w]*)\s*(\.) + ([_$a-zA-Z][$\w]*)\s* + (\(\s*\)) + scope: meta.function-call.static.without-arguments.js + captures: + 1: variable.other.class.js + 2: keyword.operator.accessor.js + 3: entity.name.function.js + 4: meta.group.braces.round.function.arguments.js + - match: |- + (?x) + (?:(?<=\.)|\b) + ([A-Z][$\w]*)\s*(\.) + ([_$a-zA-Z][$\w]*)\s* + (?=\() + scope: meta.function-call.static.with-arguments.js + captures: + 1: variable.other.class.js + 2: keyword.operator.accessor.js + 3: entity.name.function.js + - match: |- + (?x) + (?<=\.) + ([_$a-zA-Z][$\w]*)\s* + (\(\s*\)) + scope: meta.function-call.method.without-arguments.js + captures: + 1: entity.name.function.js + 2: meta.group.braces.round.function.arguments.js + - match: |- + (?x) + (?<=\.) + ([_$a-zA-Z][$\w]*)\s* + (?=\() + scope: meta.function-call.method.with-arguments.js + captures: + 1: entity.name.function.js + literal-module: + - match: (?import|export|default|from|as)\b + scope: keyword.operator.module.js + literal-number: + - match: '(?i)(?:\B[-+]|\b)0x[0-9a-f]*\.(\B|\b[0-9]+)' + scope: invalid.illegal.numeric.hex.js + - match: '(?:\B[-+]|\b)0[0-9]+\.(\B|\b[0-9]+)' + scope: invalid.illegal.numeric.octal.js + - match: |- + (?xi) + (?:\B[-+])? + (?: + \b0b[0-1]*| # binary + \b0o[0-7]*| # octal + \b0x[0-9a-f]*| # hex + ( + \B\.[0-9]+| # e.g. .999 + \b[0-9]+(\.[0-9]*)? # e.g. 999.999, 999. or 999 + )(e[-+]?[0-9]+)? # e.g. e+123, E-123 + ) + scope: constant.numeric.js + - match: '(?:\B[-+]|\b)(Infinity)\b' + scope: constant.language.infinity.js + literal-operators: + - match: (?delete|instanceof|in|new|of|typeof|void|with)\b + scope: keyword.operator.js + - match: |- + (?x) + !(?!=)| # logical-not right-to-left right + && | # logical-and left-to-right both + \|\| # logical-or left-to-right both + scope: keyword.operator.logical.js + - match: |- + (?x) + =(?!=) # assignment right-to-left both + scope: keyword.operator.assignment.js + - match: |- + (?x) + %= | # assignment right-to-left both + &= | # assignment right-to-left both + \*= | # assignment right-to-left both + \+= | # assignment right-to-left both + -= | # assignment right-to-left both + /= | # assignment right-to-left both + \^= | # assignment right-to-left both + \|= | # assignment right-to-left both + <<= | # assignment right-to-left both + >>= | # assignment right-to-left both + >>>= # assignment right-to-left both + scope: keyword.operator.assignment.augmented.js + - match: |- + (?x) + ~ | # bitwise-not right-to-left right + << | # bitwise-shift left-to-right both + >>> | # bitwise-shift left-to-right both + >> | # bitwise-shift left-to-right both + & | # bitwise-and left-to-right both + \^ | # bitwise-xor left-to-right both + \| # bitwise-or left-to-right both + scope: keyword.operator.bitwise.js + - match: |- + (?x) + <= | # relational left-to-right both + >= | # relational left-to-right both + < | # relational left-to-right both + > # relational left-to-right both + scope: keyword.operator.relational.js + - match: |- + (?x) + === | # equality left-to-right both + !== | # equality left-to-right both + == | # equality left-to-right both + != # equality left-to-right both + scope: keyword.operator.comparison.js + - match: |- + (?x) + -- | # decrement n/a right-or-left + \+\+ | # increment n/a right-or-left + / | # division left-to-right both + % | # modulus left-to-right both + \* | # multiplication left-to-right both + \+ | # addition left-to-right both + - # subtraction left-to-right both + scope: keyword.operator.arithmetic.js + - match: "[?:]" + scope: keyword.operator.ternary.js + - match: (?|<=|>=|==|!=|===|!==|\+|-|\*|%|\+\+|--|<<|>>|>>>|&|\||\^|!|~|&&|\|\||\?|:|=|\+=|-=|\*=|%=|<<=|>>=|>>>=|&=|\|=|\^=|/|/=| + \Wnew|\Wdelete|\Wvoid|\Wtypeof|\Winstanceof|\Win|\Wdo|\Wreturn|\Wcase|\Wthrow|\Wyield| + ^new|^delete|^void|^typeof|^instanceof|^in|^do|^return|^case|^throw|^yield|^ + )\s* + (/) + (?!/|\*|$) + captures: + 1: punctuation.definition.string.begin.js + push: + - meta_scope: string.regexp.js + - match: "(/)([gimy]*)" + captures: + 1: punctuation.definition.string.end.js + 2: keyword.other.js + pop: true + - include: scope:source.js.regexp + literal-string: + - match: '(["''])' + captures: + 0: punctuation.definition.string.begin.js + push: + - meta_scope: string.quoted.js + - match: (\1)|(\n) + captures: + 1: punctuation.definition.string.end.js + 2: invalid.illegal.newline.js + pop: true + - include: string-content + literal-switch: + - match: (?]{7})\s(.+)$' + captures: + 1: invalid.illegal.conflict-marker.other-commit.js + 2: invalid.illegal.string.js + round-brackets: + - match: \( + captures: + 0: meta.brace.round.begin.js + push: + - meta_scope: meta.group.braces.round.js + - match: \) + captures: + 0: meta.brace.round.end.js + pop: true + - include: expression + square-brackets: + - match: '\[' + captures: + 0: meta.brace.square.begin.js + push: + - meta_scope: meta.group.braces.square.js + - match: '\]' + captures: + 0: meta.brace.square.end.js + pop: true + - include: expression + string-content: + - match: \\\s*\n + scope: constant.character.escape.newline.js + - match: '\\([1-7][0-7]{0,2}|[0-7]{2,3}|[bfnrtv0''"\\]|x\h{2}|u\{\h+\}|u\h{4})' + scope: constant.character.escape.js + styled-components: + - match: (?(?>[^()]+)|\g<-1>)*\))\s*`)' + captures: + 1: meta.function-call.with-arguments.js entity.name.function.js + push: + - meta_scope: meta.styled-components.js + - match: (?<=`) + captures: + 1: meta.function-call.with-arguments.js entity.name.function.js + pop: true + - match: \( + captures: + 0: punctuation.definition.group.begin.js + push: + - meta_scope: meta.function-call.with-arguments.js meta.group.js + - match: \) + captures: + 0: punctuation.definition.group.end.js + pop: true + - include: expression + - match: "`" + captures: + 0: punctuation.definition.string.template.begin.js + push: + - meta_content_scope: source.css.embedded.js + - match: "`" + captures: + 0: punctuation.definition.string.template.end.js + pop: true + - include: scope:source.js.css + support-class: + - match: (?Eval|Range|Reference|Syntax|Type|URI)?Error)\b + scope: support.class.error.js + - match: \b(?>Buffer)\b + scope: support.class.node.js + support-other: + - match: (?document|window)\b + scope: support.type.object.dom.js + - match: (?global|GLOBAL|root|__dirname|__filename)\b + scope: support.type.object.node.js + - match: (?>= | //= | \*\*= + | \+= | -= | /= | @= + | \*= | %= | ~= | \^= | &= | \|= + | =(?!=) + scope: keyword.operator.assignment.python + backticks: + - match: \` + push: + - meta_scope: invalid.deprecated.backtick.python + - match: (?:\`|(?))' + scope: comment.typehint.punctuation.notation.python + - match: '([[:alpha:]_]\w*)' + scope: comment.typehint.variable.notation.python + - include: comments-base + comments-base: + - match: (\#) + captures: + 1: punctuation.definition.comment.python + push: + - meta_scope: comment.line.number-sign.python + - match: ($) + pop: true + - include: codetags + comments-string-double-three: + - match: (\#) + captures: + 1: punctuation.definition.comment.python + push: + - meta_scope: comment.line.number-sign.python + - match: ($|(?=""")) + pop: true + - include: codetags + comments-string-single-three: + - match: (\#) + captures: + 1: punctuation.definition.comment.python + push: + - meta_scope: comment.line.number-sign.python + - match: ($|(?=''')) + pop: true + - include: codetags + curly-braces: + - match: '\{' + captures: + 0: punctuation.definition.dict.begin.python + push: + - match: '\}' + captures: + 0: punctuation.definition.dict.end.python + pop: true + - match: ":" + scope: punctuation.separator.dict.python + - include: expression + decorator: + - match: |- + (?x) + ^\s* + ((@)) \s* (?=[[:alpha:]_]\w*) + captures: + 1: entity.name.function.decorator.python + 2: punctuation.definition.decorator.python + push: + - meta_scope: meta.function.decorator.python + - match: |- + (?x) + ( \) ) + # trailing whitespace and comments are legal + (?: (.*?) (?=\s*(?:\#|$)) ) + | (?=\n|\#) + captures: + 1: punctuation.definition.arguments.end.python + 2: invalid.illegal.decorator.python + pop: true + - include: decorator-name + - include: function-arguments + decorator-name: + - include: builtin-callables + - include: illegal-object-name + - match: |- + (?x) + ([[:alpha:]_]\w*) | (\.) + scope: entity.name.function.decorator.python + captures: + 2: punctuation.separator.period.python + - include: line-continuation + - match: |- + (?x) + \s* ([^([:alpha:]\s_\.#\\] .*?) (?=\#|$) + scope: invalid.illegal.decorator.python + captures: + 1: invalid.illegal.decorator.python + docstring: + - match: (\'\'\'|\"\"\") + captures: + 1: punctuation.definition.string.begin.python + push: + - meta_scope: string.quoted.docstring.multi.python + - match: (\1) + captures: + 1: punctuation.definition.string.end.python + pop: true + - include: docstring-prompt + - include: codetags + - include: docstring-guts-unicode + - match: '([rR])(\''\''\''|\"\"\")' + captures: + 1: storage.type.string.python + 2: punctuation.definition.string.begin.python + push: + - meta_scope: string.quoted.docstring.raw.multi.python + - match: (\2) + captures: + 1: punctuation.definition.string.end.python + pop: true + - include: string-consume-escape + - include: docstring-prompt + - include: codetags + - match: (\'|\") + captures: + 1: punctuation.definition.string.begin.python + push: + - meta_scope: string.quoted.docstring.single.python + - match: (\1)|(\n) + captures: + 1: punctuation.definition.string.end.python + 2: invalid.illegal.newline.python + pop: true + - include: codetags + - include: docstring-guts-unicode + - match: '([rR])(\''|\")' + captures: + 1: storage.type.string.python + 2: punctuation.definition.string.begin.python + push: + - meta_scope: string.quoted.docstring.raw.single.python + - match: (\2)|(\n) + captures: + 1: punctuation.definition.string.end.python + 2: invalid.illegal.newline.python + pop: true + - include: string-consume-escape + - include: codetags + docstring-guts-unicode: + - include: escape-sequence-unicode + - include: escape-sequence + - include: string-line-continuation + docstring-prompt: + - match: |- + (?x) + (?: + (?:^|\G) \s* (?# '\G' is necessary for ST) + ((?:>>>|\.\.\.) \s) (?=\s*\S) + ) + captures: + 1: keyword.control.flow.python + docstring-statement: + - match: '^(?=\s*[rR]?(\''\''\''|\"\"\"|\''|\"))' + comment: the string either terminates correctly or by the beginning of a new line (this is for single line docstrings that aren't terminated) AND it's not followed by another docstring + push: + - match: '((?<=\1)|^)(?!\s*[rR]?(\''\''\''|\"\"\"|\''|\"))' + pop: true + - include: docstring + double-one-fregexp-conditional: + - match: '(\()\?\((\w+(?:\s+[[:alnum:]]+)?|\d+)\)' + captures: + 0: keyword.operator.conditional.regexp + 1: punctuation.parenthesis.conditional.begin.regexp + push: + - match: (\)|(?="))|((?=(?) + captures: + 1: support.other.parenthesis.regexp punctuation.parenthesis.named.begin.regexp + 2: entity.name.tag.named.group.regexp + push: + - meta_scope: meta.named.regexp + - match: (\)|(?="))|((?=(?) + captures: + 1: support.other.parenthesis.regexp punctuation.parenthesis.named.begin.regexp + 2: entity.name.tag.named.group.regexp + push: + - meta_scope: meta.named.regexp + - match: (\)|(?="))|((?=(?) + captures: + 1: support.other.parenthesis.regexp punctuation.parenthesis.named.begin.regexp + 2: entity.name.tag.named.group.regexp + push: + - meta_scope: meta.named.regexp + - match: (\)|(?=""")) + captures: + 1: support.other.parenthesis.regexp punctuation.parenthesis.named.end.regexp + 2: invalid.illegal.newline.python + pop: true + - include: double-three-fregexp-expression + - include: comments-string-double-three + double-three-fregexp-parentheses: + - match: \( + captures: + 0: support.other.parenthesis.regexp punctuation.parenthesis.begin.regexp + push: + - match: (\)|(?=""")) + captures: + 1: support.other.parenthesis.regexp punctuation.parenthesis.end.regexp + 2: invalid.illegal.newline.python + pop: true + - include: double-three-fregexp-expression + - include: comments-string-double-three + double-three-fregexp-parentheses-non-capturing: + - match: '\(\?:' + captures: + 0: support.other.parenthesis.regexp punctuation.parenthesis.non-capturing.begin.regexp + push: + - match: (\)|(?=""")) + captures: + 1: support.other.parenthesis.regexp punctuation.parenthesis.non-capturing.end.regexp + 2: invalid.illegal.newline.python + pop: true + - include: double-three-fregexp-expression + - include: comments-string-double-three + double-three-regexp-character-set: + - match: |- + (?x) + \[ \^? \] (?! .*?\]) + - match: '(\[)(\^)?(\])?' + captures: + 1: punctuation.character.set.begin.regexp constant.other.set.regexp + 2: keyword.operator.negation.regexp + 3: constant.character.set.regexp + push: + - meta_scope: meta.character.set.regexp + - match: '(\]|(?="""))' + captures: + 1: punctuation.character.set.end.regexp constant.other.set.regexp + 2: invalid.illegal.newline.python + pop: true + - include: regexp-charecter-set-escapes + - match: '[^\n]' + scope: constant.character.set.regexp + double-three-regexp-comments: + - match: '\(\?#' + captures: + 0: punctuation.comment.begin.regexp + push: + - meta_scope: comment.regexp + - match: (\)|(?=""")) + captures: + 1: punctuation.comment.end.regexp + 2: invalid.illegal.newline.python + pop: true + - include: codetags + double-three-regexp-conditional: + - match: '(\()\?\((\w+(?:\s+[[:alnum:]]+)?|\d+)\)' + captures: + 0: keyword.operator.conditional.regexp + 1: punctuation.parenthesis.conditional.begin.regexp + push: + - match: (\)|(?=""")) + captures: + 1: keyword.operator.conditional.negative.regexp punctuation.parenthesis.conditional.end.regexp + 2: invalid.illegal.newline.python + pop: true + - include: double-three-regexp-expression + - include: comments-string-double-three + double-three-regexp-expression: + - include: regexp-base-expression + - include: double-three-regexp-character-set + - include: double-three-regexp-comments + - include: regexp-flags + - include: double-three-regexp-named-group + - include: regexp-backreference + - include: double-three-regexp-lookahead + - include: double-three-regexp-lookahead-negative + - include: double-three-regexp-lookbehind + - include: double-three-regexp-lookbehind-negative + - include: double-three-regexp-conditional + - include: double-three-regexp-parentheses-non-capturing + - include: double-three-regexp-parentheses + - include: comments-string-double-three + double-three-regexp-lookahead: + - match: (\()\?= + captures: + 0: keyword.operator.lookahead.regexp + 1: punctuation.parenthesis.lookahead.begin.regexp + push: + - match: (\)|(?=""")) + captures: + 1: keyword.operator.lookahead.regexp punctuation.parenthesis.lookahead.end.regexp + 2: invalid.illegal.newline.python + pop: true + - include: double-three-regexp-expression + - include: comments-string-double-three + double-three-regexp-lookahead-negative: + - match: (\()\?! + captures: + 0: keyword.operator.lookahead.negative.regexp + 1: punctuation.parenthesis.lookahead.begin.regexp + push: + - match: (\)|(?=""")) + captures: + 1: keyword.operator.lookahead.negative.regexp punctuation.parenthesis.lookahead.end.regexp + 2: invalid.illegal.newline.python + pop: true + - include: double-three-regexp-expression + - include: comments-string-double-three + double-three-regexp-lookbehind: + - match: (\()\?<= + captures: + 0: keyword.operator.lookbehind.regexp + 1: punctuation.parenthesis.lookbehind.begin.regexp + push: + - match: (\)|(?=""")) + captures: + 1: keyword.operator.lookbehind.regexp punctuation.parenthesis.lookbehind.end.regexp + 2: invalid.illegal.newline.python + pop: true + - include: double-three-regexp-expression + - include: comments-string-double-three + double-three-regexp-lookbehind-negative: + - match: (\()\?) + captures: + 1: support.other.parenthesis.regexp punctuation.parenthesis.named.begin.regexp + 2: entity.name.tag.named.group.regexp + push: + - meta_scope: meta.named.regexp + - match: (\)|(?=""")) + captures: + 1: support.other.parenthesis.regexp punctuation.parenthesis.named.end.regexp + 2: invalid.illegal.newline.python + pop: true + - include: double-three-regexp-expression + - include: comments-string-double-three + double-three-regexp-parentheses: + - match: \( + captures: + 0: support.other.parenthesis.regexp punctuation.parenthesis.begin.regexp + push: + - match: (\)|(?=""")) + captures: + 1: support.other.parenthesis.regexp punctuation.parenthesis.end.regexp + 2: invalid.illegal.newline.python + pop: true + - include: double-three-regexp-expression + - include: comments-string-double-three + double-three-regexp-parentheses-non-capturing: + - match: '\(\?:' + captures: + 0: support.other.parenthesis.regexp punctuation.parenthesis.non-capturing.begin.regexp + push: + - match: (\)|(?=""")) + captures: + 1: support.other.parenthesis.regexp punctuation.parenthesis.non-capturing.end.regexp + 2: invalid.illegal.newline.python + pop: true + - include: double-three-regexp-expression + - include: comments-string-double-three + ellipsis: + - match: \.\.\. + scope: constant.other.ellipsis.python + escape-sequence: + - match: |- + (?x) + \\ ( + x[0-9A-Fa-f]{2} + | [0-7]{1,3} + | [\\"'abfnrtv] + ) + scope: constant.character.escape.python + escape-sequence-unicode: + - match: |- + (?x) + \\ ( + u[0-9A-Fa-f]{4} + | U[0-9A-Fa-f]{8} + | N\{[\w\s]+?\} + ) + scope: constant.character.escape.python + expression: + - include: expression-base + - include: member-access + - match: '(?x) \b ([[:alpha:]_]\w*) \b' + comment: Tokenize identifiers to help linters + expression-bare: + - include: backticks + - include: illegal-anno + - include: literal + - include: regexp + - include: string + - include: lambda + - include: illegal-operator + - include: operator + - include: curly-braces + - include: item-access + - include: list + - include: round-braces + - include: function-call + - include: builtin-functions + - include: builtin-types + - include: builtin-exceptions + - include: magic-names + - include: special-names + - include: illegal-names + - include: special-variables + - include: ellipsis + - include: punctuation + - include: line-continuation + expression-base: + - include: comments + - include: expression-bare + - include: line-continuation + f-expression: + - include: expression-bare + - include: member-access + - match: '(?x) \b ([[:alpha:]_]\w*) \b' + comment: Tokenize identifiers to help linters + fregexp-base-expression: + - include: fregexp-quantifier + - include: fstring-formatting-braces + - match: '\{.*?\}' + - include: regexp-base-common + fregexp-double-one-line: + - match: '\b(([uU]r)|([fF]r)|(r[fF]?))(")' + captures: + 2: invalid.deprecated.prefix.python + 3: storage.type.string.python + 4: storage.type.string.python + 5: punctuation.definition.string.begin.python + push: + - meta_scope: string.interpolated.python string.regexp.quoted.single.python + - match: (")|(?=^]? [-+ ]? \#? + \d* ,? (\.\d+)? [bcdeEfFgGnosxX%]? )(?=}) + captures: + 1: storage.type.format.python + 2: storage.type.format.python + - include: fstring-terminator-multi-tail + fstring-terminator-multi-tail: + - match: "(![rsa])?(:)(?=.*?{)" + captures: + 1: storage.type.format.python + 2: storage.type.format.python + push: + - match: "(?=})" + pop: true + - include: fstring-illegal-multi-brace + - include: fstring-multi-brace + - match: "([bcdeEfFgGnosxX%])(?=})" + scope: storage.type.format.python + - match: (\.\d+) + scope: storage.type.format.python + - match: (,) + scope: storage.type.format.python + - match: (\d+) + scope: storage.type.format.python + - match: (\#) + scope: storage.type.format.python + - match: "([-+ ])" + scope: storage.type.format.python + - match: "([<>=^])" + scope: storage.type.format.python + - match: (\w) + scope: storage.type.format.python + fstring-terminator-single: + - match: "(![rsa])(?=})" + scope: storage.type.format.python + - match: |- + (?x) + (![rsa])? + ( : \w? [<>=^]? [-+ ]? \#? + \d* ,? (\.\d+)? [bcdeEfFgGnosxX%]? )(?=}) + captures: + 1: storage.type.format.python + 2: storage.type.format.python + - include: fstring-terminator-single-tail + fstring-terminator-single-tail: + - match: "(![rsa])?(:)(?=.*?{)" + captures: + 1: storage.type.format.python + 2: storage.type.format.python + push: + - match: '(?=})|(?=\n)' + pop: true + - include: fstring-illegal-single-brace + - include: fstring-single-brace + - match: "([bcdeEfFgGnosxX%])(?=})" + scope: storage.type.format.python + - match: (\.\d+) + scope: storage.type.format.python + - match: (,) + scope: storage.type.format.python + - match: (\d+) + scope: storage.type.format.python + - match: (\#) + scope: storage.type.format.python + - match: "([-+ ])" + scope: storage.type.format.python + - match: "([<>=^])" + scope: storage.type.format.python + - match: (\w) + scope: storage.type.format.python + function-arguments: + - match: (\() + captures: + 1: punctuation.definition.arguments.begin.python + push: + - meta_content_scope: meta.function-call.arguments.python + - match: (?=\))(?!\)\s*\() + pop: true + - match: (,) + scope: punctuation.separator.arguments.python + - match: |- + (?x) + (?:(?<=[,(])|^) \s* (\*{1,2}) + captures: + 1: keyword.operator.unpacking.arguments.python + - include: lambda-incomplete + - include: illegal-names + - match: '\b([[:alpha:]_]\w*)\s*(=)(?!=)' + captures: + 1: variable.parameter.function-call.python + 2: keyword.operator.assignment.python + - match: "=(?!=)" + scope: keyword.operator.assignment.python + - include: expression + - match: \s*(\))\s*(\() + captures: + 1: punctuation.definition.arguments.end.python + 2: punctuation.definition.arguments.begin.python + function-call: + - match: |- + (?x) + \b(?= + ([[:alpha:]_]\w*) \s* (\() + ) + push: + - meta_scope: meta.function-call.python + - match: (\)) + captures: + 1: punctuation.definition.arguments.end.python + pop: true + - include: special-variables + - include: function-name + - include: function-arguments + function-declaration: + - match: |- + (?x) + \s* + (?:\b(async) \s+)? \b(def)\s+ + (?= + [[:alpha:]_][[:word:]]* \s* \( + ) + captures: + 1: storage.type.function.async.python + 2: storage.type.function.python + push: + - meta_scope: meta.function.python + - match: '(:|(?=[#''"\n]))' + captures: + 1: punctuation.section.function.begin.python + pop: true + - include: function-def-name + - include: parameters + - include: line-continuation + - include: return-annotation + function-def-name: + - include: illegal-object-name + - include: builtin-possible-callables + - match: |- + (?x) + \b ([[:alpha:]_]\w*) \b + scope: entity.name.function.python + function-name: + - include: builtin-possible-callables + - match: |- + (?x) + \b ([[:alpha:]_]\w*) \b + comment: Some color schemas support meta.function-call.generic scope + scope: meta.function-call.generic.python + illegal-anno: + - match: "->" + scope: invalid.illegal.annotation.python + illegal-names: + - match: |- + (?x) + \b(?: + ( + and | assert | async | await | break | class | continue | def + | del | elif | else | except | finally | for | from | global + | if | in | is | (?<=\.)lambda | lambda(?=\s*[\.=]) + | nonlocal | not | or | pass | raise | return | try | while | with + | yield + ) | ( + as | import + ) + )\b + captures: + 1: keyword.control.flow.python + 2: keyword.control.import.python + illegal-object-name: + - match: \b(True|False|None)\b + comment: It's illegal to name class or function "True" + scope: keyword.illegal.name.python + illegal-operator: + - match: '&&|\|\||--|\+\+' + scope: invalid.illegal.operator.python + - match: "[?$]" + scope: invalid.illegal.operator.python + - match: '!\b' + comment: We don't want `!` to flash when we're typing `!=` + scope: invalid.illegal.operator.python + import: + - match: \b(?> | & | \| | \^ | ~) (?# 3) + + | (\*\* | \* | \+ | - | % | // | / | @) (?# 4) + + | (!= | == | >= | <= | < | >) (?# 5) + captures: + 1: keyword.operator.logical.python + 2: keyword.control.flow.python + 3: keyword.operator.bitwise.python + 4: keyword.operator.arithmetic.python + 5: keyword.operator.comparison.python + parameter-special: + - match: |- + (?x) + \b ((self)|(cls)) \b \s*(?:(,)|(?=\))) + captures: + 1: variable.parameter.function.language.python + 2: variable.parameter.function.language.special.self.python + 3: variable.parameter.function.language.special.cls.python + 4: punctuation.separator.parameters.python + parameters: + - match: (\() + captures: + 1: punctuation.definition.parameters.begin.python + push: + - meta_scope: meta.function.parameters.python + - match: (\)) + captures: + 1: punctuation.definition.parameters.end.python + pop: true + - match: (\*\*|\*) + scope: keyword.operator.unpacking.parameter.python + - include: lambda-incomplete + - include: illegal-names + - include: illegal-object-name + - include: parameter-special + - match: |- + (?x) + ([[:alpha:]_]\w*) + \s* (?: (,) | (?=[)#\n=])) + captures: + 1: variable.parameter.function.language.python + 2: punctuation.separator.parameters.python + - include: comments + - include: loose-default + - include: annotated-parameter + punctuation: + - match: ":" + scope: punctuation.separator.colon.python + - match: "," + scope: punctuation.separator.element.python + regexp: + - include: regexp-single-three-line + - include: regexp-double-three-line + - include: regexp-single-one-line + - include: regexp-double-one-line + - include: fregexp-single-three-line + - include: fregexp-double-three-line + - include: fregexp-single-one-line + - include: fregexp-double-one-line + regexp-backreference: + - match: |- + (?x) + (\() (\?P= \w+(?:\s+[[:alnum:]]+)?) (\)) + scope: meta.backreference.named.regexp + captures: + 1: support.other.parenthesis.regexp punctuation.parenthesis.backreference.named.begin.regexp + 2: entity.name.tag.named.backreference.regexp + 3: support.other.parenthesis.regexp punctuation.parenthesis.backreference.named.end.regexp + regexp-backreference-number: + - match: '(\\[1-9]\d?)' + scope: meta.backreference.regexp + captures: + 1: entity.name.tag.backreference.regexp + regexp-base-common: + - match: \. + scope: support.other.match.any.regexp + - match: \^ + scope: support.other.match.begin.regexp + - match: \$ + scope: support.other.match.end.regexp + - match: '[+*?]\??' + scope: keyword.operator.quantifier.regexp + - match: \| + scope: keyword.operator.disjunction.regexp + - include: regexp-escape-sequence + regexp-base-expression: + - include: regexp-quantifier + - include: regexp-base-common + regexp-charecter-set-escapes: + - match: '\\[abfnrtv\\]' + scope: constant.character.escape.regexp + - include: regexp-escape-special + - match: '\\([0-7]{1,3})' + scope: constant.character.escape.regexp + - include: regexp-escape-character + - include: regexp-escape-unicode + - include: regexp-escape-catchall + regexp-double-one-line: + - match: '\b(([uU]r)|([bB]r)|(r[bB]?))(")' + captures: + 2: invalid.deprecated.prefix.python + 3: storage.type.string.python + 4: storage.type.string.python + 5: punctuation.definition.string.begin.python + push: + - meta_scope: string.regexp.quoted.single.python + - match: (")|(?) + captures: + 1: punctuation.separator.annotation.result.python + push: + - match: (?=:) + pop: true + - include: expression + round-braces: + - match: \( + captures: + 0: punctuation.parenthesis.begin.python + push: + - match: \) + captures: + 0: punctuation.parenthesis.end.python + pop: true + - include: expression + semicolon: + - match: \;$ + scope: invalid.deprecated.semicolon.python + single-one-fregexp-conditional: + - match: '(\()\?\((\w+(?:\s+[[:alnum:]]+)?|\d+)\)' + captures: + 0: keyword.operator.conditional.regexp + 1: punctuation.parenthesis.conditional.begin.regexp + push: + - match: (\)|(?=\'))|((?=(?) + captures: + 1: support.other.parenthesis.regexp punctuation.parenthesis.named.begin.regexp + 2: entity.name.tag.named.group.regexp + push: + - meta_scope: meta.named.regexp + - match: (\)|(?=\'))|((?=(?) + captures: + 1: support.other.parenthesis.regexp punctuation.parenthesis.named.begin.regexp + 2: entity.name.tag.named.group.regexp + push: + - meta_scope: meta.named.regexp + - match: (\)|(?=\'))|((?=(?) + captures: + 1: support.other.parenthesis.regexp punctuation.parenthesis.named.begin.regexp + 2: entity.name.tag.named.group.regexp + push: + - meta_scope: meta.named.regexp + - match: (\)|(?=\'\'\')) + captures: + 1: support.other.parenthesis.regexp punctuation.parenthesis.named.end.regexp + 2: invalid.illegal.newline.python + pop: true + - include: single-three-fregexp-expression + - include: comments-string-single-three + single-three-fregexp-parentheses: + - match: \( + captures: + 0: support.other.parenthesis.regexp punctuation.parenthesis.begin.regexp + push: + - match: (\)|(?=\'\'\')) + captures: + 1: support.other.parenthesis.regexp punctuation.parenthesis.end.regexp + 2: invalid.illegal.newline.python + pop: true + - include: single-three-fregexp-expression + - include: comments-string-single-three + single-three-fregexp-parentheses-non-capturing: + - match: '\(\?:' + captures: + 0: support.other.parenthesis.regexp punctuation.parenthesis.non-capturing.begin.regexp + push: + - match: (\)|(?=\'\'\')) + captures: + 1: support.other.parenthesis.regexp punctuation.parenthesis.non-capturing.end.regexp + 2: invalid.illegal.newline.python + pop: true + - include: single-three-fregexp-expression + - include: comments-string-single-three + single-three-regexp-character-set: + - match: |- + (?x) + \[ \^? \] (?! .*?\]) + - match: '(\[)(\^)?(\])?' + captures: + 1: punctuation.character.set.begin.regexp constant.other.set.regexp + 2: keyword.operator.negation.regexp + 3: constant.character.set.regexp + push: + - meta_scope: meta.character.set.regexp + - match: '(\]|(?=\''\''\''))' + captures: + 1: punctuation.character.set.end.regexp constant.other.set.regexp + 2: invalid.illegal.newline.python + pop: true + - include: regexp-charecter-set-escapes + - match: '[^\n]' + scope: constant.character.set.regexp + single-three-regexp-comments: + - match: '\(\?#' + captures: + 0: punctuation.comment.begin.regexp + push: + - meta_scope: comment.regexp + - match: (\)|(?=\'\'\')) + captures: + 1: punctuation.comment.end.regexp + 2: invalid.illegal.newline.python + pop: true + - include: codetags + single-three-regexp-conditional: + - match: '(\()\?\((\w+(?:\s+[[:alnum:]]+)?|\d+)\)' + captures: + 0: keyword.operator.conditional.regexp + 1: punctuation.parenthesis.conditional.begin.regexp + push: + - match: (\)|(?=\'\'\')) + captures: + 1: keyword.operator.conditional.negative.regexp punctuation.parenthesis.conditional.end.regexp + 2: invalid.illegal.newline.python + pop: true + - include: single-three-regexp-expression + - include: comments-string-single-three + single-three-regexp-expression: + - include: regexp-base-expression + - include: single-three-regexp-character-set + - include: single-three-regexp-comments + - include: regexp-flags + - include: single-three-regexp-named-group + - include: regexp-backreference + - include: single-three-regexp-lookahead + - include: single-three-regexp-lookahead-negative + - include: single-three-regexp-lookbehind + - include: single-three-regexp-lookbehind-negative + - include: single-three-regexp-conditional + - include: single-three-regexp-parentheses-non-capturing + - include: single-three-regexp-parentheses + - include: comments-string-single-three + single-three-regexp-lookahead: + - match: (\()\?= + captures: + 0: keyword.operator.lookahead.regexp + 1: punctuation.parenthesis.lookahead.begin.regexp + push: + - match: (\)|(?=\'\'\')) + captures: + 1: keyword.operator.lookahead.regexp punctuation.parenthesis.lookahead.end.regexp + 2: invalid.illegal.newline.python + pop: true + - include: single-three-regexp-expression + - include: comments-string-single-three + single-three-regexp-lookahead-negative: + - match: (\()\?! + captures: + 0: keyword.operator.lookahead.negative.regexp + 1: punctuation.parenthesis.lookahead.begin.regexp + push: + - match: (\)|(?=\'\'\')) + captures: + 1: keyword.operator.lookahead.negative.regexp punctuation.parenthesis.lookahead.end.regexp + 2: invalid.illegal.newline.python + pop: true + - include: single-three-regexp-expression + - include: comments-string-single-three + single-three-regexp-lookbehind: + - match: (\()\?<= + captures: + 0: keyword.operator.lookbehind.regexp + 1: punctuation.parenthesis.lookbehind.begin.regexp + push: + - match: (\)|(?=\'\'\')) + captures: + 1: keyword.operator.lookbehind.regexp punctuation.parenthesis.lookbehind.end.regexp + 2: invalid.illegal.newline.python + pop: true + - include: single-three-regexp-expression + - include: comments-string-single-three + single-three-regexp-lookbehind-negative: + - match: (\()\?) + captures: + 1: support.other.parenthesis.regexp punctuation.parenthesis.named.begin.regexp + 2: entity.name.tag.named.group.regexp + push: + - meta_scope: meta.named.regexp + - match: (\)|(?=\'\'\')) + captures: + 1: support.other.parenthesis.regexp punctuation.parenthesis.named.end.regexp + 2: invalid.illegal.newline.python + pop: true + - include: single-three-regexp-expression + - include: comments-string-single-three + single-three-regexp-parentheses: + - match: \( + captures: + 0: support.other.parenthesis.regexp punctuation.parenthesis.begin.regexp + push: + - match: (\)|(?=\'\'\')) + captures: + 1: support.other.parenthesis.regexp punctuation.parenthesis.end.regexp + 2: invalid.illegal.newline.python + pop: true + - include: single-three-regexp-expression + - include: comments-string-single-three + single-three-regexp-parentheses-non-capturing: + - match: '\(\?:' + captures: + 0: support.other.parenthesis.regexp punctuation.parenthesis.non-capturing.begin.regexp + push: + - match: (\)|(?=\'\'\')) + captures: + 1: support.other.parenthesis.regexp punctuation.parenthesis.non-capturing.end.regexp + 2: invalid.illegal.newline.python + pop: true + - include: single-three-regexp-expression + - include: comments-string-single-three + special-names: + - match: |- + (?x) + \b + # we want to see "enough", meaning 2 or more upper-case + # letters in the beginning of the constant + # + # for more details refer to: + # https://github.com/MagicStack/MagicPython/issues/42 + ( + _* [[:upper:]] [_\d]* [[:upper:]] + ) + [[:upper:]\d]* (_\w*)? + \b + scope: constant.other.caps.python + special-variables: + - match: |- + (?x) + \b (?=^]? [-+ ]? \#? + \d* ,? (\.\d+)? [bcdeEfFgGnosxX%]? )? + }) + ) + scope: meta.format.brace.python + captures: + 1: constant.character.format.placeholder.other.python + 3: storage.type.format.python + 4: storage.type.format.python + - match: |- + (?x) + ( + { + \w* (\.[[:alpha:]_]\w* | \[[^\]'"]+\])* + (![rsa])? + (:) + [^'"{}\n]* (?: + \{ [^'"}\n]*? \} [^'"{}\n]* + )* + } + ) + scope: meta.format.brace.python + captures: + 1: constant.character.format.placeholder.other.python + 3: storage.type.format.python + 4: storage.type.format.python + string-consume-escape: + - match: '\\[''"\n\\]' + string-entity: + - include: escape-sequence + - include: string-line-continuation + - include: string-formatting + string-formatting: + - match: |- + (?x) + ( + % (\([\w\s]*\))? + [-+#0 ]* + (\d+|\*)? (\.(\d+|\*))? + ([hlL])? + [diouxXeEfFgGcrsab%] + ) + scope: meta.format.percent.python + captures: + 1: constant.character.format.placeholder.other.python + string-line-continuation: + - match: \\$ + scope: constant.language.python + string-multi-bad-brace1-formatting-raw: + - match: |- + (?x) + (?= \{% + ( .*? (?!'''|""") ) + %\} + ) + comment: "template using {% ... %}" + push: + - match: (?='''|""") + pop: true + - include: string-consume-escape + string-multi-bad-brace1-formatting-unicode: + - match: |- + (?x) + (?= \{% + ( .*? (?!'''|""") ) + %\} + ) + comment: "template using {% ... %}" + push: + - match: (?='''|""") + pop: true + - include: escape-sequence-unicode + - include: escape-sequence + - include: string-line-continuation + string-multi-bad-brace2-formatting-raw: + - match: |- + (?x) + (?!\{\{) + (?= \{ ( + \w*? (?!'''|""") [^!:\.\[}\w] + ) + .*?(?!'''|""") + \} + ) + comment: odd format or format-like syntax + push: + - match: (?='''|""") + pop: true + - include: string-consume-escape + - include: string-formatting + string-multi-bad-brace2-formatting-unicode: + - match: |- + (?x) + (?!\{\{) + (?= \{ ( + \w*? (?!'''|""") [^!:\.\[}\w] + ) + .*?(?!'''|""") + \} + ) + comment: odd format or format-like syntax + push: + - match: (?='''|""") + pop: true + - include: escape-sequence-unicode + - include: string-entity + string-quoted-multi-line: + - match: '(?:\b([rR])(?=[uU]))?([uU])?(''''''|""")' + captures: + 1: invalid.illegal.prefix.python + 2: storage.type.string.python + 3: punctuation.definition.string.begin.python + push: + - meta_scope: string.quoted.multi.python + - match: (\3) + captures: + 1: punctuation.definition.string.end.python + 2: invalid.illegal.newline.python + pop: true + - include: string-multi-bad-brace1-formatting-unicode + - include: string-multi-bad-brace2-formatting-unicode + - include: string-unicode-guts + string-quoted-single-line: + - match: '(?:\b([rR])(?=[uU]))?([uU])?(([''"]))' + captures: + 1: invalid.illegal.prefix.python + 2: storage.type.string.python + 3: punctuation.definition.string.begin.python + push: + - meta_scope: string.quoted.single.python + - match: (\3)|((?) + pop: true + - match: '(^[ \t]+)?(?=#)' + captures: + 1: punctuation.whitespace.comment.leading.php + push: + - match: (?!\G) + pop: true + - match: "#" + captures: + 0: punctuation.definition.comment.php + push: + - meta_scope: comment.line.number-sign.php + - match: \n|(?=\?>) + pop: true + constants: + - match: |- + (?xi)(?= + ( + (\\[a-z_][a-z_0-9]*\\[a-z_][a-z_0-9\\]*)| + ([a-z_][a-z_0-9]*\\[a-z_][a-z_0-9\\]*) + ) + [^a-z_0-9\\]) + push: + - match: '(?i)([a-z_][a-z_0-9]*)?(?=[^a-z0-9_\\])' + captures: + 1: constant.other.php + pop: true + - include: namespace + - match: '(?=\\?[a-zA-Z_\x{7f}-\x{ff}])' + push: + - match: '(?=[^\\a-zA-Z_\x{7f}-\x{ff}])' + pop: true + - match: (?i)\b(TRUE|FALSE|NULL|__(FILE|DIR|FUNCTION|CLASS|METHOD|LINE|NAMESPACE)__|ON|OFF|YES|NO|NL|BR|TAB)\b + scope: constant.language.php + - match: (\\)?\b(STD(IN|OUT|ERR)|ZEND_(THREAD_SAFE|DEBUG_BUILD)|DEFAULT_INCLUDE_PATH|P(HP_(R(OUND_HALF_(ODD|DOWN|UP|EVEN)|ELEASE_VERSION)|M(INOR_VERSION|A(XPATHLEN|JOR_VERSION))|BINDIR|S(HLIB_SUFFIX|YSCONFDIR|API)|CONFIG_FILE_(SCAN_DIR|PATH)|INT_(MAX|SIZE)|ZTS|O(S|UTPUT_HANDLER_(START|CONT|END))|D(EBUG|ATADIR)|URL_(SCHEME|HOST|USER|P(ORT|A(SS|TH))|QUERY|FRAGMENT)|PREFIX|E(XT(RA_VERSION|ENSION_DIR)|OL)|VERSION(_ID)?|WINDOWS_(NT_(SERVER|DOMAIN_CONTROLLER|WORKSTATION)|VERSION_(M(INOR|AJOR)|BUILD|S(UITEMASK|P_M(INOR|AJOR))|P(RODUCTTYPE|LATFORM)))|L(IBDIR|OCALSTATEDIR))|EAR_(INSTALL_DIR|EXTENSION_DIR))|E_(RECOVERABLE_ERROR|STRICT|NOTICE|CO(RE_(ERROR|WARNING)|MPILE_(ERROR|WARNING))|DEPRECATED|USER_(NOTICE|DEPRECATED|ERROR|WARNING)|PARSE|ERROR|WARNING|ALL))\b + scope: support.constant.core.php + captures: + 1: punctuation.separator.inheritance.php + - match: (\\)?\b(RADIXCHAR|GROUPING|M(_(1_PI|SQRT(1_2|2|3|PI)|2_(SQRTPI|PI)|PI(_(2|4))?|E(ULER)?|L(N(10|2|PI)|OG(10E|2E)))|ON_(GROUPING|1(1|2|0)?|7|2|8|THOUSANDS_SEP|3|DECIMAL_POINT|9|4|5|6))|S(TR_PAD_(RIGHT|BOTH|LEFT)|ORT_(REGULAR|STRING|NUMERIC|DESC|LOCALE_STRING|ASC)|EEK_(SET|CUR|END))|H(TML_(SPECIALCHARS|ENTITIES)|ASH_HMAC)|YES(STR|EXPR)|N(_(S(IGN_POSN|EP_BY_SPACE)|CS_PRECEDES)|O(STR|EXPR)|EGATIVE_SIGN|AN)|C(R(YPT_(MD5|BLOWFISH|S(HA(256|512)|TD_DES|ALT_LENGTH)|EXT_DES)|NCYSTR|EDITS_(G(ROUP|ENERAL)|MODULES|SAPI|DOCS|QA|FULLPAGE|ALL))|HAR_MAX|O(NNECTION_(NORMAL|TIMEOUT|ABORTED)|DESET|UNT_(RECURSIVE|NORMAL))|URRENCY_SYMBOL|ASE_(UPPER|LOWER))|__COMPILER_HALT_OFFSET__|T(HOUS(EP|ANDS_SEP)|_FMT(_AMPM)?)|IN(T_(CURR_SYMBOL|FRAC_DIGITS)|I_(S(YSTEM|CANNER_(RAW|NORMAL))|USER|PERDIR|ALL)|F(O_(GENERAL|MODULES|C(REDITS|ONFIGURATION)|ENVIRONMENT|VARIABLES|LICENSE|ALL))?)|D(_(T_FMT|FMT)|IRECTORY_SEPARATOR|ECIMAL_POINT|A(Y_(1|7|2|3|4|5|6)|TE_(R(SS|FC(1(123|036)|2822|8(22|50)|3339))|COOKIE|ISO8601|W3C|ATOM)))|UPLOAD_ERR_(NO_(TMP_DIR|FILE)|CANT_WRITE|INI_SIZE|OK|PARTIAL|EXTENSION|FORM_SIZE)|P(M_STR|_(S(IGN_POSN|EP_BY_SPACE)|CS_PRECEDES)|OSITIVE_SIGN|ATH(_SEPARATOR|INFO_(BASENAME|DIRNAME|EXTENSION|FILENAME)))|E(RA(_(YEAR|T_FMT|D_(T_FMT|FMT)))?|XTR_(REFS|SKIP|IF_EXISTS|OVERWRITE|PREFIX_(SAME|I(NVALID|F_EXISTS)|ALL))|NT_(NOQUOTES|COMPAT|IGNORE|QUOTES))|FRAC_DIGITS|L(C_(M(ONETARY|ESSAGES)|NUMERIC|C(TYPE|OLLATE)|TIME|ALL)|O(G_(MAIL|SYSLOG|N(O(TICE|WAIT)|DELAY|EWS)|C(R(IT|ON)|ONS)|INFO|ODELAY|D(EBUG|AEMON)|U(SER|UCP)|P(ID|ERROR)|E(RR|MERG)|KERN|WARNING|L(OCAL(1|7|2|3|4|5|0|6)|PR)|A(UTH(PRIV)?|LERT))|CK_(SH|NB|UN|EX)))|A(M_STR|B(MON_(1(1|2|0)?|7|2|8|3|9|4|5|6)|DAY_(1|7|2|3|4|5|6))|SSERT_(BAIL|CALLBACK|QUIET_EVAL|WARNING|ACTIVE)|LT_DIGITS))\b + scope: support.constant.std.php + captures: + 1: punctuation.separator.inheritance.php + - match: |- + (?x) + (\\)?\b + (GLOB_(MARK|BRACE|NO(SORT|CHECK|ESCAPE)|ONLYDIR|ERR|AVAILABLE_FLAGS)|XML_(SAX_IMPL|HTML_DOCUMENT_NODE|N(OTATION_NODE|AMESPACE_DECL_NODE)|C(OMMENT_NODE|DATA_SECTION_NODE)|TEXT_NODE|OPTION_(SKIP_(TAGSTART|WHITE)|CASE_FOLDING|TARGET_ENCODING)|D(TD_NODE|OCUMENT_(NODE|TYPE_NODE|FRAG_NODE))|PI_NODE|E(RROR_(RECURSIVE_ENTITY_REF|MISPLACED_XML_PI|B(INARY_ENTITY_REF|AD_CHAR_REF)|SYNTAX|NO(NE|_(MEMORY|ELEMENTS))|TAG_MISMATCH|IN(CORRECT_ENCODING|VALID_TOKEN)|DUPLICATE_ATTRIBUTE|UN(CLOSED_(CDATA_SECTION|TOKEN)|DEFINED_ENTITY|KNOWN_ENCODING)|JUNK_AFTER_DOC_ELEMENT|PAR(TIAL_CHAR|AM_ENTITY_REF)|EXTERNAL_ENTITY_HANDLING|A(SYNC_ENTITY|TTRIBUTE_EXTERNAL_ENTITY_REF))|NTITY_(REF_NODE|NODE|DECL_NODE)|LEMENT_(NODE|DECL_NODE))|LOCAL_NAMESPACE|ATTRIBUTE_(N(MTOKEN(S)?|O(TATION|DE))|CDATA|ID(REF(S)?)?|DECL_NODE|EN(TITY|UMERATION)))|M(HASH_(RIPEMD(1(28|60)|256|320)|GOST|MD(2|4|5)|S(HA(1|2(24|56)|384|512)|NEFRU256)|HAVAL(1(28|92|60)|2(24|56))|CRC32(B)?|TIGER(1(28|60))?|WHIRLPOOL|ADLER32)|YSQL(_(BOTH|NUM|CLIENT_(SSL|COMPRESS|I(GNORE_SPACE|NTERACTIVE))|ASSOC)|I_(RE(PORT_(STRICT|INDEX|OFF|ERROR|ALL)|FRESH_(GRANT|MASTER|BACKUP_LOG|S(TATUS|LAVE)|HOSTS|T(HREADS|ABLES)|LOG)|AD_DEFAULT_(GROUP|FILE))|GROUP_FLAG|MULTIPLE_KEY_FLAG|B(INARY_FLAG|OTH|LOB_FLAG)|S(T(MT_ATTR_(CURSOR_TYPE|UPDATE_MAX_LENGTH|PREFETCH_ROWS)|ORE_RESULT)|E(RVER_QUERY_(NO_(GOOD_INDEX_USED|INDEX_USED)|WAS_SLOW)|T_(CHARSET_NAME|FLAG)))|N(O(_D(EFAULT_VALUE_FLAG|ATA)|T_NULL_FLAG)|UM(_FLAG)?)|C(URSOR_TYPE_(READ_ONLY|SCROLLABLE|NO_CURSOR|FOR_UPDATE)|LIENT_(SSL|NO_SCHEMA|COMPRESS|I(GNORE_SPACE|NTERACTIVE)|FOUND_ROWS))|T(YPE_(GEOMETRY|MEDIUM_BLOB|B(IT|LOB)|S(HORT|TRING|ET)|YEAR|N(ULL|EWD(ECIMAL|ATE))|CHAR|TI(ME(STAMP)?|NY(_BLOB)?)|INT(24|ERVAL)|D(OUBLE|ECIMAL|ATE(TIME)?)|ENUM|VAR_STRING|FLOAT|LONG(_BLOB|LONG)?)|IMESTAMP_FLAG)|INIT_COMMAND|ZEROFILL_FLAG|O(N_UPDATE_NOW_FLAG|PT_(NET_(READ_BUFFER_SIZE|CMD_BUFFER_SIZE)|CONNECT_TIMEOUT|INT_AND_FLOAT_NATIVE|LOCAL_INFILE))|D(EBUG_TRACE_ENABLED|ATA_TRUNCATED)|U(SE_RESULT|N(SIGNED_FLAG|IQUE_KEY_FLAG))|P(RI_KEY_FLAG|ART_KEY_FLAG)|ENUM_FLAG|A(S(SOC|YNC)|UTO_INCREMENT_FLAG)))|CRYPT_(R(C(2|6)|IJNDAEL_(1(28|92)|256)|AND)|GOST|XTEA|M(ODE_(STREAM|NOFB|C(BC|FB)|OFB|ECB)|ARS)|BLOWFISH(_COMPAT)?|S(ERPENT|KIPJACK|AFER(128|PLUS|64))|C(RYPT|AST_(128|256))|T(RIPLEDES|HREEWAY|WOFISH)|IDEA|3DES| + DE(S|CRYPT|V_(RANDOM|URANDOM))|PANAMA|EN(CRYPT|IGNA)|WAKE|LOKI97|ARCFOUR(_IV)?))|S(TREAM_(REPORT_ERRORS|M(UST_SEEK|KDIR_RECURSIVE)|BUFFER_(NONE|FULL|LINE)|S(HUT_(RD(WR)?|WR)|OCK_(R(DM|AW)|S(TREAM|EQPACKET)|DGRAM)|ERVER_(BIND|LISTEN))|NOTIFY_(RE(SOLVE|DIRECTED)|MIME_TYPE_IS|SEVERITY_(INFO|ERR|WARN)|CO(MPLETED|NNECT)|PROGRESS|F(ILE_SIZE_IS|AILURE)|AUTH_RE(SULT|QUIRED))|C(RYPTO_METHOD_(SSLv(2(_(SERVER|CLIENT)|3_(SERVER|CLIENT))|3_(SERVER|CLIENT))|TLS_(SERVER|CLIENT))|LIENT_(CONNECT|PERSISTENT|ASYNC_CONNECT)|AST_(FOR_SELECT|AS_STREAM))|I(GNORE_URL|S_URL|PPROTO_(RAW|TCP|I(CMP|P)|UDP))|O(OB|PTION_(READ_(BUFFER|TIMEOUT)|BLOCKING|WRITE_BUFFER))|U(RL_STAT_(QUIET|LINK)|SE_PATH)|P(EEK|F_(INET(6)?|UNIX))|ENFORCE_SAFE_MODE|FILTER_(READ|WRITE|ALL))|UNFUNCS_RET_(STRING|TIMESTAMP|DOUBLE)|QLITE(_(R(OW|EADONLY)|MIS(MATCH|USE)|B(OTH|USY)|SCHEMA|N(O(MEM|T(FOUND|ADB)|LFS)|UM)|C(O(RRUPT|NSTRAINT)|ANTOPEN)|TOOBIG|I(NTER(RUPT|NAL)|OERR)|OK|DONE|P(ROTOCOL|ERM)|E(RROR|MPTY)|F(ORMAT|ULL)|LOCKED|A(BORT|SSOC|UTH))|3_(B(OTH|LOB)|NU(M|LL)|TEXT|INTEGER|OPEN_(READ(ONLY|WRITE)|CREATE)|FLOAT|ASSOC)))|CURL(M(SG_DONE|_(BAD_(HANDLE|EASY_HANDLE)|CALL_MULTI_PERFORM|INTERNAL_ERROR|O(UT_OF_MEMORY|K)))|SSH_AUTH_(HOST|NONE|DEFAULT|P(UBLICKEY|ASSWORD)|KEYBOARD)|CLOSEPOLICY_(SLOWEST|CALLBACK|OLDEST|LEAST_(RECENTLY_USED|TRAFFIC))|_(HTTP_VERSION_(1_(1|0)|NONE)|NETRC_(REQUIRED|IGNORED|OPTIONAL)|TIMECOND_(IF(MODSINCE|UNMODSINCE)|LASTMOD)|IPRESOLVE_(V(4|6)|WHATEVER)|VERSION_(SSL|IPV6|KERBEROS4|LIBZ))|INFO_(RE(DIRECT_(COUNT|TIME)|QUEST_SIZE)|S(SL_VERIFYRESULT|TARTTRANSFER_TIME|IZE_(DOWNLOAD|UPLOAD)|PEED_(DOWNLOAD|UPLOAD))|H(TTP_CODE|EADER_(SIZE|OUT))|NAMELOOKUP_TIME|C(ON(NECT_TIME|TENT_(TYPE|LENGTH_(DOWNLOAD|UPLOAD)))|ERTINFO)|TOTAL_TIME|PR(IVATE|ETRANSFER_TIME)|EFFECTIVE_URL|FILETIME)|OPT_(R(E(SUME_FROM|TURNTRANSFER|DIR_PROTOCOLS|FERER|AD(DATA|FUNCTION))|AN(GE|DOM_FILE))|MAX(REDIRS|CONNECTS)|B(INARYTRANSFER|UFFERSIZE)|S(S(H_(HOST_PUBLIC_KEY_MD5|P(RIVATE_KEYFILE|UBLIC_KEYFILE)|AUTH_TYPES)|L(CERT(TYPE|PASSWD)?|_(CIPHER_LIST|VERIFY(HOST|PEER))|ENGINE(_DEFAULT)?|VERSION|KEY(TYPE|PASSWD)?))|TDERR)|H(TTP(GET|HEADER|200ALIASES|_VERSION|PROXYTUNNEL|AUTH)|EADER(FUNCTION)?) + |N(O(BODY|SIGNAL|PROGRESS)|ETRC)|C(RLF|O(NNECTTIMEOUT(_MS)?|OKIE(SESSION|JAR|FILE)?)|USTOMREQUEST|ERTINFO|LOSEPOLICY|A(INFO|PATH))|T(RANSFERTEXT|CP_NODELAY|IME(CONDITION|OUT(_MS)?|VALUE))|I(N(TERFACE|FILE(SIZE)?)|PRESOLVE)|DNS_(CACHE_TIMEOUT|USE_GLOBAL_CACHE)|U(RL|SER(PWD|AGENT)|NRESTRICTED_AUTH|PLOAD)|P(R(IVATE|O(GRESSFUNCTION|XY(TYPE|USERPWD|PORT|AUTH)?|TOCOLS))|O(RT|ST(REDIR|QUOTE|FIELDS)?)|UT)|E(GDSOCKET|NCODING)|VERBOSE|K(RB4LEVEL|EYPASSWD)|QUOTE|F(RESH_CONNECT|TP(SSLAUTH|_(S(SL|KIP_PASV_IP)|CREATE_MISSING_DIRS|USE_EP(RT|SV)|FILEMETHOD)|PORT|LISTONLY|APPEND)|ILE(TIME)?|O(RBID_REUSE|LLOWLOCATION)|AILONERROR)|WRITE(HEADER|FUNCTION)|LOW_SPEED_(TIME|LIMIT)|AUTOREFERER)|PRO(XY_(SOCKS(4|5)|HTTP)|TO_(S(CP|FTP)|HTTP(S)?|T(ELNET|FTP)|DICT|F(TP(S)?|ILE)|LDAP(S)?|ALL))|E_(RE(CV_ERROR|AD_ERROR)|GOT_NOTHING|MALFORMAT_USER|BAD_(C(ONTENT_ENCODING|ALLING_ORDER)|PASSWORD_ENTERED|FUNCTION_ARGUMENT)|S(S(H|L_(C(IPHER|ONNECT_ERROR|ERTPROBLEM|ACERT)|PEER_CERTIFICATE|ENGINE_(SETFAILED|NOTFOUND)))|HARE_IN_USE|END_ERROR)|HTTP_(RANGE_ERROR|NOT_FOUND|PO(RT_FAILED|ST_ERROR))|COULDNT_(RESOLVE_(HOST|PROXY)|CONNECT)|T(OO_MANY_REDIRECTS|ELNET_OPTION_SYNTAX)|O(BSOLETE|UT_OF_MEMORY|PERATION_TIMEOUTED|K)|U(RL_MALFORMAT(_USER)?|N(SUPPORTED_PROTOCOL|KNOWN_TELNET_OPTION))|PARTIAL_FILE|F(TP_(BAD_DOWNLOAD_RESUME|SSL_FAILED|C(OULDNT_(RETR_FILE|GET_SIZE|S(TOR_FILE|ET_(BINARY|ASCII))|USE_REST)|ANT_(RECONNECT|GET_HOST))|USER_PASSWORD_INCORRECT|PORT_FAILED|QUOTE_ERROR|W(RITE_ERROR|EIRD_(SERVER_REPLY|227_FORMAT|USER_REPLY|PAS(S_REPLY|V_REPLY)))|ACCESS_DENIED)|ILE(SIZE_EXCEEDED|_COULDNT_READ_FILE)|UNCTION_NOT_FOUND|AILED_INIT)|WRITE_ERROR|L(IBRARY_NOT_FOUND|DAP_(SEARCH_FAILED|CANNOT_BIND|INVALID_URL))|ABORTED_BY_CALLBACK)|VERSION_NOW|FTP(METHOD_(MULTICWD|SINGLECWD|NOCWD)|SSL_(NONE|CONTROL|TRY|ALL)|AUTH_(SSL|TLS|DEFAULT))|AUTH_(GSSNEGOTIATE|BASIC|NTLM|DIGEST|ANY(SAFE)?))|I(MAGETYPE_(GIF|XBM|BMP|SWF|COUNT|TIFF_(MM|II)|I(CO|FF)|UNKNOWN|J(B2|P(X|2|C|EG(2000)?))|P(SD|NG)|WBMP)|NPUT_(REQUEST|GET|SE(RVER|SSION)|COOKIE|POST|ENV)|CONV_(MIME_DECODE_(STRICT|CONTINUE_ON_ERROR)|IMPL|VERSION))|D(NS_(MX|S(RV|OA)|HINFO|N(S|APTR)|CNAME|TXT|PTR|A(NY|LL|AAA|6)?)|OM(STRING_SIZE_ERR|_(SYNTAX_ERR|HIERARCHY_REQUEST_ERR|N(O(_(MODIFICATION_ALLOWED_ERR|DATA_ALLOWED_ERR)|T_(SUPPORTED_ERR|FOUND_ERR))|AMESPACE_ERR)|IN(DEX_SIZE_ERR|USE_ATTRIBUTE_ERR|VALID_(MODIFICATION_ERR|STATE_ERR|CHARACTER_ERR|ACCESS_ERR))|PHP_ERR|VALIDATION_ERR|WRONG_DOCUMENT_ERR)))|JSON_(HEX_(TAG|QUOT|A(MP|POS))|NUMERIC_CHECK|ERROR_(S(YNTAX|TATE_MISMATCH)|NONE|CTRL_CHAR|DEPTH|UTF8)|FORCE_OBJECT)|P(REG_(RECURSION_LIMIT_ERROR|GREP_INVERT|BA(CKTRACK_LIMIT_ERROR|D_UTF8_(OFFSET_ERROR|ERROR))|S(PLIT_(NO_EMPTY|OFFSET_CAPTURE|DELIM_CAPTURE)|ET_ORDER)|NO_ERROR|INTERNAL_ERROR|OFFSET_CAPTURE|PATTERN_ORDER)|SFS_(PASS_ON|ERR_FATAL|F(EED_ME|LAG_(NORMAL|FLUSH_(CLOSE|INC))))|CRE_VERSION|OSIX_(R_OK|X_OK|S_IF(REG|BLK|SOCK|CHR|IFO)|F_OK|W_OK))|F(NM_(NOESCAPE|CASEFOLD|P(ERIOD|ATHNAME))|IL(TER_(REQUIRE_(SCALAR|ARRAY)|SANITIZE_(MAGIC_QUOTES|S(TRI(NG|PPED)|PECIAL_CHARS)|NUMBER_(INT|FLOAT)|URL|E(MAIL|NCODED)|FULL_SPECIAL_CHARS)|NULL_ON_FAILURE|CALLBACK|DEFAULT|UNSAFE_RAW|VALIDATE_(REGEXP|BOOLEAN|I(NT|P)|URL|EMAIL|FLOAT)|F(ORCE_ARRAY|LAG_(S(CHEME_REQUIRED|TRIP_(BACKTICK|HIGH|LOW))|HOST_REQUIRED|NO(NE|_(RES_RANGE|PRIV_RANGE|ENCODE_QUOTES))|IPV(4|6)|PATH_REQUIRED|E(MPTY_STRING_NULL|NCODE_(HIGH|LOW|AMP))|QUERY_REQUIRED|ALLOW_(SCIENTIFIC|HEX|THOUSAND|OCTAL|FRACTION))))|E(_(BINARY|SKIP_EMPTY_LINES|NO_DEFAULT_CONTEXT|TEXT|IGNORE_NEW_LINES|USE_INCLUDE_PATH|APPEND)|INFO_(RAW|MIME(_(TYPE|ENCODING))?|SYMLINK|NONE|CONTINUE|DEVICES|PRESERVE_ATIME)))|ORCE_(GZIP|DEFLATE))|LIBXML_(XINCLUDE|N(SCLEAN|O(XMLDECL|BLANKS|NET|CDATA|E(RROR|MPTYTAG|NT)|WARNING))|COMPACT|D(TD(VALID|LOAD|ATTR)|OTTED_VERSION)|PARSEHUGE|ERR_(NONE|ERROR|FATAL|WARNING)|VERSION|LOADED_VERSION)) + \b + scope: support.constant.ext.php + captures: + 1: punctuation.separator.inheritance.php + - match: (\\)?\bT_(RE(TURN|QUIRE(_ONCE)?)|G(OTO|LOBAL)|XOR_EQUAL|M(INUS_EQUAL|OD_EQUAL|UL_EQUAL|ETHOD_C|L_COMMENT)|B(REAK|OOL(_CAST|EAN_(OR|AND))|AD_CHARACTER)|S(R(_EQUAL)?|T(RING(_(CAST|VARNAME))?|A(RT_HEREDOC|TIC))|WITCH|L(_EQUAL)?)|HALT_COMPILER|N(S_(SEPARATOR|C)|UM_STRING|EW|AMESPACE)|C(HARACTER|O(MMENT|N(ST(ANT_ENCAPSED_STRING)?|CAT_EQUAL|TINUE))|URLY_OPEN|L(O(SE_TAG|NE)|ASS(_C)?)|A(SE|TCH))|T(RY|HROW)|I(MPLEMENTS|S(SET|_(GREATER_OR_EQUAL|SMALLER_OR_EQUAL|NOT_(IDENTICAL|EQUAL)|IDENTICAL|EQUAL))|N(STANCEOF|C(LUDE(_ONCE)?)?|T(_CAST|ERFACE)|LINE_HTML)|F)|O(R_EQUAL|BJECT_(CAST|OPERATOR)|PEN_TAG(_WITH_ECHO)?|LD_FUNCTION)|D(NUMBER|I(R|V_EQUAL)|O(C_COMMENT|UBLE_(C(OLON|AST)|ARROW)|LLAR_OPEN_CURLY_BRACES)?|E(C(LARE)?|FAULT))|U(SE|NSET(_CAST)?)|P(R(I(NT|VATE)|OTECTED)|UBLIC|LUS_EQUAL|AAMAYIM_NEKUDOTAYIM)|E(X(TENDS|IT)|MPTY|N(CAPSED_AND_WHITESPACE|D(SWITCH|_HEREDOC|IF|DECLARE|FOR(EACH)?|WHILE))|CHO|VAL|LSE(IF)?)|VAR(IABLE)?|F(I(NAL|LE)|OR(EACH)?|UNC(_C|TION))|WHI(TESPACE|LE)|L(NUMBER|I(ST|NE)|OGICAL_(XOR|OR|AND))|A(RRAY(_CAST)?|BSTRACT|S|ND_EQUAL))\b + scope: support.constant.parser-token.php + captures: + 1: punctuation.separator.inheritance.php + - match: '[a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*' + comment: | + In PHP, any identifier which is not a variable is taken to be a constant. + However, if there is no constant defined with the given name then a notice + is generated and the constant is assumed to have the value of its name. + scope: constant.other.php + function-arguments: + - include: comments + - match: |- + (?ix) + (?: # Optional + (\?)? + (?: + (array|bool|float|int|string) # scalar-type + | (callable|iterable) # base-type-declaration + | ([a-z_0-9\\]*[a-z_][a-z_0-9]*) + ) + \s+ + )? + (?:(&)\s*)? # Reference + ((\$+)[a-z_\x{7f}-\x{ff}][a-z0-9_\x{7f}-\x{ff}]*) # Variable name + captures: + 1: storage.modifier.nullable.php + 2: storage.type.$2.php + 3: storage.modifier.$3.php + 5: storage.modifier.reference.php + 6: variable.other.php + 7: punctuation.definition.variable.php + push: + - meta_scope: meta.function.argment.php + - match: '(?=,|\)|/[/*]|\#)' + pop: true + - match: \s*(=) + captures: + 1: keyword.operator.assignment.php + push: + - match: '(?=,|\)|/[/*]|\#)' + pop: true + - include: parameter-default-types + - match: \S + scope: invalid.illegal.character-not-allowed-here.php + function-call: + - match: '(?i)(?=\\?[a-z_0-9\\]+\\[a-z_][a-z0-9_]*\s*\()' + comment: Functions in a user-defined namespace (overrides any built-ins) + push: + - match: (?=\s*\() + pop: true + - include: user-function-call + - match: (?i)\b(print|echo)\b + scope: support.function.construct.php + - match: '(?i)(\\)?(?=\b[a-z_][a-z_0-9]*\s*\()' + comment: Root namespace function calls (built-in or user) + captures: + 1: punctuation.separator.inheritance.php + push: + - match: (?=\s*\() + pop: true + - match: (?i)\b(isset|unset|e(val|mpty)|list)(?=\s*\() + scope: support.function.construct.php + - include: support + - include: user-function-call + heredoc: + - match: '(?=<<<\s*("?)([a-zA-Z_]+[a-zA-Z0-9_]*)(\1)\s*$)' + push: + - meta_scope: string.unquoted.heredoc.php + - match: (?!\G) + pop: true + - match: '(?=<<<\s*(''?)([a-zA-Z_]+[a-zA-Z0-9_]*)(\1)\s*$)' + push: + - meta_scope: string.unquoted.heredoc.nowdoc.php + - match: (?!\G) + pop: true + instantiation: + - match: (?i)(new)\s+ + captures: + 1: keyword.other.new.php + push: + - match: '(?i)(?=[^$a-z0-9_\\])' + pop: true + - match: "(parent|static|self)(?=[^a-z0-9_])" + scope: storage.type.php + - include: class-name + - include: variable-name + interpolation: [] + invoke-call: + - match: '(?i)(\$+)([a-z_][a-z_0-9]*)(?=\s*\()' + scope: meta.function-call.invoke.php + captures: + 1: punctuation.definition.variable.php + 2: variable.other.php + language: + - include: comments + - match: '\{' + scope: punctuation.section.scope.begin.php + - match: '\}' + scope: punctuation.section.scope.end.php + - match: '(?i)^\s*(interface)\s+([a-z0-9_]+)\s*(extends)?\s*' + captures: + 1: storage.type.interface.php + 2: entity.name.type.interface.php + 3: storage.modifier.extends.php + push: + - meta_scope: meta.interface.php + - match: '((?:[a-zA-Z0-9_]+\s*,\s*)*)([a-zA-Z0-9_]+)?\s*(?:(?=\{)|$)' + captures: + 2: entity.other.inherited-class.php + pop: true + - include: namespace + - match: '(?i)(?:^|(?<=<\?php))\s*(namespace)\b\s+(?=([a-z0-9_\\]+\s*($|[;{]|(\/[\/*])))|$)' + captures: + 1: keyword.other.namespace.php + push: + - meta_scope: meta.namespace.php + - meta_content_scope: entity.name.type.namespace.php + - match: '(?i)(?=\s*$|[^a-z0-9_\\])' + pop: true + - match: \\ + scope: punctuation.separator.inheritance.php + - match: (?i)\s*\b(use)\s+(?:((const)|(function))\s+)? + captures: + 1: keyword.other.use.php + 3: storage.type.const.php + 4: storage.type.function.php + push: + - meta_scope: meta.use.php + - match: (?=;|(?:^\s*$)) + pop: true + - include: comments + - match: '(?i)\s*(?=[a-z_0-9\\])' + push: + - match: |- + (?xi)(?: + (?:\s*(as)\b\s*([a-z_0-9]*)\s*(?=,|;|$)) + |(?=,|;|$) + ) + captures: + 1: keyword.other.use-as.php + 2: support.other.namespace.use-as.php + pop: true + - include: class-builtin + - match: '(?i)\s*(?=[\\a-z_0-9])' + push: + - meta_scope: support.other.namespace.use.php + - match: '$|(?=[\s,;])' + pop: true + - match: \\ + scope: punctuation.separator.inheritance.php + - match: \s*,\s* + - match: '(?i)^\s*(trait)\s+([a-zA-Z0-9_]+)' + captures: + 1: storage.type.trait.php + 2: entity.name.type.trait.php + push: + - meta_scope: meta.trait.php + - match: '(?=\{)' + pop: true + - match: '(?i)^\s*(abstract|final)?\s*(class)\s+([a-z0-9_]+)\s*' + captures: + 1: storage.modifier.abstract.php + 2: storage.type.class.php + 3: entity.name.type.class.php + push: + - meta_scope: meta.class.php + - match: "(?=[;{])" + pop: true + - include: comments + - match: (?i)(extends)\s+ + captures: + 1: storage.modifier.extends.php + push: + - meta_content_scope: meta.other.inherited-class.php + - match: '(?i)(?=[^a-z_0-9\\])' + pop: true + - match: '(?i)(?=\\?[a-z_0-9]+\\)' + push: + - match: '(?i)([a-z_][a-z_0-9]*)?(?=[^a-z0-9_\\])' + captures: + 1: entity.other.inherited-class.php + pop: true + - include: namespace + - include: class-builtin + - include: namespace + - match: "(?i)[a-z_][a-z_0-9]*" + scope: entity.other.inherited-class.php + - match: (?i)(implements)\s+ + captures: + 1: storage.modifier.implements.php + push: + - match: "(?i)(?=[;{])" + pop: true + - include: comments + - match: '(?i)(?=[a-z0-9_\\]+)' + push: + - meta_content_scope: meta.other.inherited-class.php + - match: '(?i)(?:\s*(?:,|(?=[^a-z0-9_\\\s]))\s*)' + pop: true + - match: '(?i)(?=\\?[a-z_0-9]+\\)' + push: + - match: '(?i)([a-z_][a-z_0-9]*)?(?=[^a-z0-9_\\])' + captures: + 1: entity.other.inherited-class.php + pop: true + - include: namespace + - include: class-builtin + - include: namespace + - match: "(?i)[a-z_][a-z_0-9]*" + scope: entity.other.inherited-class.php + - match: \s*\b((break|c(ase|ontinue)|d(e(clare|fault)|ie|o)|e(lse(if)?|nd(declare|for(each)?|if|switch|while)|xit)|for(each)?|if|return|switch|use|while|yield))\b + captures: + 1: keyword.control.php + - match: (?i)\b((?:require|include)(?:_once)?)\b\s* + captures: + 1: keyword.control.import.include.php + push: + - meta_scope: meta.include.php + - match: (?=\s|;|$) + pop: true + - include: language + - match: \b(catch)\b\s*\(\s* + captures: + 1: keyword.control.exception.catch.php + push: + - meta_scope: meta.catch.php + - match: '([A-Za-z_][A-Za-z_0-9]*)\s*((\$+)[a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*)\s*\)' + captures: + 1: support.class.exception.php + 2: variable.other.php + 3: punctuation.definition.variable.php + pop: true + - include: namespace + - match: \b(catch|try|throw|exception|finally)\b + scope: keyword.control.exception.php + - match: (?i)\b(function)\s*(&\s*)?(?=\() + captures: + 1: storage.type.function.php + 2: storage.modifier.reference.php + push: + - meta_scope: meta.function.closure.php + - match: '\{' + pop: true + - match: (\() + captures: + 1: punctuation.definition.parameters.begin.php + push: + - meta_content_scope: meta.function.arguments.php + - match: (\)) + captures: + 1: punctuation.definition.parameters.end.php + pop: true + - include: function-arguments + - match: (?i)(use)\s*(\() + captures: + 1: keyword.other.function.use.php + 2: punctuation.definition.parameters.begin.php + push: + - match: (\)) + captures: + 1: punctuation.definition.parameters.end.php + pop: true + - match: '(?:\s*(&))?\s*((\$+)[a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*)\s*(?=,|\))' + scope: meta.function.closure.use.php + captures: + 1: storage.modifier.reference.php + 2: variable.other.php + 3: punctuation.definition.variable.php + - match: |- + (?x)\s* + ((?:(?:final|abstract|public|private|protected|static)\s+)*) + (function) + (?:\s+|(\s*&\s*)) + (?: + (__(?:call|construct|debugInfo|destruct|get|set|isset|unset|tostring|clone|set_state|sleep|wakeup|autoload|invoke|callStatic)) + |([a-zA-Z0-9_]+) + ) + \s* + (\() + captures: + 2: storage.type.function.php + 3: storage.modifier.reference.php + 4: support.function.magic.php + 5: entity.name.function.php + 6: punctuation.definition.parameters.begin.php + push: + - meta_scope: meta.function.php + - meta_content_scope: meta.function.arguments.php + - match: |- + (?ix) + (\)) # Close arguments + (?: # Optional return type + \s*(:)\s* + (\?)? + (?: + (array|bool|float|int|string) # scalar-type + | (callable|iterable) # base-type-declaration + | (void) + | ([a-z_0-9\\]*[a-z_][a-z_0-9]*) # qualified-name + ) + )? + captures: + 1: punctuation.definition.parameters.end.php + 2: punctuation.separator.return-type.php + 3: storage.modifier.nullable.php + 4: storage.type.$4.php + 5: storage.modifier.$5.php + 6: storage.type.void.php + pop: true + - include: function-arguments + - include: invoke-call + - match: |- + (?xi)\s*(?= + [a-z_0-9$\\]+(::) + (?: + ([a-z_][a-z_0-9]*)\s*\( + | + ((\$+)[a-z_\x{7f}-\x{ff}][a-z0-9_\x{7f}-\x{ff}]*) + | + ([a-z_\x{7f}-\x{ff}][a-z0-9_\x{7f}-\x{ff}]*) + )? + ) + push: + - match: |- + (?x)(::) + (?: + ([A-Za-z_][A-Za-z_0-9]*)\s*\( + | + ((\$+)[a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*) + | + ([a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*) + )? + captures: + 1: keyword.operator.class.php + 2: meta.function-call.static.php + 3: variable.other.class.php + 4: punctuation.definition.variable.php + 5: constant.other.class.php + pop: true + - match: (self|static|parent)\b + scope: storage.type.php + - include: class-name + - include: variable-name + - include: variables + - include: strings + - match: (array)(\()(\)) + scope: meta.array.empty.php + captures: + 1: support.function.construct.php + 2: punctuation.definition.array.begin.php + 3: punctuation.definition.array.end.php + - match: (array)(\() + captures: + 1: support.function.construct.php + 2: punctuation.definition.array.begin.php + push: + - meta_scope: meta.array.php + - match: \) + captures: + 0: punctuation.definition.array.end.php + pop: true + - include: language + - match: (?i)\s*\(\s*(array|real|double|float|int(eger)?|bool(ean)?|string|object|binary|unset)\s*\) + captures: + 1: storage.type.php + - match: (?i)\b(array|real|double|float|int(eger)?|bool(ean)?|string|class|clone|var|function|interface|parent|self|object)\b + scope: storage.type.php + - match: (?i)\b(global|abstract|const|extends|implements|final|p(r(ivate|otected)|ublic)|static)\b + scope: storage.modifier.php + - include: object + - match: ; + scope: punctuation.terminator.expression.php + - include: heredoc + - match: \.=? + scope: keyword.operator.string.php + - match: "=>" + scope: keyword.operator.key.php + - match: '(?:(\=)(&))|(&(?=[$A-Za-z_]))' + captures: + 1: keyword.operator.assignment.php + 2: storage.modifier.reference.php + 3: storage.modifier.reference.php + - match: (@) + scope: keyword.operator.error-control.php + - match: (\-\-|\+\+) + scope: keyword.operator.increment-decrement.php + - match: (\-|\+|\*|/|%) + scope: keyword.operator.arithmetic.php + - match: (?i)(!|&&|\|\|)|\b(and|or|xor|as)\b + scope: keyword.operator.logical.php + - include: function-call + - match: '<<|>>|~|\^|&|\|' + scope: keyword.operator.bitwise.php + - match: (===|==|!==|!=|<=|>=|<>|<|>) + scope: keyword.operator.comparison.php + - match: "=" + scope: keyword.operator.assignment.php + - match: '(?i)\b(instanceof)\b\s+(?=[\\$a-z_])' + captures: + 1: keyword.operator.type.php + push: + - match: '(?=[^\\$A-Za-z_0-9])' + pop: true + - include: class-name + - include: variable-name + - include: numbers + - include: instantiation + - match: '(?i)(goto)\s+([a-z_][a-z_0-9]*)' + captures: + 1: keyword.control.goto.php + 2: support.other.php + - match: '(?i)^\s*([a-z_][a-z_0-9]*)\s*:' + captures: + 1: entity.name.goto-label.php + - include: string-backtick + - match: '\[' + captures: + 0: punctuation.section.array.begin.php + push: + - match: '\]' + captures: + 0: punctuation.section.array.end.php + pop: true + - include: language + - include: constants + namespace: + - match: '(?i)(?:(namespace)|[a-z0-9_]+)?(\\)(?=.*?([^a-z0-9_\\]|\z))' + captures: + 1: variable.language.namespace.php + 2: punctuation.separator.inheritance.php + push: + - meta_scope: support.other.namespace.php + - match: '(?i)(?=[a-z0-9_]*([^a-z0-9_\\]|\z))' + pop: true + - match: (?i)(\\) + captures: + 1: punctuation.separator.inheritance.php + numbers: + - match: '\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)\b' + scope: constant.numeric.php + object: + - match: '(->)(\$?\{)' + captures: + 1: keyword.operator.class.php + 2: punctuation.definition.variable.php + push: + - match: '(\})' + captures: + 1: punctuation.definition.variable.php + pop: true + - include: language + - match: |- + (?x)(->) + (?: + ([A-Za-z_][A-Za-z_0-9]*)\s*\( + | + ((\$+)?[a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*) + )? + captures: + 1: keyword.operator.class.php + 2: meta.function-call.object.php + 3: variable.other.property.php + 4: punctuation.definition.variable.php + parameter-default-types: + - include: strings + - include: numbers + - include: string-backtick + - include: variables + - match: "=>" + scope: keyword.operator.key.php + - match: "=" + scope: keyword.operator.assignment.php + - match: '&(?=\s*\$)' + scope: storage.modifier.reference.php + - match: (array)\s*(\() + captures: + 1: support.function.construct.php + 2: punctuation.definition.array.begin.php + push: + - meta_scope: meta.array.php + - match: \) + captures: + 0: punctuation.definition.array.end.php + pop: true + - include: parameter-default-types + - include: instantiation + - match: |- + (?xi)\s*(?= + [a-z_0-9\\]+(::) + ([a-z_\x{7f}-\x{ff}][a-z0-9_\x{7f}-\x{ff}]*)? + ) + push: + - match: '(?i)(::)([a-z_\x{7f}-\x{ff}][a-z0-9_\x{7f}-\x{ff}]*)?' + captures: + 1: keyword.operator.class.php + 2: constant.other.class.php + pop: true + - include: class-name + - include: constants + php_doc: + - match: ^(?!\s*\*).*$\n? + comment: PHPDocumentor only recognises lines with an asterisk as the first non-whitespaces character + scope: invalid.illegal.missing-asterisk.phpdoc.php + - match: ^\s*\*\s*(@access)\s+((public|private|protected)|(.+))\s*$ + captures: + 1: keyword.other.phpdoc.php + 3: storage.modifier.php + 4: invalid.illegal.wrong-access-type.phpdoc.php + - match: (@xlink)\s+(.+)\s*$ + captures: + 1: keyword.other.phpdoc.php + 2: markup.underline.link.php + - match: \@(a(bstract|uthor)|c(ategory|opyright)|example|global|internal|li(cense|nk)|pa(ckage|ram)|return|s(ee|ince|tatic|ubpackage)|t(hrows|odo)|v(ar|ersion)|uses|deprecated|final|ignore)\b + scope: keyword.other.phpdoc.php + - match: '\{(@(link)).+?\}' + scope: meta.tag.inline.phpdoc.php + captures: + 1: keyword.other.phpdoc.php + regex-double-quoted: + - match: '(?x)"/ (?= (\\.|[^"/])++/[imsxeADSUXu]*" )' + captures: + 0: punctuation.definition.string.begin.php + push: + - meta_scope: string.regexp.double-quoted.php + - match: '(/)([imsxeADSUXu]*)(")' + captures: + 0: punctuation.definition.string.end.php + pop: true + - match: '(\\){1,2}[.$^\[\]{}]' + comment: Escaped from the regexp – there can also be 2 backslashes (since 1 will escape the first) + scope: constant.character.escape.regex.php + - include: interpolation + - match: '(\{)\d+(,\d+)?(\})' + scope: string.regexp.arbitrary-repitition.php + captures: + 1: punctuation.definition.arbitrary-repitition.php + 3: punctuation.definition.arbitrary-repitition.php + - match: '\[(?:\^?\])?' + captures: + 0: punctuation.definition.character-class.php + push: + - meta_scope: string.regexp.character-class.php + - match: '\]' + captures: + 0: punctuation.definition.character-class.php + pop: true + - include: interpolation + - match: "[$^+*]" + scope: keyword.operator.regexp.php + regex-single-quoted: + - match: '(?x)''/ (?= ( \\ (?: \\ (?: \\ [\\'']? | [^''] ) | . ) | [^''/] )++/[imsxeADSUXu]*'' )' + captures: + 0: punctuation.definition.string.begin.php + push: + - meta_scope: string.regexp.single-quoted.php + - match: "(/)([imsxeADSUXu]*)(')" + captures: + 0: punctuation.definition.string.end.php + pop: true + - match: '(\{)\d+(,\d+)?(\})' + scope: string.regexp.arbitrary-repitition.php + captures: + 1: punctuation.definition.arbitrary-repitition.php + 3: punctuation.definition.arbitrary-repitition.php + - match: '\[(?:\^?\])?' + captures: + 0: punctuation.definition.character-class.php + push: + - meta_scope: string.regexp.character-class.php + - match: '\]' + captures: + 0: punctuation.definition.character-class.php + pop: true + - match: "[$^+*]" + scope: keyword.operator.regexp.php + sql-string-double-quoted: + - match: '"\s*(?=(SELECT|INSERT|UPDATE|DELETE|CREATE|REPLACE|ALTER)\b)' + captures: + 0: punctuation.definition.string.begin.php + push: + - meta_scope: string.quoted.double.sql.php + - meta_content_scope: source.sql.embedded.php + - match: '"' + captures: + 0: punctuation.definition.string.end.php + pop: true + - match: '#(\\"|[^"])*(?="|$\n?)' + scope: comment.line.number-sign.sql + - match: '--(\\"|[^"])*(?="|$\n?)' + scope: comment.line.double-dash.sql + - match: '\\[\\"`'']' + scope: constant.character.escape.php + - match: '''(?=((\\'')|[^''"])*("|$))' + comment: | + Unclosed strings must be captured to avoid them eating the remainder of the PHP script + Sample case: $sql = "SELECT * FROM bar WHERE foo = '" . $variable . "'" + scope: string.quoted.single.unclosed.sql + - match: '`(?=((\\`)|[^`"])*("|$))' + comment: | + Unclosed strings must be captured to avoid them eating the remainder of the PHP script + Sample case: $sql = "SELECT * FROM bar WHERE foo = '" . $variable . "'" + scope: string.quoted.other.backtick.unclosed.sql + - match: "'" + push: + - meta_scope: string.quoted.single.sql + - match: "'" + pop: true + - include: interpolation + - match: "`" + push: + - meta_scope: string.quoted.other.backtick.sql + - match: "`" + pop: true + - include: interpolation + - include: interpolation + - include: scope:source.sql + sql-string-single-quoted: + - match: '''\s*(?=(SELECT|INSERT|UPDATE|DELETE|CREATE|REPLACE|ALTER)\b)' + captures: + 0: punctuation.definition.string.begin.php + push: + - meta_scope: string.quoted.single.sql.php + - meta_content_scope: source.sql.embedded.php + - match: "'" + captures: + 0: punctuation.definition.string.end.php + pop: true + - match: '#(\\''|[^''])*(?=''|$\n?)' + scope: comment.line.number-sign.sql + - match: '--(\\''|[^''])*(?=''|$\n?)' + scope: comment.line.double-dash.sql + - match: '\\[\\''`"]' + scope: constant.character.escape.php + - match: '`(?=((\\`)|[^`''])*(''|$))' + comment: | + Unclosed strings must be captured to avoid them eating the remainder of the PHP script + Sample case: $sql = "SELECT * FROM bar WHERE foo = '" . $variable . "'" + scope: string.quoted.other.backtick.unclosed.sql + - match: '"(?=((\\")|[^"''])*(''|$))' + comment: | + Unclosed strings must be captured to avoid them eating the remainder of the PHP script + Sample case: $sql = "SELECT * FROM bar WHERE foo = '" . $variable . "'" + scope: string.quoted.double.unclosed.sql + - include: scope:source.sql + string-backtick: + - match: "`" + captures: + 0: punctuation.definition.string.begin.php + push: + - meta_scope: string.interpolated.php + - match: "`" + captures: + 0: punctuation.definition.string.end.php + pop: true + - match: \\. + scope: constant.character.escape.php + - include: interpolation + string-double-quoted: + - match: '"' + comment: This contentName is just to allow the usage of “select scope” to select the string contents first, then the string with quotes + captures: + 0: punctuation.definition.string.begin.php + push: + - meta_scope: string.quoted.double.php + - meta_content_scope: meta.string-contents.quoted.double.php + - match: '"' + captures: + 0: punctuation.definition.string.end.php + pop: true + - include: interpolation + string-single-quoted: + - match: "'" + captures: + 0: punctuation.definition.string.begin.php + push: + - meta_scope: string.quoted.single.php + - meta_content_scope: meta.string-contents.quoted.single.php + - match: "'" + captures: + 0: punctuation.definition.string.end.php + pop: true + - match: '\\[\\'']' + scope: constant.character.escape.php + strings: + - include: regex-double-quoted + - include: sql-string-double-quoted + - include: string-double-quoted + - include: regex-single-quoted + - include: sql-string-single-quoted + - include: string-single-quoted + support: + - match: (?i)\bapc_(s(tore|ma_info)|c(ompile_file|lear_cache|a(s|che_info))|inc|de(c|fine_constants|lete(_file)?)|exists|fetch|load_constants|add|bin_(dump(file)?|load(file)?))\b + scope: support.function.apc.php + - match: (?i)\bapcu_(s(tore|ma_info)|c(lear_cache|a(s|che_info))|inc|de(c|lete)|e(ntry|xists)|fetch|add)\b + scope: support.function.apcu.php + - match: (?i)\b(s(huffle|izeof|ort)|n(ext|at(sort|casesort))|c(o(unt|mpact)|urrent)|in_array|u(sort|ksort|asort)|p(os|rev)|e(nd|ach|xtract)|k(sort|ey(_exists)?|rsort)|list|a(sort|r(sort|ray(_(s(hift|um|plice|earch|lice)|c(h(unk|ange_key_case)|o(unt_values|lumn|mbine))|intersect(_(u(key|assoc)|key|assoc))?|diff(_(u(key|assoc)|key|assoc))?|u(n(shift|ique)|intersect(_(uassoc|assoc))?|diff(_(uassoc|assoc))?)|p(op|ush|ad|roduct)|values|key(s|_exists)|f(il(ter|l(_keys)?)|lip)|walk(_recursive)?|r(e(duce|place(_recursive)?|verse)|and)|m(ultisort|erge(_recursive)?|ap)))?))|r(sort|eset|ange))\b + scope: support.function.array.php + - match: (?i)\b(s(how_source|ys_getloadavg|leep)|highlight_(string|file)|con(stant|nection_(status|aborted))|time_(sleep_until|nanosleep)|ignore_user_abort|d(ie|efine(d)?)|u(sleep|n(iqid|pack))|__halt_compiler|p(hp_(strip_whitespace|check_syntax)|ack)|e(val|xit)|get_browser)\b + scope: support.function.basic_functions.php + - match: (?i)\bbc(s(cale|ub|qrt)|comp|div|pow(mod)?|add|m(od|ul))\b + scope: support.function.bcmath.php + - match: (?i)\bblenc_encrypt\b + scope: support.function.blenc.php + - match: (?i)\bMongoDB\\BSON\\(to(JSON|PHP)|from(JSON|PHP))\b + scope: support.function.bson.php + - match: (?i)\bbz(c(ompress|lose)|open|decompress|err(str|no|or)|flush|write|read)\b + scope: support.function.bz2.php + - match: (?i)\b(cal_(to_jd|info|days_in_month|from_jd)|unixtojd|j(d(to(unix|j(ulian|ewish)|french|gregorian)|dayofweek|monthname)|uliantojd|ewishtojd)|easter_da(ys|te)|frenchtojd|gregoriantojd)\b + scope: support.function.calendar.php + - match: (?i)\b(c(lass_(exists|alias)|all_user_method(_array)?)|trait_exists|i(s_(subclass_of|a)|nterface_exists)|__autoload|property_exists|get_(c(lass(_(vars|methods))?|alled_class)|object_vars|declared_(classes|traits|interfaces)|parent_class)|method_exists)\b + scope: support.function.classobj.php + - match: (?i)\b(com_(create_guid|print_typeinfo|event_sink|load_typelib|get_active_object|message_pump)|variant_(s(ub|et(_type)?)|n(ot|eg)|c(a(st|t)|mp)|i(nt|div|mp)|or|d(iv|ate_(to_timestamp|from_timestamp))|pow|eqv|fix|a(nd|dd|bs)|round|get_type|xor|m(od|ul)))\b + scope: support.function.com.php + - match: (?i)\brandom_(int|bytes)\b + scope: support.function.csprng.php + - match: (?i)\bctype_(space|cntrl|digit|upper|p(unct|rint)|lower|al(num|pha)|graph|xdigit)\b + scope: support.function.ctype.php + - match: (?i)\bcurl_(s(hare_(setopt|close|init)|trerror|etopt(_array)?)|c(opy_handle|lose)|init|unescape|pause|e(scape|rr(no|or)|xec)|version|file_create|reset|getinfo|multi_(s(trerror|e(topt|lect))|close|in(it|fo_read)|exec|add_handle|remove_handle|getcontent))\b + scope: support.function.curl.php + - match: (?i)\b(str(totime|ptime|ftime)|checkdate|time(zone_(name_(from_abbr|get)|transitions_get|identifiers_list|o(pen|ffset_get)|version_get|location_get|abbreviations_list))?|idate|date(_(su(n(set|_info|rise)|b)|create(_(immutable(_from_format)?|from_format))?|time(stamp_(set|get)|zone_(set|get)|_set)|i(sodate_set|nterval_(create_from_date_string|format))|offset_get|d(iff|efault_timezone_(set|get)|ate_set)|parse(_from_format)?|format|add|get_last_errors|modify))?|localtime|g(et(timeofday|date)|m(strftime|date|mktime))|m(icrotime|ktime))\b + scope: support.function.datetime.php + - match: (?i)\bdba_(sync|handlers|nextkey|close|insert|op(timize|en)|delete|popen|exists|key_split|f(irstkey|etch)|list|replace)\b + scope: support.function.dba.php + - match: (?i)\bdbx_(sort|c(o(nnect|mpare)|lose)|e(scape_string|rror)|query|fetch_row)\b + scope: support.function.dbx.php + - match: (?i)\b(scandir|c(h(dir|root)|losedir)|opendir|dir|re(winddir|addir)|getcwd)\b + scope: support.function.dir.php + - match: (?i)\beio_(s(y(nc(_file_range|fs)?|mlink)|tat(vfs)?|e(ndfile|t_m(in_parallel|ax_(idle|p(oll_(time|reqs)|arallel)))|ek))|n(threads|op|pending|re(qs|ady))|c(h(own|mod)|ustom|lose|ancel)|truncate|init|open|dup2|u(nlink|time)|poll|event_loop|f(s(ync|tat(vfs)?)|ch(own|mod)|truncate|datasync|utime|allocate)|write|l(stat|ink)|r(e(name|a(d(dir|link|ahead)?|lpath))|mdir)|g(et_(event_stream|last_error)|rp(_(cancel|limit|add))?)|mk(nod|dir)|busy)\b + scope: support.function.eio.php + - match: (?i)\benchant_(dict_(s(tore_replacement|uggest)|check|is_in_session|describe|quick_check|add_to_(session|personal)|get_error)|broker_(set_(ordering|dict_path)|init|d(ict_exists|escribe)|free(_dict)?|list_dicts|request_(dict|pwl_dict)|get_(dict_path|error)))\b + scope: support.function.enchant.php + - match: (?i)\b(s(plit(i)?|ql_regcase)|ereg(i(_replace)?|_replace)?)\b + scope: support.function.ereg.php + - match: (?i)\b(set_e(rror_handler|xception_handler)|trigger_error|debug_(print_backtrace|backtrace)|user_error|error_(clear_last|log|reporting|get_last)|restore_e(rror_handler|xception_handler))\b + scope: support.function.errorfunc.php + - match: (?i)\b(s(hell_exec|ystem)|p(assthru|roc_(nice|close|terminate|open|get_status))|e(scapeshell(cmd|arg)|xec))\b + scope: support.function.exec.php + - match: (?i)\b(exif_(t(humbnail|agname)|imagetype|read_data)|read_exif_data)\b + scope: support.function.exif.php + - match: (?i)\bfann_(s(huffle_train_data|cale_(train(_data)?|input(_train_data)?|output(_train_data)?)|ubset_train_data|et_(s(caling_params|arprop_(step_error_(shift|threshold_factor)|temperature|weight_decay_shift))|ca(scade_(num_candidate_groups|candidate_(stagnation_epochs|change_fraction|limit)|output_(stagnation_epochs|change_fraction)|weight_multiplier|activation_(steepnesses|functions)|m(in_(cand_epochs|out_epochs)|ax_(cand_epochs|out_epochs)))|llback)|train(ing_algorithm|_(stop_function|error_function))|input_scaling_params|output_scaling_params|error_log|quickprop_(decay|mu)|weight(_array)?|learning_(rate|momentum)|activation_(steepness(_(hidden|output|layer))?|function(_(hidden|output|layer))?)|rprop_(increase_factor|de(crease_factor|lta_(zero|m(in|ax))))|bit_fail_limit)|ave(_train)?)|num_(input_train_data|output_train_data)|c(opy|lear_scaling_params|ascadetrain_on_(data|file)|reate_(s(hortcut(_array)?|tandard(_array)?|parse(_array)?)|train(_from_callback)?|from_file))|t(est(_data)?|rain(_(on_(data|file)|epoch))?)|init_weights|d(uplicate_train_data|es(cale_(train|input|output)|troy(_train)?))|print_error|length_train_data|r(un|e(set_(MSE|err(str|no))|ad_train_from_file)|andomize_weights)|get_(sarprop_(step_error_(shift|threshold_factor)|temperature|weight_decay_shift)|n(um_(input|output|layers)|etwork_type)|MSE|c(onnection_(array|rate)|ascade_(num_candidate(s|_groups)|candidate_(stagnation_epochs|change_fraction|limit)|output_(stagnation_epochs|change_fraction)|weight_multiplier|activation_(steepnesses(_count)?|functions(_count)?)|m(in_(cand_epochs|out_epochs)|ax_(cand_epochs|out_epochs))))|t(otal_(neurons|connections)|rain(ing_algorithm|_(stop_function|error_function)))|err(str|no)|quickprop_(decay|mu)|l(earning_(rate|momentum)|ayer_array)|activation_(steepness|function)|rprop_(increase_factor|de(crease_factor|lta_(zero|m(in|ax))))|bi(t_fail(_limit)?|as_array))|merge_train_data)\b + scope: support.function.fann.php + - match: (?i)\b(s(ymlink|tat|et_file_buffer)|c(h(own|grp|mod)|opy|learstatcache)|t(ouch|empnam|mpfile)|is_(dir|uploaded_file|executable|file|writ(eable|able)|link|readable)|d(i(sk(_(total_space|free_space)|freespace)|rname)|elete)|u(nlink|mask)|p(close|open|a(thinfo|rse_ini_(string|file)))|f(s(canf|tat|eek)|nmatch|close|t(ell|runcate)|ile(size|ctime|type|inode|owner|_(put_contents|exists|get_contents)|perms|atime|group|mtime)?|open|p(ut(s|csv)|assthru)|eof|flush|write|lock|read|get(s(s)?|c(sv)?))|l(stat|ch(own|grp)|ink(info)?)|r(e(name|wind|a(d(file|link)|lpath(_cache_(size|get))?))|mdir)|glob|m(ove_uploaded_file|kdir)|basename)\b + scope: support.function.file.php + - match: (?i)\b(finfo_(set_flags|close|open|file|buffer)|mime_content_type)\b + scope: support.function.fileinfo.php + - match: (?i)\bfilter_(has_var|i(nput(_array)?|d)|var(_array)?|list)\b + scope: support.function.filter.php + - match: (?i)\bfastcgi_finish_request\b + scope: support.function.fpm.php + - match: (?i)\b(c(all_user_func(_array)?|reate_function)|unregister_tick_function|f(orward_static_call(_array)?|unc(tion_exists|_(num_args|get_arg(s)?)))|register_(shutdown_function|tick_function)|get_defined_functions)\b + scope: support.function.funchand.php + - match: (?i)\b(ngettext|textdomain|d(ngettext|c(ngettext|gettext)|gettext)|gettext|bind(textdomain|_textdomain_codeset))\b + scope: support.function.gettext.php + - match: (?i)\bgmp_(s(can(1|0)|trval|ign|ub|etbit|qrt(rem)?)|hamdist|ne(g|xtprime)|c(om|lrbit|mp)|testbit|i(n(tval|it|vert)|mport)|or|div(_(q(r)?|r)|exact)?|jacobi|p(o(pcount|w(m)?)|erfect_square|rob_prime)|export|fact|legendre|a(nd|dd|bs)|r(oot(rem)?|andom(_(seed|range|bits))?)|gcd(ext)?|xor|m(od|ul))\b + scope: support.function.gmp.php + - match: (?i)\bhash(_(h(kdf|mac(_file)?)|copy|init|update(_(stream|file))?|pbkdf2|equals|fi(nal|le)|algos))?\b + scope: support.function.hash.php + - match: (?i)\b(iconv(_(s(tr(pos|len|rpos)|ubstr|et_encoding)|get_encoding|mime_(decode(_headers)?|encode)))?|ob_iconv_handler)\b + scope: support.function.iconv.php + - match: (?i)\biis_(s(t(op_serv(ice|er)|art_serv(ice|er))|et_(s(cript_map|erver_rights)|dir_security|app_settings))|add_server|remove_server|get_(s(cript_map|erv(ice_state|er_(rights|by_(comment|path))))|dir_security))\b + scope: support.function.iisfunc.php + - match: (?i)\b(i(ptc(parse|embed)|mage(s(y|cale|tring(up)?|et(style|clip|t(hickness|ile)|interpolation|pixel|brush)|avealpha|x)|c(har(up)?|o(nvolution|py(res(ized|ampled)|merge(gray)?)?|lor(s(total|et|forindex)|closest(hwb|alpha)?|transparent|deallocate|exact(alpha)?|a(t|llocate(alpha)?)|resolve(alpha)?|match))|r(op(auto)?|eate(truecolor|from(string|jpeg|png|w(ebp|bmp)|g(if|d(2(part)?)?)|x(pm|bm)|bmp))?))|t(ypes|tf(text|bbox)|ruecolortopalette)|i(struecolor|nterlace)|2wbmp|openpolygon|d(estroy|ashedline)|jpeg|_type_to_(extension|mime_type)|p(s(slantfont|text|e(ncodefont|xtendfont)|freefont|loadfont|bbox)|ng|olygon|alette(copy|totruecolor))|ellipse|f(t(text|bbox)|il(ter|l(toborder|ed(polygon|ellipse|arc|rectangle))?)|ont(height|width)|lip)|w(ebp|bmp)|l(ine|oadfont|ayereffect)|a(ntialias|ffine(matrix(concat|get))?|lphablending|rc)|r(otate|e(solution|ctangle))|g(if|d(2)?|etclip|ammacorrect|rab(screen|window))|xbm|bmp))|jpeg2wbmp|png2wbmp|g(d_info|etimagesize(fromstring)?))\b + scope: support.function.image.php + - match: (?i)\b(s(ys_get_temp_dir|et_(time_limit|include_path|magic_quotes_runtime))|cli_(set_process_title|get_process_title)|ini_(set|alter|restore|get(_all)?)|zend_(thread_id|version|logo_guid)|dl|p(hp(credits|info|_(sapi_name|ini_(scanned_files|loaded_file)|uname|logo_guid)|version)|utenv)|extension_loaded|version_compare|assert(_options)?|restore_include_path|g(c_(collect_cycles|disable|enable(d)?|mem_caches)|et(opt|_(c(urrent_user|fg_var)|include(d_files|_path)|defined_constants|extension_funcs|loaded_extensions|re(sources|quired_files)|magic_quotes_(runtime|gpc))|env|lastmod|rusage|my(inode|uid|pid|gid)))|m(emory_get_(usage|peak_usage)|a(in|gic_quotes_runtime)))\b + scope: support.function.info.php + - match: (?i)\bibase_(se(t_event_handler|rv(ice_(detach|attach)|er_info))|n(um_(params|fields)|ame_result)|c(o(nnect|mmit(_ret)?)|lose)|trans|d(elete_user|rop_db|b_info)|p(connect|aram_info|repare)|e(rr(code|msg)|xecute)|query|f(ield_info|etch_(object|assoc|row)|ree_(event_handler|query|result))|wait_event|a(dd_user|ffected_rows)|r(ollback(_ret)?|estore)|gen_id|m(odify_user|aintain_db)|b(lob_(c(lose|ancel|reate)|i(nfo|mport)|open|echo|add|get)|ackup))\b + scope: support.function.interbase.php + - match: (?i)\b(n(ormalizer_(normalize|is_normalized)|umfmt_(set_(symbol|text_attribute|pattern|attribute)|create|parse(_currency)?|format(_currency)?|get_(symbol|text_attribute|pattern|error_(code|message)|locale|attribute)))|collator_(s(ort(_with_sort_keys)?|et_(strength|attribute))|c(ompare|reate)|asort|get_(s(trength|ort_key)|error_(code|message)|locale|attribute))|transliterator_(create(_(inverse|from_rules))?|transliterate|list_ids|get_error_(code|message))|i(ntl(cal_get_error_(code|message)|tz_get_error_(code|message)|_(is_failure|error_name|get_error_(code|message)))|dn_to_(utf8|ascii))|datefmt_(set_(calendar|timezone(_id)?|pattern|lenient)|create|is_lenient|parse|format(_object)?|localtime|get_(calendar(_object)?|time(type|zone(_id)?)|datetype|pattern|error_(code|message)|locale))|locale_(set_default|c(ompose|anonicalize)|parse|filter_matches|lookup|accept_from_http|get_(script|d(isplay_(script|name|variant|language|region)|efault)|primary_language|keywords|all_variants|region))|resourcebundle_(c(ount|reate)|locales|get(_error_(code|message))?)|grapheme_(s(tr(str|i(str|pos)|pos|len|r(ipos|pos))|ubstr)|extract)|msgfmt_(set_pattern|create|parse(_message)?|format(_message)?|get_(pattern|error_(code|message)|locale)))\b + scope: support.function.intl.php + - match: (?i)\bjson_(decode|encode|last_error(_msg)?)\b + scope: support.function.json.php + - match: (?i)\bldap_(s(tart_tls|ort|e(t_(option|rebind_proc)|arch)|asl_bind)|next_(entry|attribute|reference)|c(o(n(nect|trol_paged_result(_response)?)|unt_entries|mpare)|lose)|t61_to_8859|d(n2ufn|elete)|8859_to_t61|unbind|parse_re(sult|ference)|e(scape|rr(no|2str|or)|xplode_dn)|f(irst_(entry|attribute|reference)|ree_result)|list|add|re(name|ad)|get_(option|dn|entries|values(_len)?|attributes)|mod(ify(_batch)?|_(del|add|replace))|bind)\b + scope: support.function.ldap.php + - match: (?i)\blibxml_(set_(streams_context|external_entity_loader)|clear_errors|disable_entity_loader|use_internal_errors|get_(errors|last_error))\b + scope: support.function.libxml.php + - match: (?i)\b(ezmlm_hash|mail)\b + scope: support.function.mail.php + - match: (?i)\b(s(in(h)?|qrt|rand)|h(ypot|exdec)|c(os(h)?|eil)|tan(h)?|i(s_(nan|infinite|finite)|ntdiv)|octdec|de(c(hex|oct|bin)|g2rad)|p(i|ow)|exp(m1)?|f(loor|mod)|l(cg_value|og(1(p|0))?)|a(sin(h)?|cos(h)?|tan(h|2)?|bs)|r(ound|a(nd|d2deg))|getrandmax|m(t_(srand|rand|getrandmax)|in|ax)|b(indec|ase_convert))\b + scope: support.function.math.php + - match: (?i)\bmb_(s(tr(str|cut|to(upper|lower)|i(str|pos|mwidth)|pos|width|len|r(chr|i(chr|pos)|pos))|ubst(itute_character|r(_count)?)|plit|end_mail)|http_(input|output)|c(heck_encoding|onvert_(case|encoding|variables|kana))|internal_encoding|output_handler|de(code_(numericentity|mimeheader)|tect_(order|encoding))|p(arse_str|referred_mime_name)|e(ncod(ing_aliases|e_(numericentity|mimeheader))|reg(i(_replace)?|_(search(_(setpos|init|pos|regs|get(pos|regs)))?|replace(_callback)?|match))?)|l(ist_encodings|anguage)|regex_(set_options|encoding)|get_info)\b + scope: support.function.mbstring.php + - match: (?i)\bm(crypt_(c(fb|reate_iv|bc)|ofb|decrypt|e(nc(_(self_test|is_block_(algorithm(_mode)?|mode)|get_(supported_key_sizes|iv_size|key_size|algorithms_name|modes_name|block_size))|rypt)|cb)|list_(algorithms|modes)|ge(neric(_(init|deinit|end))?|t_(cipher_name|iv_size|key_size|block_size))|module_(self_test|close|is_block_(algorithm(_mode)?|mode)|open|get_(supported_key_sizes|algo_(key_size|block_size))))|decrypt_generic)\b + scope: support.function.mcrypt.php + - match: (?i)\bmemcache_debug\b + scope: support.function.memcache.php + - match: (?i)\bmhash(_(count|keygen_s2k|get_(hash_name|block_size)))?\b + scope: support.function.mhash.php + - match: (?i)\b(log_(cmd_(insert|delete|update)|killcursor|write_batch|reply|getmore)|bson_(decode|encode))\b + scope: support.function.mongo.php + - match: (?i)\bmysql_(s(tat|e(t_charset|lect_db))|num_(fields|rows)|c(onnect|l(ient_encoding|ose)|reate_db)|t(hread_id|ablename)|in(sert_id|fo)|d(ata_seek|rop_db|b_(name|query))|unbuffered_query|p(connect|ing)|e(scape_string|rr(no|or))|query|f(ield_(seek|name|t(ype|able)|flags|len)|etch_(object|field|lengths|a(ssoc|rray)|row)|ree_result)|list_(tables|dbs|processes|fields)|affected_rows|re(sult|al_escape_string)|get_(server_info|host_info|client_info|proto_info))\b + scope: support.function.mysql.php + - match: (?i)\bmysqli_(s(sl_set|t(ore_result|at|mt_(s(tore_result|end_long_data)|next_result|close|init|data_seek|prepare|execute|f(etch|ree_result)|attr_(set|get)|res(ult_metadata|et)|get_(warnings|result)|more_results|bind_(param|result)))|e(nd_(query|long_data)|t_(charset|opt|local_infile_(handler|default))|lect_db)|lave_query|avepoint)|next_result|c(ha(nge_user|racter_set_name)|o(nnect|mmit)|l(ient_encoding|ose))|thread_safe|init|options|d(isable_r(pl_parse|eads_from_master)|ump_debug_info|ebug|ata_seek)|use_result|p(ing|oll|aram_count|repare)|e(scape_string|nable_r(pl_parse|eads_from_master)|xecute|mbedded_server_(start|end))|kill|query|f(ield_seek|etch(_(object|field(s|_direct)?|a(ssoc|ll|rray)|row))?|ree_result)|autocommit|r(ollback|pl_(p(arse_enabled|robe)|query_type)|e(port|fresh|lease_savepoint|a(p_async_query|l_(connect|escape_string|query))))|get_(c(harset|onnection_stats|lient_(stats|info|version)|ache_stats)|warnings|links_stats|metadata)|m(ore_results|ulti_query|aster_query)|b(ind_(param|result)|egin_transaction))\b + scope: support.function.mysqli.php + - match: (?i)\bmysqlnd_memcache_(set|get_config)\b + scope: support.function.mysqlnd-memcache.php + - match: (?i)\bmysqlnd_ms_(set_(user_pick_server|qos)|dump_servers|query_is_select|fabric_select_(shard|global)|get_(stats|last_(used_connection|gtid))|xa_(commit|rollback|gc|begin)|match_wild)\b + scope: support.function.mysqlnd-ms.php + - match: (?i)\bmysqlnd_qc_(set_(storage_handler|cache_condition|is_select|user_handlers)|clear_cache|get_(normalized_query_trace_log|c(ore_stats|ache_info)|query_trace_log|available_handlers))\b + scope: support.function.mysqlnd-qc.php + - match: (?i)\bmysqlnd_uh_(set_(statement_proxy|connection_proxy)|convert_to_mysqlnd)\b + scope: support.function.mysqlnd-uh.php + - match: (?i)\b(s(yslog|ocket_(set_(timeout|blocking)|get_status)|et(cookie|rawcookie))|h(ttp_response_code|eader(s_(sent|list)|_re(gister_callback|move))?)|c(heckdnsrr|loselog)|i(net_(ntop|pton)|p2long)|openlog|d(ns_(check_record|get_(record|mx))|efine_syslog_variables)|pfsockopen|fsockopen|long2ip|get(servby(name|port)|host(name|by(name(l)?|addr))|protobyn(umber|ame)|mxrr))\b + scope: support.function.network.php + - match: (?i)\bnsapi_(virtual|re(sponse_headers|quest_headers))\b + scope: support.function.nsapi.php + - match: (?i)\boci(s(tatementtype|e(tprefetch|rverversion)|avelob(file)?)|n(umcols|ew(c(ollection|ursor)|descriptor)|logon)|c(o(l(umn(s(cale|ize)|name|type(raw)?|isnull|precision)|l(size|trim|a(ssign(elem)?|ppend)|getelem|max))|mmit)|loselob|ancel)|internaldebug|definebyname|_(s(tatement_type|e(t_(client_i(nfo|dentifier)|prefetch|edition|action|module_name)|rver_version))|n(um_(fields|rows)|ew_(c(o(nnect|llection)|ursor)|descriptor))|c(o(nnect|mmit)|l(ient_version|ose)|ancel)|internal_debug|d(isable_taf_callback|efine_by_name)|p(connect|a(ssword_change|rse))|e(rror|xecute)|f(ield_(s(cale|ize)|name|type(_raw)?|is_null|precision)|etch(_(object|a(ssoc|ll|rray)|row))?|ree_(statement|descriptor))|lob_(copy|is_equal)|r(ollback|e(sult|gister_taf_callback))|get_implicit_resultset|bind_(array_by_name|by_name))|p(logon|arse)|e(rror|xecute)|f(etch(statement|into)?|ree(statement|c(ollection|ursor)|desc))|write(temporarylob|lobtofile)|lo(adlob|go(n|ff))|r(o(wcount|llback)|esult)|bindbyname)\b + scope: support.function.oci8.php + - match: (?i)\bopcache_(compile_file|i(s_script_cached|nvalidate)|reset|get_(status|configuration))\b + scope: support.function.opcache.php + - match: (?i)\bopenssl_(s(ign|pki_(new|export(_challenge)?|verify)|eal)|c(sr_(sign|new|export(_to_file)?|get_(subject|public_key))|ipher_iv_length)|open|d(h_compute_key|igest|ecrypt)|p(ublic_(decrypt|encrypt)|k(cs(12_(export(_to_file)?|read)|7_(sign|decrypt|encrypt|verify))|ey_(new|export(_to_file)?|free|get_(details|p(ublic|rivate))))|rivate_(decrypt|encrypt)|bkdf2)|e(ncrypt|rror_string)|verify|free_key|random_pseudo_bytes|get_(c(ipher_methods|ert_locations)|p(ublickey|rivatekey)|md_methods)|x509_(check(_private_key|purpose)|parse|export(_to_file)?|f(ingerprint|ree)|read))\b + scope: support.function.openssl.php + - match: (?i)\b(o(utput_(add_rewrite_var|reset_rewrite_vars)|b_(start|clean|implicit_flush|end_(clean|flush)|flush|list_handlers|g(zhandler|et_(status|c(ontents|lean)|flush|le(ngth|vel)))))|flush)\b + scope: support.function.output.php + - match: (?i)\bpassword_(hash|needs_rehash|verify|get_info)\b + scope: support.function.password.php + - match: (?i)\bpcntl_(s(trerror|ig(nal(_(dispatch|get_handler))?|timedwait|procmask|waitinfo)|etpriority)|e(rrno|xec)|fork|w(stopsig|termsig|if(s(topped|ignaled)|exited)|exitstatus|ait(pid)?)|alarm|get(_last_error|priority))\b + scope: support.function.pcntl.php + - match: (?i)\bpg_(s(ocket|e(nd_(prepare|execute|query(_params)?)|t_(client_encoding|error_verbosity)|lect))|host|num_(fields|rows)|c(o(n(sume_input|nect(ion_(status|reset|busy)|_poll)?|vert)|py_(to|from))|l(ient_encoding|ose)|ancel_query)|t(ty|ra(nsaction_status|ce))|insert|options|d(elete|bname)|u(n(trace|escape_bytea)|pdate)|p(connect|ing|ort|ut_line|arameter_status|repare)|e(scape_(string|identifier|literal|bytea)|nd_copy|xecute)|version|query(_params)?|f(ield_(size|n(um|ame)|t(ype(_oid)?|able)|is_null|prtlen)|etch_(object|a(ssoc|ll(_columns)?|rray)|r(ow|esult))|lush|ree_result)|l(o_(seek|c(lose|reate)|t(ell|runcate)|import|open|unlink|export|write|read(_all)?)|ast_(notice|oid|error))|affected_rows|result_(s(tatus|eek)|error(_field)?)|get_(notify|pid|result)|meta_data)\b + scope: support.function.pgsql.php + - match: (?i)\b(virtual|apache_(setenv|note|child_terminate|lookup_uri|re(s(ponse_headers|et_timeout)|quest_headers)|get(_(version|modules)|env))|getallheaders)\b + scope: support.function.php_apache.php + - match: (?i)\bdom_import_simplexml\b + scope: support.function.php_dom.php + - match: (?i)\bftp_(s(sl_connect|ystype|i(te|ze)|et_option)|n(list|b_(continue|put|f(put|get)|get))|c(h(dir|mod)|onnect|dup|lose)|delete|p(ut|wd|asv)|exec|quit|f(put|get)|login|alloc|r(ename|aw(list)?|mdir)|get(_option)?|m(dtm|kdir))\b + scope: support.function.php_ftp.php + - match: (?i)\bimap_(s(can(mailbox)?|tatus|ort|ubscribe|e(t(_quota|flag_full|acl)|arch)|avebody)|header(s|info)?|num_(recent|msg)|c(heck|l(ose|earflag_full)|reate(mailbox)?)|t(hread|imeout)|open|delete(mailbox)?|8bit|u(n(subscribe|delete)|tf(7_(decode|encode)|8)|id)|ping|e(rrors|xpunge)|qprint|fetch(structure|header|text|_overview|mime|body)|l(sub|ist(s(can|ubscribed)|mailbox)?|ast_error)|a(ppend|lerts)|r(e(name(mailbox)?|open)|fc822_(parse_(headers|adrlist)|write_address))|g(c|et(subscribed|_quota(root)?|acl|mailboxes))|m(sgno|ime_header_decode|ail(_(co(py|mpose)|move)|boxmsginfo)?)|b(inary|ody(struct)?|ase64))\b + scope: support.function.php_imap.php + - match: (?i)\bmssql_(select_db|n(um_(fields|rows)|ext_result)|c(onnect|lose)|init|data_seek|pconnect|execute|query|f(ield_(seek|name|type|length)|etch_(object|field|a(ssoc|rray)|row|batch)|ree_(statement|result))|r(ows_affected|esult)|g(uid_string|et_last_message)|min_(error_severity|message_severity)|bind)\b + scope: support.function.php_mssql.php + - match: (?i)\bodbc_(s(tatistics|pecialcolumns|etoption)|n(um_(fields|rows)|ext_result)|c(o(nnect|lumn(s|privileges)|mmit)|ursor|lose(_all)?)|table(s|privileges)|d(o|ata_source)|p(connect|r(imarykeys|ocedure(s|columns)|epare))|e(rror(msg)?|xec(ute)?)|f(ield_(scale|n(um|ame)|type|precision|len)|oreignkeys|etch_(into|object|array|row)|ree_result)|longreadlen|autocommit|r(ollback|esult(_all)?)|gettypeinfo|binmode)\b + scope: support.function.php_odbc.php + - match: (?i)\bpreg_(split|quote|filter|last_error|replace(_callback(_array)?)?|grep|match(_all)?)\b + scope: support.function.php_pcre.php + - match: (?i)\b(spl_(classes|object_hash|autoload(_(call|unregister|extensions|functions|register))?)|class_(implements|uses|parents)|iterator_(count|to_array|apply))\b + scope: support.function.php_spl.php + - match: (?i)\bzip_(close|open|entry_(name|c(ompress(ionmethod|edsize)|lose)|open|filesize|read)|read)\b + scope: support.function.php_zip.php + - match: (?i)\bposix_(s(trerror|et(sid|uid|pgid|e(uid|gid)|rlimit|gid))|ctermid|t(tyname|imes)|i(satty|nitgroups)|uname|errno|kill|access|get(sid|cwd|uid|_last_error|p(id|pid|w(nam|uid)|g(id|rp))|e(uid|gid)|login|rlimit|g(id|r(nam|oups|gid)))|mk(nod|fifo))\b + scope: support.function.posix.php + - match: (?i)\bset(threadtitle|proctitle)\b + scope: support.function.proctitle.php + - match: (?i)\bpspell_(s(tore_replacement|uggest|ave_wordlist)|new(_(config|personal))?|c(heck|onfig_(save_repl|create|ignore|d(ict_dir|ata_dir)|personal|r(untogether|epl)|mode)|lear_session)|add_to_(session|personal))\b + scope: support.function.pspell.php + - match: (?i)\breadline(_(c(ompletion_function|lear_history|allback_(handler_(install|remove)|read_char))|info|on_new_line|write_history|list_history|add_history|re(display|ad_history)))?\b + scope: support.function.readline.php + - match: (?i)\brecode(_(string|file))?\b + scope: support.function.recode.php + - match: (?i)\brrd(c_disconnect|_(create|tune|info|update|error|version|f(irst|etch)|last(update)?|restore|graph|xport))\b + scope: support.function.rrd.php + - match: (?i)\b(s(hm_(has_var|detach|put_var|attach|remove(_var)?|get_var)|em_(acquire|re(lease|move)|get))|ftok|msg_(s(tat_queue|e(nd|t_queue))|queue_exists|re(ceive|move_queue)|get_queue))\b + scope: support.function.sem.php + - match: (?i)\bsession_(s(ta(tus|rt)|et_(save_handler|cookie_params)|ave_path)|name|c(ommit|ache_(expire|limiter)|reate_id)|i(s_registered|d)|de(stroy|code)|un(set|register)|encode|write_close|abort|re(set|g(ister(_shutdown)?|enerate_id))|g(c|et_cookie_params)|module_name)\b + scope: support.function.session.php + - match: (?i)\bshmop_(size|close|open|delete|write|read)\b + scope: support.function.shmop.php + - match: (?i)\bsimplexml_(import_dom|load_(string|file))\b + scope: support.function.simplexml.php + - match: (?i)\bsnmp(set|2_(set|walk|real_walk|get(next)?)|_(set_(oid_(numeric_print|output_format)|enum_print|valueretrieval|quick_print)|read_mib|get_(valueretrieval|quick_print))|3_(set|walk|real_walk|get(next)?)|walk(oid)?|realwalk|get(next)?)\b + scope: support.function.snmp.php + - match: (?i)\b(is_soap_fault|use_soap_error_handler)\b + scope: support.function.soap.php + - match: (?i)\bsocket_(s(hutdown|trerror|e(nd(to|msg)?|t(opt|_(nonblock|option|block))|lect))|c(onnect|l(ose|ear_error)|reate(_(pair|listen))?|msg_space)|import_stream|write|l(isten|ast_error)|accept|re(cv(from|msg)?|ad)|get(sockname|opt|_option|peername)|bind)\b + scope: support.function.sockets.php + - match: (?i)\bsqlite_(s(ingle_query|eek)|has_(prev|more)|n(um_(fields|rows)|ext)|c(hanges|olumn|urrent|lose|reate_(function|aggregate))|open|u(nbuffered_query|df_(decode_binary|encode_binary))|p(open|rev)|e(scape_string|rror_string|xec)|valid|key|query|f(ield_name|etch_(s(tring|ingle)|column_types|object|a(ll|rray))|actory)|l(ib(encoding|version)|ast_(insert_rowid|error))|array_query|rewind|busy_timeout)\b + scope: support.function.sqlite.php + - match: (?i)\bsqlsrv_(se(nd_stream_data|rver_info)|has_rows|n(um_(fields|rows)|ext_result)|c(o(n(nect|figure)|mmit)|l(ient_info|ose)|ancel)|prepare|e(rrors|xecute)|query|f(ield_metadata|etch(_(object|array))?|ree_stmt)|ro(ws_affected|llback)|get_(config|field)|begin_transaction)\b + scope: support.function.sqlsrv.php + - match: (?i)\bstats_(s(ta(ndard_deviation|t_(noncentral_t|correlation|in(nerproduct|dependent_t)|p(owersum|ercentile|aired_t)|gennch|binomial_coef))|kew)|harmonic_mean|c(ovariance|df_(n(oncentral_(chisquare|f)|egative_binomial)|c(hisquare|auchy)|t|uniform|poisson|exponential|f|weibull|l(ogistic|aplace)|gamma|b(inomial|eta)))|den(s_(n(ormal|egative_binomial)|c(hisquare|auchy)|t|pmf_(hypergeometric|poisson|binomial)|exponential|f|weibull|l(ogistic|aplace)|gamma|beta)|_uniform)|variance|kurtosis|absolute_deviation|rand_(setall|phrase_to_seeds|ranf|ge(n_(no(ncen(tral_(t|f)|ral_chisquare)|rmal)|chisquare|t|i(nt|uniform|poisson|binomial(_negative)?)|exponential|f(uniform)?|gamma|beta)|t_seeds)))\b + scope: support.function.stats.php + - match: (?i)\bs(tream_(s(ocket_(s(hutdown|e(ndto|rver))|client|pair|enable_crypto|accept|recvfrom|get_name)|upports_lock|e(t_(chunk_size|timeout|write_buffer|read_buffer|blocking)|lect))|notification_callback|co(ntext_(set_(option|default|params)|create|get_(options|default|params))|py_to_stream)|is_local|encoding|filter_(prepend|append|re(gister|move))|wrapper_(unregister|re(store|gister))|re(solve_include_path|gister_wrapper)|get_(contents|transports|filters|wrappers|line|meta_data)|bucket_(new|prepend|append|make_writeable))|et_socket_blocking)\b + scope: support.function.streamsfuncs.php + - match: (?i)\b(s(scanf|ha1(_file)?|tr(s(tr|pn)|n(c(asecmp|mp)|atc(asecmp|mp))|c(spn|hr|oll|asecmp|mp)|t(o(upper|k|lower)|r)|i(str|p(slashes|cslashes|os|_tags))|_(s(huffle|plit)|ireplace|pad|word_count|r(ot13|ep(eat|lace))|getcsv)|p(os|brk)|len|r(chr|ipos|pos|ev))|imilar_text|oundex|ubstr(_(co(unt|mpare)|replace))?|printf|etlocale)|h(tml(specialchars(_decode)?|_entity_decode|entities)|e(x2bin|brev(c)?))|n(umber_format|l(2br|_langinfo))|c(h(op|unk_split|r)|o(nvert_(cyr_string|uu(decode|encode))|unt_chars)|r(ypt|c32))|trim|implode|ord|uc(first|words)|join|p(arse_str|rint(f)?)|e(cho|xplode)|v(sprintf|printf|fprintf)|quote(d_printable_(decode|encode)|meta)|fprintf|wordwrap|l(cfirst|trim|ocaleconv|evenshtein)|add(slashes|cslashes)|rtrim|get_html_translation_table|m(oney_format|d5(_file)?|etaphone)|bin2hex)\b + scope: support.function.string.php + - match: (?i)\bsybase_(se(t_message_handler|lect_db)|num_(fields|rows)|c(onnect|lose)|d(eadlock_retry_count|ata_seek)|unbuffered_query|pconnect|query|f(ield_seek|etch_(object|field|a(ssoc|rray)|row)|ree_result)|affected_rows|result|get_last_message|min_(server_severity|client_severity|error_severity|message_severity))\b + scope: support.function.sybase.php + - match: (?i)\b(taint|is_tainted|untaint)\b + scope: support.function.taint.php + - match: (?i)\b(tidy_(s(et(opt|_encoding)|ave_config)|c(onfig_count|lean_repair)|is_x(html|ml)|diagnose|parse_(string|file)|error_count|warning_count|load_config|access_count|re(set_config|pair_(string|file))|get(opt|_(status|h(tml(_ver)?|ead)|config|o(utput|pt_doc)|r(oot|elease)|body)))|ob_tidyhandler)\b + scope: support.function.tidy.php + - match: (?i)\btoken_(name|get_all)\b + scope: support.function.tokenizer.php + - match: (?i)\btrader_(s(t(och(f|rsi)?|ddev)|in(h)?|u(m|b)|et_(compat|unstable_period)|qrt|ar(ext)?|ma)|ht_(sine|trend(line|mode)|dcp(hase|eriod)|phasor)|natr|c(ci|o(s(h)?|rrel)|dl(s(ho(otingstar|rtline)|t(icksandwich|alledpattern)|pinningtop|eparatinglines)|h(i(kkake(mod)?|ghwave)|omingpigeon|a(ngingman|rami(cross)?|mmer))|c(o(ncealbabyswall|unterattack)|losingmarubozu)|t(hrusting|a(sukigap|kuri)|ristar)|i(n(neck|vertedhammer)|dentical3crows)|2crows|onneck|d(oji(star)?|arkcloudcover|ragonflydoji)|u(nique3river|psidegap2crows)|3(starsinsouth|inside|outside|whitesoldiers|linestrike|blackcrows)|piercing|e(ngulfing|vening(star|dojistar))|kicking(bylength)?|l(ongl(ine|eggeddoji)|adderbottom)|a(dvanceblock|bandonedbaby)|ri(sefall3methods|ckshawman)|g(apsidesidewhite|ravestonedoji)|xsidegap3methods|m(orning(star|dojistar)|a(t(hold|chinglow)|rubozu))|b(elthold|reakaway))|eil|mo)|t(sf|ypprice|3|ema|an(h)?|r(i(x|ma)|ange))|obv|d(iv|ema|x)|ultosc|p(po|lus_d(i|m))|e(rrno|xp|ma)|var|kama|floor|w(clprice|illr|ma)|l(n|inearreg(_(slope|intercept|angle))?|og10)|a(sin|cos|t(an|r)|d(osc|d|x(r)?)?|po|vgprice|roon(osc)?)|r(si|oc(p|r(100)?)?)|get_(compat|unstable_period)|m(i(n(index|us_d(i|m)|max(index)?)?|dp(oint|rice))|om|ult|edprice|fi|a(cd(ext|fix)?|vp|x(index)?|ma)?)|b(op|eta|bands))\b + scope: support.function.trader.php + - match: (?i)\bUI\\(Draw\\Text\\Font\\fontFamilies|quit|run)\b + scope: support.function.ui.php + - match: (?i)\buopz_(co(py|mpose)|implement|overload|delete|undefine|extend|f(unction|lags)|re(store|name|define)|backup)\b + scope: support.function.uopz.php + - match: (?i)\b(http_build_query|url(decode|encode)|parse_url|rawurl(decode|encode)|get_(headers|meta_tags)|base64_(decode|encode))\b + scope: support.function.url.php + - match: (?i)\b(s(trval|e(ttype|rialize))|i(s(set|_(s(calar|tring)|nu(ll|meric)|callable|i(nt(eger)?|terable)|object|double|float|long|array|re(source|al)|bool))|ntval|mport_request_variables)|d(oubleval|ebug_zval_dump)|unse(t|rialize)|print_r|empty|var_(dump|export)|floatval|get(type|_(defined_vars|resource_type))|boolval)\b + scope: support.function.var.php + - match: (?i)\bwddx_(serialize_va(lue|rs)|deserialize|packet_(start|end)|add_vars)\b + scope: support.function.wddx.php + - match: (?i)\bxhprof_(sample_(disable|enable)|disable|enable)\b + scope: support.function.xhprof.php + - match: (?i)\b(utf8_(decode|encode)|xml_(set_(start_namespace_decl_handler|notation_decl_handler|character_data_handler|object|default_handler|unparsed_entity_decl_handler|processing_instruction_handler|e(nd_namespace_decl_handler|lement_handler|xternal_entity_ref_handler))|parse(_into_struct|r_(set_option|create(_ns)?|free|get_option))?|error_string|get_(current_(column_number|line_number|byte_index)|error_code)))\b + scope: support.function.xml.php + - match: (?i)\bxmlrpc_(se(t_type|rver_(c(all_method|reate)|destroy|add_introspection_data|register_(introspection_callback|method)))|is_fault|decode(_request)?|parse_method_descriptions|encode(_request)?|get_type)\b + scope: support.function.xmlrpc.php + - match: (?i)\bxmlwriter_(s(tart_(c(omment|data)|d(td(_(e(ntity|lement)|attlist))?|ocument)|pi|element(_ns)?|attribute(_ns)?)|et_indent(_string)?)|text|o(utput_memory|pen_(uri|memory))|end_(c(omment|data)|d(td(_(e(ntity|lement)|attlist))?|ocument)|pi|element|attribute)|f(ull_end_element|lush)|write_(c(omment|data)|dtd(_(e(ntity|lement)|attlist))?|pi|element(_ns)?|attribute(_ns)?|raw))\b + scope: support.function.xmlwriter.php + - match: (?i)\b(inflate_(init|add)|zlib_(decode|encode|get_coding_type)|deflate_(init|add)|readgzfile|gz(seek|c(ompress|lose)|tell|inflate|open|de(code|flate)|uncompress|p(uts|assthru)|e(ncode|of)|file|write|re(wind|ad)|get(s(s)?|c)))\b + scope: support.function.zlib.php + - match: (?i)\bis_int(eger)?\b + scope: support.function.alias.php + user-function-call: + - match: '(?i)(?=[a-z_0-9\\]*[a-z_][a-z0-9_]*\s*\()' + push: + - meta_scope: meta.function-call.php + - match: '(?i)[a-z_][a-z_0-9]*(?=\s*\()' + pop: true + - include: namespace + var_basic: + - match: |- + (?x) + (\$+)[a-zA-Z_\x{7f}-\x{ff}] + [a-zA-Z0-9_\x{7f}-\x{ff}]*?\b + scope: variable.other.php + captures: + 1: punctuation.definition.variable.php + var_global: + - match: (\$)((_(COOKIE|FILES|GET|POST|REQUEST))|arg(v|c))\b + scope: variable.other.global.php + captures: + 1: punctuation.definition.variable.php + var_global_safer: + - match: (\$)((GLOBALS|_(ENV|SERVER|SESSION))) + scope: variable.other.global.safer.php + captures: + 1: punctuation.definition.variable.php + variable-name: + - include: var_global + - include: var_global_safer + - match: |- + (?x) + ((\$)(?[a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*)) + (?: + (->)(\g) + | + (\[) + (?:(\d+)|((\$)\g)|(\w+)) + (\]) + )? + comment: "Simple syntax: $foo, $foo[0], $foo[$bar], $foo->bar" + captures: + 1: variable.other.php + 10: string.unquoted.index.php + 11: punctuation.section.array.end.php + 2: punctuation.definition.variable.php + 4: keyword.operator.class.php + 5: variable.other.property.php + 6: punctuation.section.array.begin.php + 7: constant.numeric.index.php + 8: variable.other.index.php + 9: punctuation.definition.variable.php + - match: |- + (?x) + ((\$\{)(?[a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*)(\})) + comment: 'Simple syntax with braces: "foo${bar}baz"' + captures: + 1: variable.other.php + 2: punctuation.definition.variable.php + 4: punctuation.definition.variable.php + variables: + - include: var_global + - include: var_global_safer + - include: var_basic + - match: '(\$\{)(?=.*?\})' + captures: + 1: punctuation.definition.variable.php + push: + - match: '(\})' + captures: + 1: punctuation.definition.variable.php + pop: true + - include: language diff --git a/syntect/minimal_grammars/Perl.sublime-syntax b/syntect/minimal_grammars/Perl.sublime-syntax new file mode 100644 index 0000000..304e2ba --- /dev/null +++ b/syntect/minimal_grammars/Perl.sublime-syntax @@ -0,0 +1,1327 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: Perl +comment: "TODO: Include RegExp syntax" +file_extensions: + - pl + - pm + - pod + - t + - PL + - psgi + - vcl +first_line_match: |- + (?x) + # Hashbang + ^\#!.*(?:\s|\/|(?<=!)\b)perl(?:$|\s) + | + # Modeline + (?i: + # Emacs + -\*-(?:(?:(?!mode\s*:)[^:;]+:[^:;]+;)*\s*mode\s*:)?\s* + perl + \s*(?:;[^:;]+:[^:;]+?)*;?\s*-\*- + | + # Vim + (?:(?:\s|^)vi(?:m[<=>]?\d+|m)?|(?!^)\sex)(?=:(?=\s*set?\s[^\n:]+:)|:(?!\s*set?\s))(?:(?:\s|\s*:\s*)\w*(?:\s*=(?:[^\n\\\s]|\\.)*)?)*[\s:](?:filetype|ft|syntax)\s*= + perl + (?=\s|:|$) + ) +scope: source.perl +contexts: + main: + - include: line_comment + - match: "^(?==[a-zA-Z]+)" + push: + - meta_scope: comment.block.documentation.perl + - match: ^(=cut\b.*$) + pop: true + - include: pod + - include: variable + - match: '\b(?=qr\s*[^\s\w])' + comment: string.regexp.compile.perl + push: + - match: '(qr)\s*\{' + captures: + 0: punctuation.definition.string.perl + 1: support.function.perl + push: + - meta_scope: string.regexp.compile.nested_braces.perl + - match: '\}' + captures: + 0: punctuation.definition.string.perl + 1: support.function.perl + pop: true + - include: escaped_char + - include: variable + - include: nested_braces_interpolated + - match: '(qr)\s*\[' + captures: + 0: punctuation.definition.string.perl + 1: support.function.perl + push: + - meta_scope: string.regexp.compile.nested_brackets.perl + - match: '\]' + captures: + 0: punctuation.definition.string.perl + 1: support.function.perl + pop: true + - include: escaped_char + - include: variable + - include: nested_brackets_interpolated + - match: (qr)\s*< + captures: + 0: punctuation.definition.string.perl + 1: support.function.perl + push: + - meta_scope: string.regexp.compile.nested_ltgt.perl + - match: ">" + captures: + 0: punctuation.definition.string.perl + 1: support.function.perl + pop: true + - include: escaped_char + - include: variable + - include: nested_ltgt_interpolated + - match: (qr)\s*\( + captures: + 0: punctuation.definition.string.perl + 1: support.function.perl + push: + - meta_scope: string.regexp.compile.nested_parens.perl + - match: \) + captures: + 0: punctuation.definition.string.perl + 1: support.function.perl + pop: true + - match: '\$(?=[^\s\w\\''\{\[\(\<])' + comment: This is to prevent thinks like qr/foo$/ to treat $/ as a variable + - include: escaped_char + - include: variable + - include: nested_parens_interpolated + - match: (qr)\s*' + captures: + 0: punctuation.definition.string.perl + 1: support.function.perl + push: + - meta_scope: string.regexp.compile.single-quote.perl + - match: "'" + captures: + 0: punctuation.definition.string.perl + 1: support.function.perl + pop: true + - include: escaped_char + - match: '(qr)\s*([^\s\w''\{\[\(\<])' + captures: + 0: punctuation.definition.string.perl + 1: support.function.perl + push: + - meta_scope: string.regexp.compile.simple-delimiter.perl + - match: \2 + captures: + 0: punctuation.definition.string.perl + 1: support.function.perl + pop: true + - match: '\$(?=[^\s\w''\{\[\(\<])' + comment: This is to prevent thinks like qr/foo$/ to treat $/ as a variable + scope: keyword.control.anchor.perl + - include: escaped_char + - include: variable + - include: nested_parens_interpolated + - match: '((([egimosxradlupcn]*)))(?=(\s+\S|\s*[;\,\#\{\}\)]|\s*$))' + captures: + 1: string.regexp.compile.perl + 2: punctuation.definition.string.perl + 3: keyword.control.regexp-option.perl + pop: true + - match: '(?" + captures: + 0: punctuation.definition.string.perl + 1: support.function.perl + pop: true + - include: escaped_char + - include: variable + - include: nested_ltgt_interpolated + - match: (m)\s*\( + captures: + 0: punctuation.definition.string.perl + 1: support.function.perl + push: + - meta_scope: string.regexp.find-m.nested_parens.perl + - match: \) + captures: + 0: punctuation.definition.string.perl + 1: support.function.perl + pop: true + - include: escaped_char + - include: variable + - include: nested_parens_interpolated + - match: (m)\s*' + captures: + 0: punctuation.definition.string.perl + 1: support.function.perl + push: + - meta_scope: string.regexp.find-m.single-quote.perl + - match: "'" + captures: + 0: punctuation.definition.string.perl + 1: support.function.perl + pop: true + - include: escaped_char + - match: '\G(?" + captures: + 0: punctuation.definition.string.perl + 1: support.function.perl + pop: true + - include: escaped_char + - include: nested_ltgt + - match: (s)\s*\( + captures: + 0: punctuation.definition.string.perl + 1: support.function.perl + push: + - meta_scope: string.regexp.nested_parens.perl + - match: \) + captures: + 0: punctuation.definition.string.perl + 1: support.function.perl + pop: true + - include: escaped_char + - include: nested_parens + - match: '\{' + captures: + 0: punctuation.definition.string.perl + push: + - meta_scope: string.regexp.format.nested_braces.perl + - match: '\}' + captures: + 0: punctuation.definition.string.perl + pop: true + - include: escaped_char + - include: variable + - include: nested_braces_interpolated + - match: '\[' + captures: + 0: punctuation.definition.string.perl + push: + - meta_scope: string.regexp.format.nested_brackets.perl + - match: '\]' + captures: + 0: punctuation.definition.string.perl + pop: true + - include: escaped_char + - include: variable + - include: nested_brackets_interpolated + - match: < + captures: + 0: punctuation.definition.string.perl + push: + - meta_scope: string.regexp.format.nested_ltgt.perl + - match: ">" + captures: + 0: punctuation.definition.string.perl + pop: true + - include: escaped_char + - include: variable + - include: nested_ltgt_interpolated + - match: \( + captures: + 0: punctuation.definition.string.perl + push: + - meta_scope: string.regexp.format.nested_parens.perl + - match: \) + captures: + 0: punctuation.definition.string.perl + pop: true + - include: escaped_char + - include: variable + - include: nested_parens_interpolated + - match: "'" + captures: + 0: punctuation.definition.string.perl + push: + - meta_scope: string.regexp.format.single_quote.perl + - match: "'" + captures: + 0: punctuation.definition.string.perl + pop: true + - match: '\\[''\\]' + scope: constant.character.escape.perl + - match: '([^\s\w\[({<;])' + captures: + 0: punctuation.definition.string.perl + push: + - meta_scope: string.regexp.format.simple_delimiter.perl + - match: \1 + captures: + 0: punctuation.definition.string.perl + pop: true + - include: escaped_char + - include: variable + - match: \s+ + - match: '((([egimosxradlupcn]*)))(?=(\s+\S|\s*[;\,\{\}\)\]>]|\s*$))' + captures: + 1: string.regexp.replace.perl + 2: punctuation.definition.string.perl + 3: keyword.control.regexp-option.perl + pop: true + - match: '\b(?=s([^\sa-zA-Z0-9\[({<]).*\1([egimosxradlupcn]*)([\}\)\;\,]|\s+))' + comment: string.regexp.replaceXXX + push: + - match: '((([egimosxradlupcn]*)))(?=([\}\)\;\,]|\s+|\s*$))' + captures: + 1: string.regexp.replace.perl + 2: punctuation.definition.string.perl + 3: keyword.control.regexp-option.perl + pop: true + - match: '(s\s*)([^\sa-zA-Z0-9\[({<])' + captures: + 0: punctuation.definition.string.perl + 1: support.function.perl + push: + - meta_scope: string.regexp.replaceXXX.simple_delimiter.perl + - match: (?=\2) + captures: + 0: punctuation.definition.string.perl + 1: support.function.perl + pop: true + - include: escaped_char + - match: "'" + captures: + 0: punctuation.definition.string.perl + push: + - meta_scope: string.regexp.replaceXXX.format.single_quote.perl + - match: "'" + captures: + 0: punctuation.definition.string.perl + pop: true + - match: '\\[''\\]' + scope: constant.character.escape.perl.perl + - match: '([^\sa-zA-Z0-9\[({<])' + captures: + 0: punctuation.definition.string.perl + push: + - meta_scope: string.regexp.replaceXXX.format.simple_delimiter.perl + - match: \1 + captures: + 0: punctuation.definition.string.perl + pop: true + - include: escaped_char + - include: variable + - match: '\b(?=(?]))' + comment: string.regexp.replace.extended + push: + - match: '((([egimosradlupc]*x[egimosradlupc]*)))\b' + captures: + 1: string.regexp.replace.perl + 2: punctuation.definition.string.perl + 3: keyword.control.regexp-option.perl + pop: true + - match: (s)\s*(.) + captures: + 0: punctuation.definition.string.perl + 1: support.function.perl + push: + - meta_scope: string.regexp.replace.extended.simple_delimiter.perl + - match: (?=\2) + captures: + 0: punctuation.definition.string.perl + 1: support.function.perl + pop: true + - include: escaped_char + - match: "'" + captures: + 0: punctuation.definition.string.perl + push: + - meta_scope: string.regexp.replace.extended.simple_delimiter.perl + - match: '''(?=[egimosradlupc]*x[egimosradlupc]*)\b' + captures: + 0: punctuation.definition.string.perl + pop: true + - include: escaped_char + - match: (.) + captures: + 0: punctuation.definition.string.perl + push: + - meta_scope: string.regexp.replace.extended.simple_delimiter.perl + - match: '\1(?=[egimosradlupc]*x[egimosradlupc]*)\b' + captures: + 0: punctuation.definition.string.perl + pop: true + - include: escaped_char + - include: variable + - match: '(?<=\(|\{|~|&|\||if|unless|^)\s*((\/))' + captures: + 1: string.regexp.find.perl + 2: punctuation.definition.string.perl + push: + - meta_content_scope: string.regexp.find.perl + - match: '((\1([egimosxradlupcn]*)))(?=(\s+\S|\s*[;\,\#\{\}\)]|\s*$))' + captures: + 1: string.regexp.find.perl + 2: punctuation.definition.string.perl + 3: keyword.control.regexp-option.perl + pop: true + - match: \$(?=\/) + comment: This is to prevent thinks like /foo$/ to treat $/ as a variable + scope: keyword.control.anchor.perl + - include: escaped_char + - include: variable + - match: \b(\w+)\s*(?==>) + captures: + 1: constant.other.key.perl + - match: '(?<={)\s*\w+\s*(?=})' + scope: constant.other.bareword.perl + - match: '^\s*(package)\s+([^\s;]+)' + scope: meta.class.perl + captures: + 1: keyword.control.perl + 2: entity.name.type.class.perl + - match: '\b(sub)(?:\s+([-a-zA-Z0-9_]+))?\s*(?:\([\$\@\*;]*\))?[^\w\{]' + scope: meta.function.perl + captures: + 1: storage.type.sub.perl + 2: entity.name.function.perl + 3: storage.type.method.perl + - match: ^\s*(BEGIN|UNITCHECK|CHECK|INIT|END|DESTROY)\b + scope: meta.function.perl + captures: + 1: entity.name.function.perl + 2: punctuation.definition.parameters.perl + 3: variable.parameter.function.perl + - match: '^(?=(\t| {4}))' + push: + - meta_scope: meta.leading-tabs + - match: '(?=[^\t\s])' + pop: true + - match: '(\t| {4})(\t| {4})?' + captures: + 1: meta.odd-tab + 2: meta.even-tab + - match: '\b(tr|y)\s*([^A-Za-z0-9\s])(.*?)(?)\b(continue|default|die|do|else|elsif|exit|for|foreach|given|goto|if|last|next|redo|return|select|unless|until|wait|when|while|switch|case|require|use|eval)\b + scope: keyword.control.perl + - match: \b(my|our|local)\b + scope: storage.modifier.perl + - match: '(?|=>|->) + scope: keyword.operator.comparison.perl + - match: (((<<) *"HTML"))(.*)\n? + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.doublequote.perl + 3: punctuation.definition.heredoc.perl + push: + - meta_content_scope: text.html.embedded.perl + - match: (^HTML$) + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.doublequote.perl + 3: punctuation.definition.heredoc.perl + pop: true + - include: escaped_char + - include: variable + - include: scope:text.html.basic + - match: (((<<) *"XML"))(.*)\n? + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.doublequote.perl + 3: punctuation.definition.heredoc.perl + push: + - meta_content_scope: text.xml.embedded.perl + - match: (^XML$) + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.doublequote.perl + 3: punctuation.definition.heredoc.perl + pop: true + - include: escaped_char + - include: variable + - include: scope:text.xml + - match: (((<<) *"CSS"))(.*)\n? + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.doublequote.perl + 3: punctuation.definition.heredoc.perl + push: + - meta_content_scope: text.css.embedded.perl + - match: (^CSS$) + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.doublequote.perl + 3: punctuation.definition.heredoc.perl + pop: true + - include: escaped_char + - include: variable + - include: scope:source.css + - match: (((<<) *"JAVASCRIPT"))(.*)\n? + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.doublequote.perl + 3: punctuation.definition.heredoc.perl + push: + - meta_content_scope: text.js.embedded.perl + - match: (^JAVASCRIPT$) + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.doublequote.perl + 3: punctuation.definition.heredoc.perl + pop: true + - include: escaped_char + - include: variable + - include: scope:source.js + - match: (((<<) *"SQL"))(.*)\n? + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.doublequote.perl + 3: punctuation.definition.heredoc.perl + push: + - meta_content_scope: source.sql.embedded.perl + - match: (^SQL$) + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.doublequote.perl + 3: punctuation.definition.heredoc.perl + pop: true + - include: escaped_char + - include: variable + - include: scope:source.sql + - match: (((<<) *"POSTSCRIPT"))(.*)\n? + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.doublequote.perl + 3: punctuation.definition.heredoc.perl + push: + - meta_content_scope: text.postscript.embedded.perl + - match: (^POSTSCRIPT$) + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.doublequote.perl + 3: punctuation.definition.heredoc.perl + pop: true + - include: escaped_char + - include: variable + - include: scope:source.postscript + - match: '(((<<) *"([^"]*)"))(.*)\n?' + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.doublequote.perl + 3: punctuation.definition.heredoc.perl + push: + - meta_content_scope: string.unquoted.heredoc.doublequote.perl + - match: (^\4$) + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.doublequote.perl + 3: punctuation.definition.heredoc.perl + pop: true + - include: escaped_char + - include: variable + - match: (((<<) *'HTML'))(.*)\n? + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.quote.perl + 3: punctuation.definition.heredoc.perl + push: + - meta_content_scope: text.html.embedded.perl + - match: (^HTML$) + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.quote.perl + 3: punctuation.definition.heredoc.perl + pop: true + - include: scope:text.html.basic + - match: (((<<) *'XML'))(.*)\n? + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.quote.perl + 3: punctuation.definition.heredoc.perl + push: + - meta_content_scope: text.xml.embedded.perl + - match: (^XML$) + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.quote.perl + 3: punctuation.definition.heredoc.perl + pop: true + - include: scope:text.xml + - match: (((<<) *'CSS'))(.*)\n? + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.quote.perl + 3: punctuation.definition.heredoc.perl + push: + - meta_content_scope: text.css.embedded.perl + - match: (^CSS$) + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.quote.perl + 3: punctuation.definition.heredoc.perl + pop: true + - include: scope:source.css + - match: (((<<) *'JAVASCRIPT'))(.*)\n? + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.quote.perl + 3: punctuation.definition.heredoc.perl + push: + - meta_content_scope: text.js.embedded.perl + - match: (^JAVASCRIPT$) + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.quote.perl + 3: punctuation.definition.heredoc.perl + pop: true + - include: scope:source.js + - match: (((<<) *'SQL'))(.*)\n? + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.quote.perl + 3: punctuation.definition.heredoc.perl + push: + - meta_content_scope: source.sql.embedded.perl + - match: (^SQL$) + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.quote.perl + 3: punctuation.definition.heredoc.perl + pop: true + - include: scope:source.sql + - match: (((<<) *'POSTSCRIPT'))(.*)\n? + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.quote.perl + 3: punctuation.definition.heredoc.perl + push: + - meta_content_scope: source.postscript.embedded.perl + - match: (^POSTSCRIPT$) + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.quote.perl + 3: punctuation.definition.heredoc.perl + pop: true + - include: scope:source.postscript + - match: '(((<<) *''([^'']*)''))(.*)\n?' + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.quote.perl + 3: punctuation.definition.heredoc.perl + push: + - meta_content_scope: string.unquoted.heredoc.quote.perl + - match: (^\4$) + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.quote.perl + 3: punctuation.definition.heredoc.perl + pop: true + - match: '(((<<) *\\((?![=\d\$\( ])[^;,''"`\s\)]*)))(.*)\n?' + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.quote.perl + 3: punctuation.definition.heredoc.perl + push: + - meta_content_scope: string.unquoted.heredoc.quote.perl + - match: (^\4$) + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.quote.perl + 3: punctuation.definition.heredoc.perl + pop: true + - match: '(((<<) *`([^`]*)`))(.*)\n?' + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.backtick.perl + 3: punctuation.definition.heredoc.perl + push: + - meta_content_scope: string.unquoted.heredoc.backtick.perl + - match: (^\4$) + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.backtick.perl + 3: punctuation.definition.heredoc.perl + pop: true + - include: escaped_char + - include: variable + - match: (((<<) *HTML\b))(.*)\n? + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.perl + 3: punctuation.definition.heredoc.perl + push: + - meta_content_scope: text.html.embedded.perl + - match: (^HTML$) + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.perl + 3: punctuation.definition.heredoc.perl + pop: true + - include: escaped_char + - include: variable + - include: scope:text.html.basic + - match: (((<<) *XML\b))(.*)\n? + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.perl + 3: punctuation.definition.heredoc.perl + push: + - meta_content_scope: text.xml.embedded.perl + - match: (^XML$) + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.perl + 3: punctuation.definition.heredoc.perl + pop: true + - include: escaped_char + - include: variable + - include: scope:text.xml + - match: (((<<) *JAVASCRIPT\b))(.*)\n? + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.perl + 3: punctuation.definition.heredoc.perl + push: + - meta_content_scope: source.js.embedded.perl + - match: (^JAVASCRIPT$) + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.perl + 3: punctuation.definition.heredoc.perl + pop: true + - include: escaped_char + - include: variable + - include: scope:source.js + - match: (((<<) *SQL\b))(.*)\n? + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.perl + 3: punctuation.definition.heredoc.perl + push: + - meta_content_scope: source.sql.embedded.perl + - match: (^SQL$) + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.perl + 3: punctuation.definition.heredoc.perl + pop: true + - include: escaped_char + - include: variable + - include: scope:source.sql + - match: (((<<) *POSTSCRIPT\b))(.*)\n? + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.perl + 3: punctuation.definition.heredoc.perl + push: + - meta_content_scope: source.postscript.embedded.perl + - match: (^POSTSCRIPT$) + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.perl + 3: punctuation.definition.heredoc.perl + pop: true + - include: escaped_char + - include: variable + - include: scope:source.postscript + - match: '(((<<) *((?![=\d\$\( ])[^;,''"`\s\)]*)))(.*)\n?' + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.perl + 3: punctuation.definition.heredoc.perl + push: + - meta_content_scope: string.unquoted.heredoc.perl + - match: (^\4$) + captures: + 1: punctuation.definition.string.perl + 2: string.unquoted.heredoc.perl + 3: punctuation.definition.heredoc.perl + pop: true + - include: escaped_char + - include: variable + - match: '\bqq\s*([^\(\{\[\<\w\s])' + captures: + 0: punctuation.definition.string.begin.perl + push: + - meta_scope: string.quoted.other.qq.perl + - match: \1 + captures: + 0: punctuation.definition.string.end.perl + pop: true + - include: escaped_char + - include: variable + - match: '\bqx\s*([^''\(\{\[\<\w\s])' + captures: + 0: punctuation.definition.string.begin.perl + push: + - meta_scope: string.interpolated.qx.perl + - match: \1 + captures: + 0: punctuation.definition.string.end.perl + pop: true + - include: escaped_char + - include: variable + - match: \bqx\s*' + captures: + 0: punctuation.definition.string.begin.perl + push: + - meta_scope: string.interpolated.qx.single-quote.perl + - match: "'" + captures: + 0: punctuation.definition.string.end.perl + pop: true + - include: escaped_char + - match: '"' + captures: + 0: punctuation.definition.string.begin.perl + push: + - meta_scope: string.quoted.double.perl + - match: '"' + captures: + 0: punctuation.definition.string.end.perl + pop: true + - include: escaped_char + - include: variable + - match: '(?)\bqw?\s*([^\(\{\[\<\w\s])' + captures: + 0: punctuation.definition.string.begin.perl + push: + - meta_scope: string.quoted.other.q.perl + - match: \1 + captures: + 0: punctuation.definition.string.end.perl + pop: true + - match: "'" + captures: + 0: punctuation.definition.string.begin.perl + push: + - meta_scope: string.quoted.single.perl + - match: "'" + captures: + 0: punctuation.definition.string.end.perl + pop: true + - match: '\\[''\\]' + scope: constant.character.escape.perl + - match: "`" + captures: + 0: punctuation.definition.string.begin.perl + push: + - meta_scope: string.interpolated.perl + - match: "`" + captures: + 0: punctuation.definition.string.end.perl + pop: true + - include: escaped_char + - include: variable + - match: (?)\bqq\s*\( + captures: + 0: punctuation.definition.string.begin.perl + push: + - meta_scope: string.quoted.other.qq-paren.perl + - match: \) + captures: + 0: punctuation.definition.string.end.perl + pop: true + - include: escaped_char + - include: nested_parens_interpolated + - include: variable + - match: '\bqq\s*\{' + captures: + 0: punctuation.definition.string.begin.perl + push: + - meta_scope: string.quoted.other.qq-brace.perl + - match: '\}' + captures: + 0: punctuation.definition.string.end.perl + pop: true + - include: escaped_char + - include: nested_braces_interpolated + - include: variable + - match: '\bqq\s*\[' + captures: + 0: punctuation.definition.string.begin.perl + push: + - meta_scope: string.quoted.other.qq-bracket.perl + - match: '\]' + captures: + 0: punctuation.definition.string.end.perl + pop: true + - include: escaped_char + - include: nested_brackets_interpolated + - include: variable + - match: \bqq\s*\< + captures: + 0: punctuation.definition.string.begin.perl + push: + - meta_scope: string.quoted.other.qq-ltgt.perl + - match: \> + captures: + 0: punctuation.definition.string.end.perl + pop: true + - include: escaped_char + - include: nested_ltgt_interpolated + - include: variable + - match: (?)\bqx\s*\( + captures: + 0: punctuation.definition.string.begin.perl + push: + - meta_scope: string.interpolated.qx-paren.perl + - match: \) + captures: + 0: punctuation.definition.string.end.perl + pop: true + - include: escaped_char + - include: nested_parens_interpolated + - include: variable + - match: '\bqx\s*\{' + captures: + 0: punctuation.definition.string.begin.perl + push: + - meta_scope: string.interpolated.qx-brace.perl + - match: '\}' + captures: + 0: punctuation.definition.string.end.perl + pop: true + - include: escaped_char + - include: nested_braces_interpolated + - include: variable + - match: '\bqx\s*\[' + captures: + 0: punctuation.definition.string.begin.perl + push: + - meta_scope: string.interpolated.qx-bracket.perl + - match: '\]' + captures: + 0: punctuation.definition.string.end.perl + pop: true + - include: escaped_char + - include: nested_brackets_interpolated + - include: variable + - match: \bqx\s*\< + captures: + 0: punctuation.definition.string.begin.perl + push: + - meta_scope: string.interpolated.qx-ltgt.perl + - match: \> + captures: + 0: punctuation.definition.string.end.perl + pop: true + - include: escaped_char + - include: nested_ltgt_interpolated + - include: variable + - match: (?)\bqw?\s*\( + captures: + 0: punctuation.definition.string.begin.perl + push: + - meta_scope: string.quoted.other.q-paren.perl + - match: \) + captures: + 0: punctuation.definition.string.end.perl + pop: true + - include: nested_parens + - match: '\bqw?\s*\{' + captures: + 0: punctuation.definition.string.begin.perl + push: + - meta_scope: string.quoted.other.q-brace.perl + - match: '\}' + captures: + 0: punctuation.definition.string.end.perl + pop: true + - include: nested_braces + - match: '\bqw?\s*\[' + captures: + 0: punctuation.definition.string.begin.perl + push: + - meta_scope: string.quoted.other.q-bracket.perl + - match: '\]' + captures: + 0: punctuation.definition.string.end.perl + pop: true + - include: nested_brackets + - match: \bqw?\s*\< + captures: + 0: punctuation.definition.string.begin.perl + push: + - meta_scope: string.quoted.other.q-ltgt.perl + - match: \> + captures: + 0: punctuation.definition.string.end.perl + pop: true + - include: nested_ltgt + - match: ^__\w+__ + captures: + 0: punctuation.definition.string.begin.perl + push: + - meta_scope: string.unquoted.program-block.perl + - match: $ + captures: + 0: punctuation.definition.string.end.perl + pop: true + - match: \b(format)\s+(\w+)\s*= + captures: + 1: support.function.perl + 2: entity.name.function.format.perl + push: + - meta_scope: meta.format.perl + - match: ^\.\s*$ + pop: true + - include: line_comment + - include: variable + - match: \b(x)\s*(\d+)\b + captures: + 1: support.function.perl + 2: entity.name.function.perl + - match: \b(ARGV|DATA|ENV|SIG|STDERR|STDIN|STDOUT|atan2|bind|binmode|bless|caller|chdir|chmod|chomp|chop|chown|chr|chroot|close|closedir|cmp|connect|cos|crypt|dbmclose|dbmopen|defined|delete|dump|each|endgrent|endhostent|endnetent|endprotoent|endpwent|endservent|eof|eq|eval|exec|exists|exp|fcntl|fileno|flock|fork|formline|ge|getc|getgrent|getgrgid|getgrnam|gethostbyaddr|gethostbyname|gethostent|getlogin|getnetbyaddr|getnetbyname|getnetent|getpeername|getpgrp|getppid|getpriority|getprotobyname|getprotobynumber|getprotoent|getpwent|getpwnam|getpwuid|getservbyname|getservbyport|getservent|getsockname|getsockopt|glob|gmtime|grep|gt|hex|import|index|int|ioctl|join|keys|kill|lc|lcfirst|le|length|link|listen|local|localtime|log|lstat|lt|m|map|mkdir|msgctl|msgget|msgrcv|msgsnd|ne|no|oct|open|opendir|ord|pack|pipe|pop|pos|print|printf|push|quotemeta|rand|read|readdir|readlink|recv|ref|rename|reset|reverse|rewinddir|rindex|rmdir|s|say|scalar|seek|seekdir|semctl|semget|semop|send|setgrent|sethostent|setnetent|setpgrp|setpriority|setprotoent|setpwent|setservent|setsockopt|shift|shmctl|shmget|shmread|shmwrite|shutdown|sin|sleep|socket|socketpair|sort|splice|split|sprintf|sqrt|srand|stat|study|substr|symlink|syscall|sysopen|sysread|system|syswrite|tell|telldir|tie|tied|time|times|tr|truncate|uc|ucfirst|umask|undef|unlink|unpack|unshift|untie|utime|values|vec|waitpid|wantarray|warn|write|y)\b + scope: support.function.perl + - match: '(\{)(\})' + comment: Match empty brackets for ↩ snippet + captures: + 1: punctuation.section.scope.begin.perl + 2: punctuation.section.scope.end.perl + - match: (\()(\)) + comment: Match empty parenthesis for ↩ snippet + captures: + 1: punctuation.section.scope.begin.perl + 2: punctuation.section.scope.end.perl + escaped_char: + - match: \\\d+ + scope: constant.character.escape.perl + - match: '\\c[^\s\\]' + scope: constant.character.escape.perl + - match: '\\g(?:\{(?:\w*|-\d+)\}|\d+)' + scope: constant.character.escape.perl + - match: '\\k(?:\{\w*\}|<\w*>|''\w*'')' + scope: constant.character.escape.perl + - match: '\\N\{[^\}]*\}' + scope: constant.character.escape.perl + - match: '\\o\{\d*\}' + scope: constant.character.escape.perl + - match: '\\(?:p|P)(?:\{\w*\}|P)' + scope: constant.character.escape.perl + - match: '\\x(?:[0-9a-zA-Z]{2}|\{\w*\})?' + scope: constant.character.escape.perl + - match: \\. + scope: constant.character.escape.perl + line_comment: + - match: '(^[ \t]+)?(?=#)' + captures: + 1: punctuation.whitespace.comment.leading.perl + push: + - match: (?!\G) + pop: true + - match: "#" + captures: + 0: punctuation.definition.comment.perl + push: + - meta_scope: comment.line.number-sign.perl + - match: \n + pop: true + nested_braces: + - match: '\{' + captures: + 1: punctuation.section.scope.perl + push: + - match: '\}' + captures: + 1: punctuation.section.scope.perl + pop: true + - include: escaped_char + - include: nested_braces + nested_braces_interpolated: + - match: '\{' + captures: + 1: punctuation.section.scope.perl + push: + - match: '\}' + captures: + 1: punctuation.section.scope.perl + pop: true + - include: escaped_char + - include: variable + - include: nested_braces_interpolated + nested_brackets: + - match: '\[' + captures: + 1: punctuation.section.scope.perl + push: + - match: '\]' + captures: + 1: punctuation.section.scope.perl + pop: true + - include: escaped_char + - include: nested_brackets + nested_brackets_interpolated: + - match: '\[' + captures: + 1: punctuation.section.scope.perl + push: + - match: '\]' + captures: + 1: punctuation.section.scope.perl + pop: true + - include: escaped_char + - include: variable + - include: nested_brackets_interpolated + nested_ltgt: + - match: < + captures: + 1: punctuation.section.scope.perl + push: + - match: ">" + captures: + 1: punctuation.section.scope.perl + pop: true + - include: nested_ltgt + nested_ltgt_interpolated: + - match: < + captures: + 1: punctuation.section.scope.perl + push: + - match: ">" + captures: + 1: punctuation.section.scope.perl + pop: true + - include: variable + - include: nested_ltgt_interpolated + nested_parens: + - match: \( + captures: + 1: punctuation.section.scope.perl + push: + - match: \) + captures: + 1: punctuation.section.scope.perl + pop: true + - include: escaped_char + - include: nested_parens + nested_parens_interpolated: + - match: \( + captures: + 1: punctuation.section.scope.perl + push: + - match: \) + captures: + 1: punctuation.section.scope.perl + pop: true + - match: '\$(?=[^\s\w''\{\[\(\<])' + comment: This is to prevent thinks like qr/foo$/ to treat $/ as a variable + scope: keyword.control.anchor.perl + - include: escaped_char + - include: variable + - include: nested_parens_interpolated + pod: + - match: ^=(pod|back|cut)\b + scope: storage.type.class.pod.perl + - match: ^(=begin)\s+(html)\s*$ + captures: + 1: storage.type.class.pod.perl + 2: variable.other.pod.perl + push: + - meta_scope: meta.embedded.pod.perl + - meta_content_scope: text.embedded.html.basic + - match: ^(=end)\s+(html)|^(?==cut) + captures: + 1: storage.type.class.pod.perl + 2: variable.other.pod.perl + pop: true + - include: scope:text.html.basic + - match: '^(=(?:head[1-4]|item|over|encoding|begin|end|for))\b\s*(.*)' + captures: + 1: storage.type.class.pod.perl + 2: variable.other.pod.perl + - include: pod-formatting + pod-formatting: + - match: 'I(?:<([^<>]+)>|<+(\s+(?:(?|[^>])+\s+)>+)' + scope: entity.name.type.instance.pod.perl + captures: + 1: markup.italic.pod.perl + 2: markup.italic.pod.perl + - match: 'B(?:<([^<>]+)>|<+(\s+(?:(?|[^>])+\s+)>+)' + scope: entity.name.type.instance.pod.perl + captures: + 1: markup.bold.pod.perl + 2: markup.bold.pod.perl + - match: 'C(?:<([^<>]+)>|<+(\\s+(?:(?|[^>])+\\s+)>+)' + scope: entity.name.type.instance.pod.perl + captures: + 1: markup.raw.pod.perl + 2: markup.raw.pod.perl + - match: "L<([^>]+)>" + scope: entity.name.type.instance.pod.perl + captures: + 1: markup.underline.link.hyperlink.pod.perl + - match: "[EFSXZ]<[^>]*>" + scope: entity.name.type.instance.pod.perl + variable: + - match: '(\$)&(?![A-Za-z0-9_])' + scope: variable.other.regexp.match.perl + captures: + 1: punctuation.definition.variable.perl + - match: '(\$)`(?![A-Za-z0-9_])' + scope: variable.other.regexp.pre-match.perl + captures: + 1: punctuation.definition.variable.perl + - match: '(\$)''(?![A-Za-z0-9_])' + scope: variable.other.regexp.post-match.perl + captures: + 1: punctuation.definition.variable.perl + - match: '(\$)\+(?![A-Za-z0-9_])' + scope: variable.other.regexp.last-paren-match.perl + captures: + 1: punctuation.definition.variable.perl + - match: '(\$)"(?![A-Za-z0-9_])' + scope: variable.other.readwrite.list-separator.perl + captures: + 1: punctuation.definition.variable.perl + - match: '(\$)0(?![A-Za-z0-9_])' + scope: variable.other.predefined.program-name.perl + captures: + 1: punctuation.definition.variable.perl + - match: '(\$)[_ab\*\.\/\|,\\;#%=\-~^:?!\$<>\(\)\[\]@](?![A-Za-z0-9_])' + scope: variable.other.predefined.perl + captures: + 1: punctuation.definition.variable.perl + - match: '(\$)[0-9]+(?![A-Za-z0-9_])' + scope: variable.other.subpattern.perl + captures: + 1: punctuation.definition.variable.perl + - match: '([\$\@\%](#)?)([a-zA-Zx7f-xff\$]|::)([a-zA-Z0-9_x7f-xff\$]|::)*\b' + scope: variable.other.readwrite.global.perl + captures: + 1: punctuation.definition.variable.perl + - match: '(\$\{)(?:[a-zA-Zx7f-xff\$]|::)(?:[a-zA-Z0-9_x7f-xff\$]|::)*(\})' + scope: variable.other.readwrite.global.perl + captures: + 1: punctuation.definition.variable.perl + 2: punctuation.definition.variable.perl + - match: '([\$\@\%](#)?)[0-9_]\b' + scope: variable.other.readwrite.global.special.perl + captures: + 1: punctuation.definition.variable.perl diff --git a/syntect/minimal_grammars/PowerShellSyntax.sublime-syntax b/syntect/minimal_grammars/PowerShellSyntax.sublime-syntax new file mode 100644 index 0000000..4715099 --- /dev/null +++ b/syntect/minimal_grammars/PowerShellSyntax.sublime-syntax @@ -0,0 +1,447 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: PowerShell +file_extensions: + - ps1 + - psm1 + - psd1 +scope: source.powershell +contexts: + main: + - match: "<#" + captures: + 0: punctuation.definition.comment.block.begin.powershell + push: + - meta_scope: comment.block.powershell + - match: "#>" + captures: + 0: punctuation.definition.comment.block.end.powershell + pop: true + - include: commentEmbeddedDocs + - match: '[2-6]>&1|>>|>|<<|<|>|>\||[1-6]>|[1-6]>>' + scope: keyword.operator.redirection.powershell + - include: commands + - include: commentLine + - include: variable + - include: interpolatedStringContent + - include: function + - include: attribute + - include: UsingDirective + - include: type + - include: hashtable + - include: doubleQuotedString + - include: scriptblock + - include: doubleQuotedStringEscapes + - match: (?|->>) + scope: keyword.operator.assignment.r + - match: (==|!=|<>|<|>|<=|>=) + scope: keyword.operator.comparison.r + - match: "(!|&{1,2}|[|]{1,2})" + scope: keyword.operator.logical.r + - match: (\.\.\.|\$|@|:|\~) + scope: keyword.other.r + - match: '"' + captures: + 0: punctuation.definition.string.begin.r + push: + - meta_scope: string.quoted.double.r + - match: '"' + captures: + 0: punctuation.definition.string.end.r + pop: true + - match: \\. + scope: constant.character.escape.r + - match: "'" + captures: + 0: punctuation.definition.string.begin.r + push: + - meta_scope: string.quoted.single.r + - match: "'" + captures: + 0: punctuation.definition.string.end.r + pop: true + - match: \\. + scope: constant.character.escape.r + - match: '([[:alpha:].][[:alnum:]._]*)\s*(<-)\s*(function)' + scope: meta.function.r + captures: + 1: entity.name.function.r + 2: keyword.operator.assignment.r + 3: keyword.control.r + - match: '(setMethod|setReplaceMethod|setGeneric|setGroupGeneric|setClass)\s*\(\s*([[:alpha:]\d]+\s*=\s*)?("|\x{27})([a-zA-Z._\[\$@][a-zA-Z0-9._\[]*?)\3.*' + scope: meta.method.declaration.r + captures: + 1: entity.name.tag.r + 4: entity.name.type.r + - match: '([[:alpha:].][[:alnum:]._]*)\s*\(' + - match: '([[:alpha:].][[:alnum:]._]*)\s*(=)(?=[^=])' + captures: + 1: variable.parameter.r + 2: keyword.operator.assignment.r + - match: '\b([\d_][[:alnum:]._]+)\b' + scope: invalid.illegal.variable.other.r + - match: '\b([[:alnum:]_]+)(?=::)' + scope: entity.namespace.r + - match: '\b([[:alnum:]._]+)\b' + scope: variable.other.r + - match: '\{' + captures: + 0: punctuation.section.block.begin.r + push: + - meta_scope: meta.block.r + - match: '\}' + captures: + 0: punctuation.section.block.end.r + pop: true + - include: scope:source.r diff --git a/syntect/minimal_grammars/SQL.sublime-syntax b/syntect/minimal_grammars/SQL.sublime-syntax new file mode 100644 index 0000000..5a9efdf --- /dev/null +++ b/syntect/minimal_grammars/SQL.sublime-syntax @@ -0,0 +1,251 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: SQL +file_extensions: + - sql + - ddl + - dml +scope: source.sql +contexts: + main: + - include: comments + - match: '(?i:^\s*(create(?:\s+or\s+replace)?)\s+(aggregate|conversion|database|domain|function|group|(unique\s+)?index|language|operator class|operator|rule|schema|sequence|table|tablespace|trigger|type|user|view)\s+)([''"`]?)(\w+)\4' + scope: meta.create.sql + captures: + 1: keyword.other.create.sql + 2: keyword.other.sql + 5: entity.name.function.sql + - match: (?i:^\s*(drop)\s+(aggregate|conversion|database|domain|function|group|index|language|operator class|operator|rule|schema|sequence|table|tablespace|trigger|type|user|view)) + scope: meta.drop.sql + captures: + 1: keyword.other.create.sql + 2: keyword.other.sql + - match: (?i:\s*(drop)\s+(table)\s+(\w+)(\s+cascade)?\b) + scope: meta.drop.sql + captures: + 1: keyword.other.create.sql + 2: keyword.other.table.sql + 3: entity.name.function.sql + 4: keyword.other.cascade.sql + - match: (?i:^\s*(alter)\s+(aggregate|conversion|database|domain|function|group|index|language|operator class|operator|rule|schema|sequence|table|tablespace|trigger|type|user|view)\s+) + scope: meta.alter.sql + captures: + 1: keyword.other.create.sql + 2: keyword.other.table.sql + - match: |- + (?xi) + + # normal stuff, capture 1 + \b(bigint|bigserial|bit|boolean|box|bytea|cidr|circle|date|double\sprecision|inet|int|integer|line|lseg|macaddr|money|oid|path|point|polygon|real|serial|smallint|sysdate|text)\b + + # numeric suffix, capture 2 + 3i + |\b(bit\svarying|character\s(?:varying)?|tinyint|var\schar|float|interval)\((\d+)\) + + # optional numeric suffix, capture 4 + 5i + |\b(char|number|varchar\d?)\b(?:\((\d+)\))? + + # special case, capture 6 + 7i + 8i + |\b(numeric|decimal)\b(?:\((\d+),(\d+)\))? + + # special case, captures 9, 10i, 11 + |\b(times?)\b(?:\((\d+)\))?(\swith(?:out)?\stime\szone\b)? + + # special case, captures 12, 13, 14i, 15 + |\b(timestamp)(?:(s|tz))?\b(?:\((\d+)\))?(\s(with|without)\stime\szone\b)? + + + captures: + 1: storage.type.sql + 10: constant.numeric.sql + 11: storage.type.sql + 12: storage.type.sql + 13: storage.type.sql + 14: constant.numeric.sql + 15: storage.type.sql + 2: storage.type.sql + 3: constant.numeric.sql + 4: storage.type.sql + 5: constant.numeric.sql + 6: storage.type.sql + 7: constant.numeric.sql + 8: constant.numeric.sql + 9: storage.type.sql + - match: (?i:\b((?:primary|foreign)\s+key|references|on\sdelete(\s+cascade)?|check|constraint)\b) + scope: storage.modifier.sql + - match: \b\d+\b + scope: constant.numeric.sql + - match: (?i:\b(select(\s+distinct)?|insert\s+(ignore\s+)?into|update|delete|from|set|where|group\sby|or|like|and|union(\s+all)?|having|order\sby|limit|(inner|cross)\s+join|join|straight_join|(left|right)(\s+outer)?\s+join|natural(\s+(left|right)(\s+outer)?)?\s+join)\b) + scope: keyword.other.DML.sql + - match: (?i:\b(on|((is\s+)?not\s+)?null)\b) + scope: keyword.other.DDL.create.II.sql + - match: (?i:\bvalues\b) + scope: keyword.other.DML.II.sql + - match: (?i:\b(begin(\s+work)?|start\s+transaction|commit(\s+work)?|rollback(\s+work)?)\b) + scope: keyword.other.LUW.sql + - match: (?i:\b(grant(\swith\sgrant\soption)?|revoke)\b) + scope: keyword.other.authorization.sql + - match: (?i:\bin\b) + scope: keyword.other.data-integrity.sql + - match: (?i:^\s*(comment\s+on\s+(table|column|aggregate|constraint|database|domain|function|index|operator|rule|schema|sequence|trigger|type|view))\s+.*?\s+(is)\s+) + scope: keyword.other.object-comments.sql + - match: (?i)\bAS\b + scope: keyword.other.alias.sql + - match: (?i)\b(DESC|ASC)\b + scope: keyword.other.order.sql + - match: \* + scope: keyword.operator.star.sql + - match: "[!<>]?=|<>|<|>" + scope: keyword.operator.comparison.sql + - match: '-|\+|/' + scope: keyword.operator.math.sql + - match: \|\| + scope: keyword.operator.concatenator.sql + - match: (?i)\b(CURRENT_(DATE|TIME(STAMP)?|USER)|(SESSION|SYSTEM)_USER)\b + comment: List of SQL99 built-in functions from http://www.oreilly.com/catalog/sqlnut/chapter/ch04.html + scope: support.function.scalar.sql + - match: (?i)\b(AVG|COUNT|MIN|MAX|SUM)(?=\s*\() + comment: List of SQL99 built-in functions from http://www.oreilly.com/catalog/sqlnut/chapter/ch04.html + scope: support.function.aggregate.sql + - match: (?i)\b(CONCATENATE|CONVERT|LOWER|SUBSTRING|TRANSLATE|TRIM|UPPER)\b + scope: support.function.string.sql + - match: (\w+?)\.(\w+) + captures: + 1: constant.other.database-name.sql + 2: constant.other.table-name.sql + - include: strings + - include: regexps + - match: (\()(\)) + comment: Allow for special ↩ behavior + scope: meta.block.sql + captures: + 1: punctuation.section.scope.begin.sql + 2: punctuation.section.scope.end.sql + comments: + - match: '(^[ \t]+)?(?=--)' + captures: + 1: punctuation.whitespace.comment.leading.sql + push: + - match: (?!\G) + pop: true + - match: "--" + captures: + 0: punctuation.definition.comment.sql + push: + - meta_scope: comment.line.double-dash.sql + - match: \n + pop: true + - match: '(^[ \t]+)?(?=#)' + captures: + 1: punctuation.whitespace.comment.leading.sql + push: + - match: (?!\G) + pop: true + - match: "#" + captures: + 0: punctuation.definition.comment.sql + push: + - meta_scope: comment.line.number-sign.sql + - match: \n + pop: true + - match: /\* + captures: + 0: punctuation.definition.comment.sql + push: + - meta_scope: comment.block.c + - match: \*/ + captures: + 0: punctuation.definition.comment.sql + pop: true + regexps: + - match: /(?=\S.*/) + captures: + 0: punctuation.definition.string.begin.sql + push: + - meta_scope: string.regexp.sql + - match: / + captures: + 0: punctuation.definition.string.end.sql + pop: true + - include: string_interpolation + - match: \\/ + scope: constant.character.escape.slash.sql + - match: '%r\{' + comment: We should probably handle nested bracket pairs!?! -- Allan + captures: + 0: punctuation.definition.string.begin.sql + push: + - meta_scope: string.regexp.modr.sql + - match: '\}' + captures: + 0: punctuation.definition.string.end.sql + pop: true + - include: string_interpolation + string_escape: + - match: \\. + scope: constant.character.escape.sql + string_interpolation: + - match: '(#\{)([^\}]*)(\})' + scope: string.interpolated.sql + captures: + 1: punctuation.definition.string.begin.sql + 3: punctuation.definition.string.end.sql + strings: + - match: '('')[^''\\]*('')' + comment: this is faster than the next begin/end rule since sub-pattern will match till end-of-line and SQL files tend to have very long lines. + scope: string.quoted.single.sql + captures: + 1: punctuation.definition.string.begin.sql + 2: punctuation.definition.string.end.sql + - match: "'" + captures: + 0: punctuation.definition.string.begin.sql + push: + - meta_scope: string.quoted.single.sql + - match: "'" + captures: + 0: punctuation.definition.string.end.sql + pop: true + - include: string_escape + - match: '(`)[^`\\]*(`)' + comment: this is faster than the next begin/end rule since sub-pattern will match till end-of-line and SQL files tend to have very long lines. + scope: string.quoted.other.backtick.sql + captures: + 1: punctuation.definition.string.begin.sql + 2: punctuation.definition.string.end.sql + - match: "`" + captures: + 0: punctuation.definition.string.begin.sql + push: + - meta_scope: string.quoted.other.backtick.sql + - match: "`" + captures: + 0: punctuation.definition.string.end.sql + pop: true + - include: string_escape + - match: '(")[^"#]*(")' + comment: this is faster than the next begin/end rule since sub-pattern will match till end-of-line and SQL files tend to have very long lines. + scope: string.quoted.double.sql + captures: + 1: punctuation.definition.string.begin.sql + 2: punctuation.definition.string.end.sql + - match: '"' + captures: + 0: punctuation.definition.string.begin.sql + push: + - meta_scope: string.quoted.double.sql + - match: '"' + captures: + 0: punctuation.definition.string.end.sql + pop: true + - include: string_interpolation + - match: '%\{' + captures: + 0: punctuation.definition.string.begin.sql + push: + - meta_scope: string.other.quoted.brackets.sql + - match: '\}' + captures: + 0: punctuation.definition.string.end.sql + pop: true + - include: string_interpolation diff --git a/syntect/minimal_grammars/TOML.sublime-syntax b/syntect/minimal_grammars/TOML.sublime-syntax new file mode 100644 index 0000000..07a8f02 --- /dev/null +++ b/syntect/minimal_grammars/TOML.sublime-syntax @@ -0,0 +1,254 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: TOML +file_extensions: + - toml +scope: source.toml +contexts: + main: + - include: comments + - include: groups + - include: key_pair + - include: invalid + comments: + - match: '(^[ \t]+)?(?=#)' + captures: + 1: punctuation.whitespace.comment.leading.toml + push: + - match: (?!\G) + pop: true + - match: "#" + captures: + 0: punctuation.definition.comment.toml + push: + - meta_scope: comment.line.number-sign.toml + - match: \n + pop: true + groups: + - match: '^\s*(\[)([^\[\]]*)(\])' + scope: meta.group.toml + captures: + 1: punctuation.definition.section.begin.toml + 3: punctuation.definition.section.begin.toml + - match: '^\s*(\[\[)([^\[\]]*)(\]\])' + scope: meta.group.double.toml + captures: + 1: punctuation.definition.section.begin.toml + 3: punctuation.definition.section.begin.toml + invalid: + - match: \S+(\s*(?=\S))? + scope: invalid.illegal.not-allowed-here.toml + key_pair: + - match: '([A-Za-z0-9_-]+)\s*(=)\s*' + captures: + 1: variable.other.key.toml + 2: punctuation.separator.key-value.toml + push: + - match: (?<=\S)(?]|^await|[^\._$[:alnum:]]await|^return|[^\._$[:alnum:]]return|^yield|[^\._$[:alnum:]]yield|^throw|[^\._$[:alnum:]]throw|^in|[^\._$[:alnum:]]in|^of|[^\._$[:alnum:]]of|^typeof|[^\._$[:alnum:]]typeof|&&|\|\||\*)\s*(\{)' + captures: + 1: punctuation.definition.block.ts + push: + - meta_scope: meta.objectliteral.ts + - match: '\}' + captures: + 0: punctuation.definition.block.ts + pop: true + - include: object-member + array-binding-pattern: + - match: '(?:(\.\.\.)\s*)?(\[)' + captures: + 1: keyword.operator.rest.ts + 2: punctuation.definition.binding-pattern.array.ts + push: + - match: '\]' + captures: + 0: punctuation.definition.binding-pattern.array.ts + pop: true + - include: binding-element + - include: punctuation-comma + array-binding-pattern-const: + - match: '(?:(\.\.\.)\s*)?(\[)' + captures: + 1: keyword.operator.rest.ts + 2: punctuation.definition.binding-pattern.array.ts + push: + - match: '\]' + captures: + 0: punctuation.definition.binding-pattern.array.ts + pop: true + - include: binding-element-const + - include: punctuation-comma + array-literal: + - match: '\s*(\[)' + captures: + 1: meta.brace.square.ts + push: + - meta_scope: meta.array.literal.ts + - match: '\]' + captures: + 0: meta.brace.square.ts + pop: true + - include: expression + - include: punctuation-comma + arrow-function: + - match: '(?:(?)' + scope: meta.arrow.ts + captures: + 1: storage.modifier.async.ts + 2: variable.parameter.ts + - match: |- + (?x) (?: + (? is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + ) + ) + captures: + 1: storage.modifier.async.ts + push: + - meta_scope: meta.arrow.ts + - match: '(?==>|\{|(^\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\s+))' + pop: true + - include: comment + - include: type-parameters + - include: function-parameters + - include: arrow-return-type + - include: possibly-arrow-return-type + - match: "=>" + captures: + 0: storage.type.function.arrow.ts + push: + - meta_scope: meta.arrow.ts + - match: '((?<=\}|\S)(?)|((?!\{)(?=\S)))(?!\/[\/\*])' + pop: true + - include: single-line-comment-consuming-line-ending + - include: decl-block + - include: expression + arrow-return-type: + - match: (?<=\))\s*(:) + captures: + 1: keyword.operator.type.annotation.ts + push: + - meta_scope: meta.return.type.arrow.ts + - match: '(?==>|\{|(^\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\s+))' + pop: true + - include: arrow-return-type-body + arrow-return-type-body: + - match: '(?<=[:])(?=\s*\{)' + push: + - match: '(?<=\})' + pop: true + - include: type-object + - include: type-predicate-operator + - include: type + async-modifier: + - match: '(?) + scope: cast.expr.ts + captures: + 1: meta.brace.angle.ts + 2: storage.modifier.ts + 3: meta.brace.angle.ts + - match: '(?:(?*?\&\|\^]|[^_$[:alnum:]](?:\+\+|\-\-)|[^\+]\+|[^\-]\-))\s*(<)(?!) + captures: + 1: meta.brace.angle.ts + pop: true + - include: type + - match: '(?:(?<=^))\s*(<)(?=[_$[:alpha:]][_$[:alnum:]]*\s*>)' + captures: + 1: meta.brace.angle.ts + push: + - meta_scope: cast.expr.ts + - match: (\>) + captures: + 1: meta.brace.angle.ts + pop: true + - include: type + class-declaration: + - match: '(?\s*$)' + captures: + 1: punctuation.definition.comment.ts + push: + - meta_scope: comment.line.triple-slash.directive.ts + - match: (?=$) + pop: true + - match: (<)(reference|amd-dependency|amd-module) + captures: + 1: punctuation.definition.tag.directive.ts + 2: entity.name.tag.directive.ts + push: + - meta_scope: meta.tag.ts + - match: /> + captures: + 0: punctuation.definition.tag.directive.ts + pop: true + - match: path|types|no-default-lib|lib|name + scope: entity.other.attribute-name.directive.ts + - match: "=" + scope: keyword.operator.assignment.ts + - include: string + docblock: + - match: |- + (?x) + ((@)(?:access|api)) + \s+ + (private|protected|public) + \b + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: constant.language.access-type.jsdoc + - match: |- + (?x) + ((@)author) + \s+ + ( + [^@\s<>*/] + (?:[^@<>*/]|\*[^/])* + ) + (?: + \s* + (<) + ([^>\s]+) + (>) + )? + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: entity.name.type.instance.jsdoc + 4: punctuation.definition.bracket.angle.begin.jsdoc + 5: constant.other.email.link.underline.jsdoc + 6: punctuation.definition.bracket.angle.end.jsdoc + - match: |- + (?x) + ((@)borrows) \s+ + ((?:[^@\s*/]|\*[^/])+) # + \s+ (as) \s+ # as + ((?:[^@\s*/]|\*[^/])+) # + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: entity.name.type.instance.jsdoc + 4: keyword.operator.control.jsdoc + 5: entity.name.type.instance.jsdoc + - match: ((@)example)\s+ + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + push: + - meta_scope: meta.example.jsdoc + - match: (?=@|\*/) + pop: true + - match: ^\s\*\s+ + - match: \G(<)caption(>) + captures: + 0: entity.name.tag.inline.jsdoc + 1: punctuation.definition.bracket.angle.begin.jsdoc + 2: punctuation.definition.bracket.angle.end.jsdoc + push: + - meta_content_scope: constant.other.description.jsdoc + - match: ()|(?=\*/) + captures: + 0: entity.name.tag.inline.jsdoc + 1: punctuation.definition.bracket.angle.begin.jsdoc + 2: punctuation.definition.bracket.angle.end.jsdoc + pop: true + - match: '[^\s@*](?:[^*]|\*[^/])*' + captures: + 0: source.embedded.ts + - match: (?x) ((@)kind) \s+ (class|constant|event|external|file|function|member|mixin|module|namespace|typedef) \b + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: constant.language.symbol-type.jsdoc + - match: |- + (?x) + ((@)see) + \s+ + (?: + # URL + ( + (?=https?://) + (?:[^\s*]|\*[^/])+ + ) + | + # JSDoc namepath + ( + (?! + # Avoid matching bare URIs (also acceptable as links) + https?:// + | + # Avoid matching {@inline tags}; we match those below + (?:\[[^\[\]]*\])? # Possible description [preceding]{@tag} + {@(?:link|linkcode|linkplain|tutorial)\b + ) + # Matched namepath + (?:[^@\s*/]|\*[^/])+ + ) + ) + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: variable.other.link.underline.jsdoc + 4: entity.name.type.instance.jsdoc + - match: |- + (?x) + ((@)template) + \s+ + # One or more valid identifiers + ( + [A-Za-z_$] # First character: non-numeric word character + [\w$.\[\]]* # Rest of identifier + (?: # Possible list of additional identifiers + \s* , \s* + [A-Za-z_$] + [\w$.\[\]]* + )* + ) + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: variable.other.jsdoc + - match: |- + (?x) + ( + (@) + (?:arg|argument|const|constant|member|namespace|param|var) + ) + \s+ + ( + [A-Za-z_$] + [\w$.\[\]]* + ) + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: variable.other.jsdoc + - match: '((@)typedef)\s+(?={)' + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + push: + - match: '(?=\s|\*/|[^{}\[\]A-Za-z_$])' + pop: true + - include: jsdoctype + - match: '(?:[^@\s*/]|\*[^/])+' + scope: entity.name.type.instance.jsdoc + - match: '((@)(?:arg|argument|const|constant|member|namespace|param|prop|property|var))\s+(?={)' + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + push: + - match: '(?=\s|\*/|[^{}\[\]A-Za-z_$])' + pop: true + - include: jsdoctype + - match: '([A-Za-z_$][\w$.\[\]]*)' + scope: variable.other.jsdoc + - match: |- + (?x) + (\[)\s* + [\w$]+ + (?: + (?:\[\])? # Foo[ ].bar properties within an array + \. # Foo.Bar namespaced parameter + [\w$]+ + )* + (?: + \s* + (=) # [foo=bar] Default parameter value + \s* + ( + # The inner regexes are to stop the match early at */ and to not stop at escaped quotes + (?> + "(?:(?:\*(?!/))|(?:\\(?!"))|[^*\\])*?" | # [foo="bar"] Double-quoted + '(?:(?:\*(?!/))|(?:\\(?!'))|[^*\\])*?' | # [foo='bar'] Single-quoted + \[ (?:(?:\*(?!/))|[^*])*? \] | # [foo=[1,2]] Array literal + (?:(?:\*(?!/))|\s(?!\s*\])|\[.*?(?:\]|(?=\*/))|[^*\s\[\]])* # Everything else + )* + ) + )? + \s*(?:(\])((?:[^*\s]|\*[^\s/])+)?|(?=\*/)) + scope: variable.other.jsdoc + captures: + 1: punctuation.definition.optional-value.begin.bracket.square.jsdoc + 2: keyword.operator.assignment.jsdoc + 3: source.embedded.ts + 4: punctuation.definition.optional-value.end.bracket.square.jsdoc + 5: invalid.illegal.syntax.jsdoc + - match: |- + (?x) + ( + (@) + (?:define|enum|exception|export|extends|lends|implements|modifies + |namespace|private|protected|returns?|suppress|this|throws|type + |yields?) + ) + \s+(?={) + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + push: + - match: '(?=\s|\*/|[^{}\[\]A-Za-z_$])' + pop: true + - include: jsdoctype + - match: |- + (?x) + ( + (@) + (?:alias|augments|callback|constructs|emits|event|fires|exports? + |extends|external|function|func|host|lends|listens|interface|memberof!? + |method|module|mixes|mixin|name|requires|see|this|typedef|uses) + ) + \s+ + ( + (?: + [^{}@\s*] | \*[^/] + )+ + ) + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: entity.name.type.instance.jsdoc + - match: '((@)(?:default(?:value)?|license|version))\s+(([''''"]))' + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: variable.other.jsdoc + 4: punctuation.definition.string.begin.jsdoc + push: + - meta_content_scope: variable.other.jsdoc + - match: (\3)|(?=$|\*/) + captures: + 0: variable.other.jsdoc + 1: punctuation.definition.string.end.jsdoc + pop: true + - match: '((@)(?:default(?:value)?|license|tutorial|variation|version))\s+([^\s*]+)' + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: variable.other.jsdoc + - match: '(?x) (@) (?:abstract|access|alias|api|arg|argument|async|attribute|augments|author|beta|borrows|bubbles |callback|chainable|class|classdesc|code|config|const|constant|constructor|constructs|copyright |default|defaultvalue|define|deprecated|desc|description|dict|emits|enum|event|example|exception |exports?|extends|extension(?:_?for)?|external|externs|file|fileoverview|final|fires|for|func |function|generator|global|hideconstructor|host|ignore|implements|implicitCast|inherit[Dd]oc |inner|instance|interface|internal|kind|lends|license|listens|main|member|memberof!?|method |mixes|mixins?|modifies|module|name|namespace|noalias|nocollapse|nocompile|nosideeffects |override|overview|package|param|polymer(?:Behavior)?|preserve|private|prop|property|protected |public|read[Oo]nly|record|require[ds]|returns?|see|since|static|struct|submodule|summary |suppress|template|this|throws|todo|tutorial|type|typedef|unrestricted|uses|var|variation |version|virtual|writeOnce|yields?) \b' + scope: storage.type.class.jsdoc + captures: + 1: punctuation.definition.block.tag.jsdoc + - include: inline-tags + - match: '((@)(?:[_$[:alpha:]][_$[:alnum:]]*))(?=\s+)' + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + enum-declaration: + - match: '(?) + )) | + ((async\s*)?( + ((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + )) | + # typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) => + (:\s*( + (<) | + ([(]\s*( + ([)]) | + (\.\.\.) | + ([_$[:alnum:]]+\s*( + ([:,?=])| + ([)]\s*=>) + )) + )) + )) | + (:\s*(?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) | + (:\s*(=>|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*( + ((async\s+)?( + (function\s*[(<*]) | + (function\s+) | + ([_$[:alpha:]][_$[:alnum:]]*\s*=>) + )) | + ((async\s*)?( + ((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + ))) + captures: + 1: storage.modifier.ts + 2: keyword.operator.rest.ts + 3: entity.name.function.ts variable.language.this.ts + 4: entity.name.function.ts + 5: keyword.operator.optional.ts + - match: '(?x)(?:(?>=|>>>=|\|= + scope: keyword.operator.assignment.compound.bitwise.ts + - match: "<<|>>>|>>" + scope: keyword.operator.bitwise.shift.ts + - match: "===|!==|==|!=" + scope: keyword.operator.comparison.ts + - match: <=|>=|<>|<|> + scope: keyword.operator.relational.ts + - match: '(\!)\s*(/)(?![/*])' + captures: + 1: keyword.operator.logical.ts + 2: keyword.operator.arithmetic.ts + - match: \!|&&|\|\||\?\? + scope: keyword.operator.logical.ts + - match: \&|~|\^|\| + scope: keyword.operator.bitwise.ts + - match: \= + scope: keyword.operator.assignment.ts + - match: "--" + scope: keyword.operator.decrement.ts + - match: \+\+ + scope: keyword.operator.increment.ts + - match: '%|\*|/|-|\+' + scope: keyword.operator.arithmetic.ts + - match: '(?<=[_$[:alnum:])\]])\s*(?=(\/\*([^\*]|(\*[^\/]))*\*\/\s*)+(/)(?![/*]))' + push: + - match: '(/)(?!\*([^\*]|(\*[^\/]))*\*\/)' + captures: + 1: keyword.operator.arithmetic.ts + pop: true + - include: comment + - match: '(?<=[_$[:alnum:])\]])\s*(/)(?![/*])' + captures: + 1: keyword.operator.arithmetic.ts + expressionPunctuations: + - include: punctuation-comma + - include: punctuation-accessor + expressionWithoutIdentifiers: + - include: string + - include: regex + - include: comment + - include: function-expression + - include: class-expression + - include: arrow-function + - include: paren-expression-possibly-arrow + - include: cast + - include: ternary-expression + - include: new-expr + - include: instanceof-expr + - include: object-literal + - include: expression-operators + - include: function-call + - include: literal + - include: support-objects + - include: paren-expression + field-declaration: + - match: |- + (?x)(?) + )) | + ((async\s*)?( + ((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + )) | + # typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) => + (:\s*( + (<) | + ([(]\s*( + ([)]) | + (\.\.\.) | + ([_$[:alnum:]]+\s*( + ([:,?=])| + ([)]\s*=>) + )) + )) + )) | + (:\s*(?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) | + (:\s*(=>|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*( + ((async\s+)?( + (function\s*[(<*]) | + (function\s+) | + ([_$[:alpha:]][_$[:alnum:]]*\s*=>) + )) | + ((async\s*)?( + ((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + ))) + captures: + 1: meta.definition.property.ts entity.name.function.ts + 2: keyword.operator.optional.ts + 3: keyword.operator.definiteassignment.ts + - match: '\#?[_$[:alpha:]][_$[:alnum:]]*' + scope: meta.definition.property.ts variable.object.property.ts + - match: \? + scope: keyword.operator.optional.ts + - match: \! + scope: keyword.operator.definiteassignment.ts + for-loop: + - match: '(?\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)?\()' + push: + - match: '(?<=\))(?!(((([_$[:alpha:]][_$[:alnum:]]*)(\s*\??\.\s*(\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\??\.\s*\#?[_$[:alpha:]][_$[:alnum:]]*))|(?<=[\)]))\s*(?:(\?\.\s*)|(\!))?(<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)?\()' + pop: true + - match: '(?=(([_$[:alpha:]][_$[:alnum:]]*)(\s*\??\.\s*(\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\??\.\s*\#?[_$[:alpha:]][_$[:alnum:]]*))' + push: + - meta_scope: meta.function-call.ts + - match: '(?=\s*(?:(\?\.\s*)|(\!))?(<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)?\()' + pop: true + - include: support-function-call-identifiers + - match: '(\#?[_$[:alpha:]][_$[:alnum:]]*)' + scope: entity.name.function.ts + - include: comment + - match: \?\. + scope: meta.function-call.ts punctuation.accessor.optional.ts + - match: \! + scope: meta.function-call.ts keyword.operator.definiteassignment.ts + - include: type-arguments + - include: paren-expression + function-declaration: + - match: '(?) + )) | + ((async\s*)?( + ((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + )) + captures: + 1: punctuation.accessor.ts + 2: punctuation.accessor.optional.ts + 3: entity.name.function.ts + - match: '(?:(\.)|(\?\.(?!\s*[[:digit:]])))\s*(\#?[[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])' + captures: + 1: punctuation.accessor.ts + 2: punctuation.accessor.optional.ts + 3: variable.other.constant.property.ts + - match: '(?:(\.)|(\?\.(?!\s*[[:digit:]])))\s*(\#?[_$[:alpha:]][_$[:alnum:]]*)' + captures: + 1: punctuation.accessor.ts + 2: punctuation.accessor.optional.ts + 3: variable.other.property.ts + - match: "([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])" + scope: variable.other.constant.ts + - match: "[_$[:alpha:]][_$[:alnum:]]*" + scope: variable.other.readwrite.ts + if-statement: + - match: '(?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?[\(])' + captures: + 1: storage.modifier.ts + 2: storage.modifier.ts + 3: storage.modifier.async.ts + 4: keyword.operator.new.ts + 5: keyword.generator.asterisk.ts + push: + - meta_scope: meta.method.declaration.ts + - match: '(?=\}|;|,|$)|(?<=\})' + pop: true + - include: method-declaration-name + - include: function-body + - match: |- + (?x)(?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?[\(]) + captures: + 1: storage.modifier.ts + 2: storage.modifier.ts + 3: storage.modifier.async.ts + 4: storage.type.property.ts + 5: keyword.generator.asterisk.ts + push: + - meta_scope: meta.method.declaration.ts + - match: '(?=\}|;|,|$)|(?<=\})' + pop: true + - include: method-declaration-name + - include: function-body + method-declaration-name: + - match: |- + (?x)(?=((\b(?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?[\(]) + captures: + 1: storage.modifier.async.ts + 2: storage.type.property.ts + 3: keyword.generator.asterisk.ts + push: + - meta_scope: meta.method.declaration.ts + - match: '(?=\}|;|,)|(?<=\})' + pop: true + - include: method-declaration-name + - include: function-body + - match: |- + (?x)(?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?[\(]) + captures: + 1: storage.modifier.async.ts + 2: storage.type.property.ts + 3: keyword.generator.asterisk.ts + push: + - match: (?=\(|\<) + pop: true + - include: method-declaration-name + object-member: + - include: comment + - include: object-literal-method-declaration + - match: '(?=\[)' + push: + - meta_scope: meta.object.member.ts meta.object-literal.key.ts + - match: '(?=:)|((?<=[\]])(?=\s*[\(\<]))' + pop: true + - include: comment + - include: array-literal + - match: '(?=[\''\"\`])' + push: + - meta_scope: meta.object.member.ts meta.object-literal.key.ts + - match: '(?=:)|((?<=[\''\"\`])(?=((\s*[\(\<,}])|(\s+(as)\s+))))' + pop: true + - include: comment + - include: string + - match: |- + (?x)(?=(\b(?) + )) | + ((async\s*)?( + ((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + ))) + scope: meta.object.member.ts + captures: + 0: meta.object-literal.key.ts + 1: entity.name.function.ts + - match: '(?:[_$[:alpha:]][_$[:alnum:]]*)\s*(?=(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*:)' + scope: meta.object.member.ts + captures: + 0: meta.object-literal.key.ts + - match: \.\.\. + captures: + 0: keyword.operator.spread.ts + push: + - meta_scope: meta.object.member.ts + - match: '(?=,|\})' + pop: true + - include: expression + - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(?=,|\}|$|\/\/|\/\*)' + scope: meta.object.member.ts + captures: + 1: variable.other.readwrite.ts + - match: '(?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)\(\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))' + captures: + 1: storage.modifier.async.ts + push: + - match: (?<=\)) + pop: true + - include: type-parameters + - match: \( + captures: + 0: meta.brace.round.ts + push: + - match: \) + captures: + 0: meta.brace.round.ts + pop: true + - include: expression-inside-possibly-arrow-parens + - match: '(?<=:)\s*(async)?\s*(\()(?=\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))' + captures: + 1: storage.modifier.async.ts + 2: meta.brace.round.ts + push: + - match: \) + captures: + 0: meta.brace.round.ts + pop: true + - include: expression-inside-possibly-arrow-parens + - match: (?<=:)\s*(async)?\s*(?=\<\s*$) + captures: + 1: storage.modifier.async.ts + push: + - match: (?<=\>) + pop: true + - include: type-parameters + - match: '(?<=\>)\s*(\()(?=\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))' + captures: + 1: meta.brace.round.ts + push: + - match: \) + captures: + 0: meta.brace.round.ts + pop: true + - include: expression-inside-possibly-arrow-parens + - include: possibly-arrow-return-type + - include: expression + - include: punctuation-comma + parameter-array-binding-pattern: + - match: '(?:(\.\.\.)\s*)?(\[)' + captures: + 1: keyword.operator.rest.ts + 2: punctuation.definition.binding-pattern.array.ts + push: + - match: '\]' + captures: + 0: punctuation.definition.binding-pattern.array.ts + pop: true + - include: parameter-binding-element + - include: punctuation-comma + parameter-binding-element: + - include: comment + - include: string + - include: numeric-literal + - include: regex + - include: parameter-object-binding-pattern + - include: parameter-array-binding-pattern + - include: destructuring-parameter-rest + - include: variable-initializer + parameter-name: + - match: '(?) + )) | + ((async\s*)?( + ((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + )) | + # typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) => + (:\s*( + (<) | + ([(]\s*( + ([)]) | + (\.\.\.) | + ([_$[:alnum:]]+\s*( + ([:,?=])| + ([)]\s*=>) + )) + )) + )) | + (:\s*(?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) | + (:\s*(=>|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*( + ((async\s+)?( + (function\s*[(<*]) | + (function\s+) | + ([_$[:alpha:]][_$[:alnum:]]*\s*=>) + )) | + ((async\s*)?( + ((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + ))) + captures: + 1: storage.modifier.ts + 2: keyword.operator.rest.ts + 3: entity.name.function.ts variable.language.this.ts + 4: entity.name.function.ts + 5: keyword.operator.optional.ts + - match: '(?x)(?:(?])" + pop: true + - include: type + paren-expression: + - match: \( + captures: + 0: meta.brace.round.ts + push: + - match: \) + captures: + 0: meta.brace.round.ts + pop: true + - include: expression + paren-expression-possibly-arrow: + - match: '(?<=[(=,])\s*(async)?(?=\s*((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?\(\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))' + captures: + 1: storage.modifier.async.ts + push: + - match: (?<=\)) + pop: true + - include: paren-expression-possibly-arrow-with-typeparameters + - match: '(?<=[(=,]|=>|^return|[^\._$[:alnum:]]return)\s*(async)?(?=\s*((((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?\()|(<))\s*$)' + captures: + 1: storage.modifier.async.ts + push: + - match: (?<=\)) + pop: true + - include: paren-expression-possibly-arrow-with-typeparameters + - include: possibly-arrow-return-type + paren-expression-possibly-arrow-with-typeparameters: + - include: type-parameters + - match: \( + captures: + 0: meta.brace.round.ts + push: + - match: \) + captures: + 0: meta.brace.round.ts + pop: true + - include: expression-inside-possibly-arrow-parens + possibly-arrow-return-type: + - match: '(?<=\)|^)\s*(:)(?=\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*=>)' + captures: + 1: meta.arrow.ts meta.return.type.arrow.ts keyword.operator.type.annotation.ts + push: + - meta_content_scope: meta.arrow.ts meta.return.type.arrow.ts + - match: '(?==>|\{|(^\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\s+))' + pop: true + - include: arrow-return-type-body + property-accessor: + - match: '(?|&&|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[\()]|\\.|\[([^\]\\]|\\.)+\]|\(([^\)\\]|\\.)+\))+\/([gimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$]))' + captures: + 1: punctuation.definition.string.begin.ts + push: + - meta_scope: string.regexp.ts + - match: "(/)([gimsuy]*)" + captures: + 1: punctuation.definition.string.end.ts + 2: keyword.other.ts + pop: true + - include: regexp + - match: '((?' + captures: + 0: keyword.other.back-reference.regexp + 1: variable.other.regexp + - match: '[?+*]|\{(\d+,\d+|\d+,|,\d+|\d+)\}\??' + scope: keyword.operator.quantifier.regexp + - match: \| + scope: keyword.operator.or.regexp + - match: (\()((\?=)|(\?!)|(\?<=)|(\?))?' + captures: + 0: punctuation.definition.group.regexp + 1: punctuation.definition.group.no-capture.regexp + 2: variable.other.regexp + push: + - meta_scope: meta.group.regexp + - match: \) + captures: + 0: punctuation.definition.group.regexp + pop: true + - include: regexp + - match: '(\[)(\^)?' + captures: + 1: punctuation.definition.character-class.regexp + 2: keyword.operator.negation.regexp + push: + - meta_scope: constant.other.character-class.set.regexp + - match: '(\])' + captures: + 1: punctuation.definition.character-class.regexp + pop: true + - match: '(?:.|(\\(?:[0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}))|(\\c[A-Z])|(\\.))\-(?:[^\]\\]|(\\(?:[0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}))|(\\c[A-Z])|(\\.))' + scope: constant.other.character-class.range.regexp + captures: + 1: constant.character.numeric.regexp + 2: constant.character.control.regexp + 3: constant.character.escape.backslash.regexp + 4: constant.character.numeric.regexp + 5: constant.character.control.regexp + 6: constant.character.escape.backslash.regexp + - include: regex-character-class + - include: regex-character-class + return-type: + - match: (?<=\))\s*(:)(?=\s*\S) + captures: + 1: keyword.operator.type.annotation.ts + push: + - meta_scope: meta.return.type.ts + - match: "(?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?\()) + | + (?:(EPSILON|MAX_SAFE_INTEGER|MAX_VALUE|MIN_SAFE_INTEGER|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY)\b(?!\$))) + captures: + 1: punctuation.accessor.ts + 2: punctuation.accessor.optional.ts + 3: support.variable.property.ts + 4: support.constant.ts + - match: |- + (?x) (?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?\() + captures: + 1: punctuation.accessor.ts + 2: punctuation.accessor.optional.ts + 3: support.constant.dom.ts + 4: support.variable.property.dom.ts + - match: |- + (?x)(?\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)?`)' + push: + - meta_scope: string.template.ts + - match: (?=`) + pop: true + - match: '(?=(([_$[:alpha:]][_$[:alnum:]]*\s*\??\.\s*)*|(\??\.\s*)?)([_$[:alpha:]][_$[:alnum:]]*))' + push: + - match: '(?=(<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)?`)' + pop: true + - include: support-function-call-identifiers + - match: "([_$[:alpha:]][_$[:alnum:]]*)" + scope: entity.name.function.tagged-template.ts + - include: type-arguments + - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(?=(<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)`)' + captures: + 1: entity.name.function.tagged-template.ts + push: + - meta_scope: string.template.ts + - match: (?=`) + pop: true + - include: type-arguments + - match: "([_$[:alpha:]][_$[:alnum:]]*)?(`)" + captures: + 1: entity.name.function.tagged-template.ts + 2: punctuation.definition.string.template.begin.ts + push: + - meta_scope: string.template.ts + - match: "`" + captures: + 0: punctuation.definition.string.template.end.ts + pop: true + - include: template-substitution-element + - include: string-character-escape + template-substitution-element: + - match: '\$\{' + captures: + 0: punctuation.definition.template-expression.begin.ts + push: + - meta_scope: meta.template.expression.ts + - meta_content_scope: meta.embedded.line.ts + - match: '\}' + captures: + 0: punctuation.definition.template-expression.end.ts + pop: true + - include: expression + ternary-expression: + - match: '(?!\?\.\s*[^[:digit:]])(\?)(?!\?)' + captures: + 1: keyword.operator.ternary.ts + push: + - match: \s*(:) + captures: + 1: keyword.operator.ternary.ts + pop: true + - include: expression + this-literal: + - match: '(?])|((?<=[\}>\]\)]|[_$[:alpha:]])\s*(?=\{)))' + pop: true + - include: type + - match: (:) + captures: + 1: keyword.operator.type.annotation.ts + push: + - meta_scope: meta.type.annotation.ts + - match: '(?])|(?=^\s*$)|((?<=\S)(?=\s*$))|((?<=[\}>\]\)]|[_$[:alpha:]])\s*(?=\{)))' + pop: true + - include: type + type-arguments: + - match: \< + captures: + 0: punctuation.definition.typeparameters.begin.ts + push: + - meta_scope: meta.type.parameters.ts + - match: \> + captures: + 0: punctuation.definition.typeparameters.end.ts + pop: true + - include: type-arguments-body + type-arguments-body: + - match: '(?) + pop: true + - include: comment + - include: type-parameters + - match: '(?) + )) + ) + ) + ) + push: + - meta_scope: meta.type.function.ts + - match: (?<=\)) + pop: true + - include: function-parameters + type-function-return-type: + - match: (=>)(?=\s*\S) + captures: + 1: storage.type.function.arrow.ts + push: + - meta_scope: meta.type.function.return.ts + - match: '(?)(?:\?]|//|$)' + pop: true + - include: type-function-return-type-core + - match: "=>" + captures: + 0: storage.type.function.arrow.ts + push: + - meta_scope: meta.type.function.return.ts + - match: '(?)(?]|//|^\s*$)|((?<=\S)(?=\s*$)))' + pop: true + - include: type-function-return-type-core + type-function-return-type-core: + - include: comment + - match: '(?<==>)(?=\s*\{)' + push: + - match: '(?<=\})' + pop: true + - include: type-object + - include: type-predicate-operator + - include: type + type-name: + - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(?:(\.)|(\?\.(?!\s*[[:digit:]])))\s*(<)' + captures: + 1: entity.name.type.module.ts + 2: punctuation.accessor.ts + 3: punctuation.accessor.optional.ts + 4: meta.type.parameters.ts punctuation.definition.typeparameters.begin.ts + push: + - meta_content_scope: meta.type.parameters.ts + - match: (>) + captures: + 1: meta.type.parameters.ts punctuation.definition.typeparameters.end.ts + pop: true + - include: type-arguments-body + - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(<)' + captures: + 1: entity.name.type.ts + 2: meta.type.parameters.ts punctuation.definition.typeparameters.begin.ts + push: + - meta_content_scope: meta.type.parameters.ts + - match: (>) + captures: + 1: meta.type.parameters.ts punctuation.definition.typeparameters.end.ts + pop: true + - include: type-arguments-body + - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(?:(\.)|(\?\.(?!\s*[[:digit:]])))' + captures: + 1: entity.name.type.module.ts + 2: punctuation.accessor.ts + 3: punctuation.accessor.optional.ts + - match: "[_$[:alpha:]][_$[:alnum:]]*" + scope: entity.name.type.ts + type-object: + - match: '\{' + captures: + 0: punctuation.definition.block.ts + push: + - meta_scope: meta.object.type.ts + - match: '\}' + captures: + 0: punctuation.definition.block.ts + pop: true + - include: comment + - include: method-declaration + - include: indexer-declaration + - include: indexer-mapped-type-declaration + - include: field-declaration + - include: type-annotation + - match: \.\.\. + captures: + 0: keyword.operator.spread.ts + push: + - match: '(?=\}|;|,|$)|(?<=\})' + pop: true + - include: type + - include: punctuation-comma + - include: punctuation-semicolon + - include: type + type-operators: + - include: typeof-operator + - match: '([&|])(?=\s*\{)' + captures: + 0: keyword.operator.type.ts + push: + - match: '(?<=\})' + pop: true + - include: type-object + - match: "[&|]" + captures: + 0: keyword.operator.type.ts + push: + - match: (?=\S) + pop: true + - match: '(?) + captures: + 1: punctuation.definition.typeparameters.end.ts + pop: true + - include: comment + - match: '(?) + scope: keyword.operator.assignment.ts + type-paren-or-function-parameters: + - match: \( + captures: + 0: meta.brace.round.ts + push: + - meta_scope: meta.type.paren.cover.ts + - match: \) + captures: + 0: meta.brace.round.ts + pop: true + - match: |- + (?x)(?:(?) + )) + )) + )) | + (:\s*(?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))))) + captures: + 1: storage.modifier.ts + 2: keyword.operator.rest.ts + 3: entity.name.function.ts variable.language.this.ts + 4: entity.name.function.ts + 5: keyword.operator.optional.ts + - match: '(?x)(?:(?) + )) | + ((async\s*)?( + ((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + )) | + # typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) => + (:\s*( + (<) | + ([(]\s*( + ([)]) | + (\.\.\.) | + ([_$[:alnum:]]+\s*( + ([:,?=])| + ([)]\s*=>) + )) + )) + )) | + (:\s*(?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) | + (:\s*(=>|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*( + ((async\s+)?( + (function\s*[(<*]) | + (function\s+) | + ([_$[:alpha:]][_$[:alnum:]]*\s*=>) + )) | + ((async\s*)?( + ((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + ))) + captures: + 1: meta.definition.variable.ts variable.other.constant.ts entity.name.function.ts + push: + - meta_scope: meta.var-single-variable.expr.ts + - match: '(?=$|^|[;,=}]|((?) + )) | + ((async\s*)?( + ((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + )) | + # typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) => + (:\s*( + (<) | + ([(]\s*( + ([)]) | + (\.\.\.) | + ([_$[:alnum:]]+\s*( + ([:,?=])| + ([)]\s*=>) + )) + )) + )) | + (:\s*(?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) | + (:\s*(=>|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*( + ((async\s+)?( + (function\s*[(<*]) | + (function\s+) | + ([_$[:alpha:]][_$[:alnum:]]*\s*=>) + )) | + ((async\s*)?( + ((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?[\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + ))) + captures: + 1: meta.definition.variable.ts entity.name.function.ts + 2: keyword.operator.definiteassignment.ts + push: + - meta_scope: meta.var-single-variable.expr.ts + - match: '(?=$|^|[;,=}]|((?\s*$) + captures: + 1: keyword.operator.assignment.ts + push: + - match: '(?=$|^|[,);}\]]|((?]|^await|[^\._$[:alnum:]]await|^return|[^\._$[:alnum:]]return|^yield|[^\._$[:alnum:]]yield|^throw|[^\._$[:alnum:]]throw|^in|[^\._$[:alnum:]]in|^of|[^\._$[:alnum:]]of|^typeof|[^\._$[:alnum:]]typeof|&&|\|\||\*)\s*(\{)' + captures: + 1: punctuation.definition.block.tsx + push: + - meta_scope: meta.objectliteral.tsx + - match: '\}' + captures: + 0: punctuation.definition.block.tsx + pop: true + - include: object-member + array-binding-pattern: + - match: '(?:(\.\.\.)\s*)?(\[)' + captures: + 1: keyword.operator.rest.tsx + 2: punctuation.definition.binding-pattern.array.tsx + push: + - match: '\]' + captures: + 0: punctuation.definition.binding-pattern.array.tsx + pop: true + - include: binding-element + - include: punctuation-comma + array-binding-pattern-const: + - match: '(?:(\.\.\.)\s*)?(\[)' + captures: + 1: keyword.operator.rest.tsx + 2: punctuation.definition.binding-pattern.array.tsx + push: + - match: '\]' + captures: + 0: punctuation.definition.binding-pattern.array.tsx + pop: true + - include: binding-element-const + - include: punctuation-comma + array-literal: + - match: '\s*(\[)' + captures: + 1: meta.brace.square.tsx + push: + - meta_scope: meta.array.literal.tsx + - match: '\]' + captures: + 0: meta.brace.square.tsx + pop: true + - include: expression + - include: punctuation-comma + arrow-function: + - match: '(?:(?)' + scope: meta.arrow.tsx + captures: + 1: storage.modifier.async.tsx + 2: variable.parameter.tsx + - match: |- + (?x) (?: + (? is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + ( + [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends + ) | + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + ) + ) + captures: + 1: storage.modifier.async.tsx + push: + - meta_scope: meta.arrow.tsx + - match: '(?==>|\{|(^\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\s+))' + pop: true + - include: comment + - include: type-parameters + - include: function-parameters + - include: arrow-return-type + - include: possibly-arrow-return-type + - match: "=>" + captures: + 0: storage.type.function.arrow.tsx + push: + - meta_scope: meta.arrow.tsx + - match: '((?<=\}|\S)(?)|((?!\{)(?=\S)))(?!\/[\/\*])' + pop: true + - include: single-line-comment-consuming-line-ending + - include: decl-block + - include: expression + arrow-return-type: + - match: (?<=\))\s*(:) + captures: + 1: keyword.operator.type.annotation.tsx + push: + - meta_scope: meta.return.type.arrow.tsx + - match: '(?==>|\{|(^\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\s+))' + pop: true + - include: arrow-return-type-body + arrow-return-type-body: + - match: '(?<=[:])(?=\s*\{)' + push: + - match: '(?<=\})' + pop: true + - include: type-object + - include: type-predicate-operator + - include: type + async-modifier: + - match: '(?\s*$)' + captures: + 1: punctuation.definition.comment.tsx + push: + - meta_scope: comment.line.triple-slash.directive.tsx + - match: (?=$) + pop: true + - match: (<)(reference|amd-dependency|amd-module) + captures: + 1: punctuation.definition.tag.directive.tsx + 2: entity.name.tag.directive.tsx + push: + - meta_scope: meta.tag.tsx + - match: /> + captures: + 0: punctuation.definition.tag.directive.tsx + pop: true + - match: path|types|no-default-lib|lib|name + scope: entity.other.attribute-name.directive.tsx + - match: "=" + scope: keyword.operator.assignment.tsx + - include: string + docblock: + - match: |- + (?x) + ((@)(?:access|api)) + \s+ + (private|protected|public) + \b + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: constant.language.access-type.jsdoc + - match: |- + (?x) + ((@)author) + \s+ + ( + [^@\s<>*/] + (?:[^@<>*/]|\*[^/])* + ) + (?: + \s* + (<) + ([^>\s]+) + (>) + )? + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: entity.name.type.instance.jsdoc + 4: punctuation.definition.bracket.angle.begin.jsdoc + 5: constant.other.email.link.underline.jsdoc + 6: punctuation.definition.bracket.angle.end.jsdoc + - match: |- + (?x) + ((@)borrows) \s+ + ((?:[^@\s*/]|\*[^/])+) # + \s+ (as) \s+ # as + ((?:[^@\s*/]|\*[^/])+) # + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: entity.name.type.instance.jsdoc + 4: keyword.operator.control.jsdoc + 5: entity.name.type.instance.jsdoc + - match: ((@)example)\s+ + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + push: + - meta_scope: meta.example.jsdoc + - match: (?=@|\*/) + pop: true + - match: ^\s\*\s+ + - match: \G(<)caption(>) + captures: + 0: entity.name.tag.inline.jsdoc + 1: punctuation.definition.bracket.angle.begin.jsdoc + 2: punctuation.definition.bracket.angle.end.jsdoc + push: + - meta_content_scope: constant.other.description.jsdoc + - match: ()|(?=\*/) + captures: + 0: entity.name.tag.inline.jsdoc + 1: punctuation.definition.bracket.angle.begin.jsdoc + 2: punctuation.definition.bracket.angle.end.jsdoc + pop: true + - match: '[^\s@*](?:[^*]|\*[^/])*' + captures: + 0: source.embedded.tsx + - match: (?x) ((@)kind) \s+ (class|constant|event|external|file|function|member|mixin|module|namespace|typedef) \b + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: constant.language.symbol-type.jsdoc + - match: |- + (?x) + ((@)see) + \s+ + (?: + # URL + ( + (?=https?://) + (?:[^\s*]|\*[^/])+ + ) + | + # JSDoc namepath + ( + (?! + # Avoid matching bare URIs (also acceptable as links) + https?:// + | + # Avoid matching {@inline tags}; we match those below + (?:\[[^\[\]]*\])? # Possible description [preceding]{@tag} + {@(?:link|linkcode|linkplain|tutorial)\b + ) + # Matched namepath + (?:[^@\s*/]|\*[^/])+ + ) + ) + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: variable.other.link.underline.jsdoc + 4: entity.name.type.instance.jsdoc + - match: |- + (?x) + ((@)template) + \s+ + # One or more valid identifiers + ( + [A-Za-z_$] # First character: non-numeric word character + [\w$.\[\]]* # Rest of identifier + (?: # Possible list of additional identifiers + \s* , \s* + [A-Za-z_$] + [\w$.\[\]]* + )* + ) + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: variable.other.jsdoc + - match: |- + (?x) + ( + (@) + (?:arg|argument|const|constant|member|namespace|param|var) + ) + \s+ + ( + [A-Za-z_$] + [\w$.\[\]]* + ) + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: variable.other.jsdoc + - match: '((@)typedef)\s+(?={)' + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + push: + - match: '(?=\s|\*/|[^{}\[\]A-Za-z_$])' + pop: true + - include: jsdoctype + - match: '(?:[^@\s*/]|\*[^/])+' + scope: entity.name.type.instance.jsdoc + - match: '((@)(?:arg|argument|const|constant|member|namespace|param|prop|property|var))\s+(?={)' + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + push: + - match: '(?=\s|\*/|[^{}\[\]A-Za-z_$])' + pop: true + - include: jsdoctype + - match: '([A-Za-z_$][\w$.\[\]]*)' + scope: variable.other.jsdoc + - match: |- + (?x) + (\[)\s* + [\w$]+ + (?: + (?:\[\])? # Foo[ ].bar properties within an array + \. # Foo.Bar namespaced parameter + [\w$]+ + )* + (?: + \s* + (=) # [foo=bar] Default parameter value + \s* + ( + # The inner regexes are to stop the match early at */ and to not stop at escaped quotes + (?> + "(?:(?:\*(?!/))|(?:\\(?!"))|[^*\\])*?" | # [foo="bar"] Double-quoted + '(?:(?:\*(?!/))|(?:\\(?!'))|[^*\\])*?' | # [foo='bar'] Single-quoted + \[ (?:(?:\*(?!/))|[^*])*? \] | # [foo=[1,2]] Array literal + (?:(?:\*(?!/))|\s(?!\s*\])|\[.*?(?:\]|(?=\*/))|[^*\s\[\]])* # Everything else + )* + ) + )? + \s*(?:(\])((?:[^*\s]|\*[^\s/])+)?|(?=\*/)) + scope: variable.other.jsdoc + captures: + 1: punctuation.definition.optional-value.begin.bracket.square.jsdoc + 2: keyword.operator.assignment.jsdoc + 3: source.embedded.tsx + 4: punctuation.definition.optional-value.end.bracket.square.jsdoc + 5: invalid.illegal.syntax.jsdoc + - match: |- + (?x) + ( + (@) + (?:define|enum|exception|export|extends|lends|implements|modifies + |namespace|private|protected|returns?|suppress|this|throws|type + |yields?) + ) + \s+(?={) + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + push: + - match: '(?=\s|\*/|[^{}\[\]A-Za-z_$])' + pop: true + - include: jsdoctype + - match: |- + (?x) + ( + (@) + (?:alias|augments|callback|constructs|emits|event|fires|exports? + |extends|external|function|func|host|lends|listens|interface|memberof!? + |method|module|mixes|mixin|name|requires|see|this|typedef|uses) + ) + \s+ + ( + (?: + [^{}@\s*] | \*[^/] + )+ + ) + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: entity.name.type.instance.jsdoc + - match: '((@)(?:default(?:value)?|license|version))\s+(([''''"]))' + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: variable.other.jsdoc + 4: punctuation.definition.string.begin.jsdoc + push: + - meta_content_scope: variable.other.jsdoc + - match: (\3)|(?=$|\*/) + captures: + 0: variable.other.jsdoc + 1: punctuation.definition.string.end.jsdoc + pop: true + - match: '((@)(?:default(?:value)?|license|tutorial|variation|version))\s+([^\s*]+)' + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + 3: variable.other.jsdoc + - match: '(?x) (@) (?:abstract|access|alias|api|arg|argument|async|attribute|augments|author|beta|borrows|bubbles |callback|chainable|class|classdesc|code|config|const|constant|constructor|constructs|copyright |default|defaultvalue|define|deprecated|desc|description|dict|emits|enum|event|example|exception |exports?|extends|extension(?:_?for)?|external|externs|file|fileoverview|final|fires|for|func |function|generator|global|hideconstructor|host|ignore|implements|implicitCast|inherit[Dd]oc |inner|instance|interface|internal|kind|lends|license|listens|main|member|memberof!?|method |mixes|mixins?|modifies|module|name|namespace|noalias|nocollapse|nocompile|nosideeffects |override|overview|package|param|polymer(?:Behavior)?|preserve|private|prop|property|protected |public|read[Oo]nly|record|require[ds]|returns?|see|since|static|struct|submodule|summary |suppress|template|this|throws|todo|tutorial|type|typedef|unrestricted|uses|var|variation |version|virtual|writeOnce|yields?) \b' + scope: storage.type.class.jsdoc + captures: + 1: punctuation.definition.block.tag.jsdoc + - include: inline-tags + - match: '((@)(?:[_$[:alpha:]][_$[:alnum:]]*))(?=\s+)' + captures: + 1: storage.type.class.jsdoc + 2: punctuation.definition.block.tag.jsdoc + enum-declaration: + - match: '(?) + )) | + ((async\s*)?( + ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + ( + [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends + ) | + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + )) | + # typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) => + (:\s*( + (<) | + ([(]\s*( + ([)]) | + (\.\.\.) | + ([_$[:alnum:]]+\s*( + ([:,?=])| + ([)]\s*=>) + )) + )) + )) | + (:\s*(?\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) | + (:\s*(=>|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*( + ((async\s+)?( + (function\s*[(<*]) | + (function\s+) | + ([_$[:alpha:]][_$[:alnum:]]*\s*=>) + )) | + ((async\s*)?( + ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + ( + [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends + ) | + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + ))) + captures: + 1: storage.modifier.tsx + 2: keyword.operator.rest.tsx + 3: entity.name.function.tsx variable.language.this.tsx + 4: entity.name.function.tsx + 5: keyword.operator.optional.tsx + - match: '(?x)(?:(?>=|>>>=|\|= + scope: keyword.operator.assignment.compound.bitwise.tsx + - match: "<<|>>>|>>" + scope: keyword.operator.bitwise.shift.tsx + - match: "===|!==|==|!=" + scope: keyword.operator.comparison.tsx + - match: <=|>=|<>|<|> + scope: keyword.operator.relational.tsx + - match: '(\!)\s*(/)(?![/*])' + captures: + 1: keyword.operator.logical.tsx + 2: keyword.operator.arithmetic.tsx + - match: \!|&&|\|\||\?\? + scope: keyword.operator.logical.tsx + - match: \&|~|\^|\| + scope: keyword.operator.bitwise.tsx + - match: \= + scope: keyword.operator.assignment.tsx + - match: "--" + scope: keyword.operator.decrement.tsx + - match: \+\+ + scope: keyword.operator.increment.tsx + - match: '%|\*|/|-|\+' + scope: keyword.operator.arithmetic.tsx + - match: '(?<=[_$[:alnum:])\]])\s*(?=(\/\*([^\*]|(\*[^\/]))*\*\/\s*)+(/)(?![/*]))' + push: + - match: '(/)(?!\*([^\*]|(\*[^\/]))*\*\/)' + captures: + 1: keyword.operator.arithmetic.tsx + pop: true + - include: comment + - match: '(?<=[_$[:alnum:])\]])\s*(/)(?![/*])' + captures: + 1: keyword.operator.arithmetic.tsx + expressionPunctuations: + - include: punctuation-comma + - include: punctuation-accessor + expressionWithoutIdentifiers: + - include: jsx + - include: string + - include: regex + - include: comment + - include: function-expression + - include: class-expression + - include: arrow-function + - include: paren-expression-possibly-arrow + - include: cast + - include: ternary-expression + - include: new-expr + - include: instanceof-expr + - include: object-literal + - include: expression-operators + - include: function-call + - include: literal + - include: support-objects + - include: paren-expression + field-declaration: + - match: |- + (?x)(?) + )) | + ((async\s*)?( + ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + ( + [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends + ) | + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + )) | + # typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) => + (:\s*( + (<) | + ([(]\s*( + ([)]) | + (\.\.\.) | + ([_$[:alnum:]]+\s*( + ([:,?=])| + ([)]\s*=>) + )) + )) + )) | + (:\s*(?\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) | + (:\s*(=>|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*( + ((async\s+)?( + (function\s*[(<*]) | + (function\s+) | + ([_$[:alpha:]][_$[:alnum:]]*\s*=>) + )) | + ((async\s*)?( + ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + ( + [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends + ) | + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + ))) + captures: + 1: meta.definition.property.tsx entity.name.function.tsx + 2: keyword.operator.optional.tsx + 3: keyword.operator.definiteassignment.tsx + - match: '\#?[_$[:alpha:]][_$[:alnum:]]*' + scope: meta.definition.property.tsx variable.object.property.tsx + - match: \? + scope: keyword.operator.optional.tsx + - match: \! + scope: keyword.operator.definiteassignment.tsx + for-loop: + - match: '(?\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)?\()' + push: + - match: '(?<=\))(?!(((([_$[:alpha:]][_$[:alnum:]]*)(\s*\??\.\s*(\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\??\.\s*\#?[_$[:alpha:]][_$[:alnum:]]*))|(?<=[\)]))\s*(?:(\?\.\s*)|(\!))?(<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)?\()' + pop: true + - match: '(?=(([_$[:alpha:]][_$[:alnum:]]*)(\s*\??\.\s*(\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\??\.\s*\#?[_$[:alpha:]][_$[:alnum:]]*))' + push: + - meta_scope: meta.function-call.tsx + - match: '(?=\s*(?:(\?\.\s*)|(\!))?(<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)?\()' + pop: true + - include: support-function-call-identifiers + - match: '(\#?[_$[:alpha:]][_$[:alnum:]]*)' + scope: entity.name.function.tsx + - include: comment + - match: \?\. + scope: meta.function-call.tsx punctuation.accessor.optional.tsx + - match: \! + scope: meta.function-call.tsx keyword.operator.definiteassignment.tsx + - include: type-arguments + - include: paren-expression + function-declaration: + - match: '(?) + )) | + ((async\s*)?( + ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + ( + [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends + ) | + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + )) + captures: + 1: punctuation.accessor.tsx + 2: punctuation.accessor.optional.tsx + 3: entity.name.function.tsx + - match: '(?:(\.)|(\?\.(?!\s*[[:digit:]])))\s*(\#?[[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])' + captures: + 1: punctuation.accessor.tsx + 2: punctuation.accessor.optional.tsx + 3: variable.other.constant.property.tsx + - match: '(?:(\.)|(\?\.(?!\s*[[:digit:]])))\s*(\#?[_$[:alpha:]][_$[:alnum:]]*)' + captures: + 1: punctuation.accessor.tsx + 2: punctuation.accessor.optional.tsx + 3: variable.other.property.tsx + - match: "([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])" + scope: variable.other.constant.tsx + - match: "[_$[:alpha:]][_$[:alnum:]]*" + scope: variable.other.readwrite.tsx + if-statement: + - match: '(?))' + push: + - meta_scope: meta.tag.tsx + - match: '(/>)|(?:())' + captures: + 1: punctuation.definition.tag.end.tsx + 2: punctuation.definition.tag.begin.tsx + 3: entity.name.tag.namespace.tsx + 4: punctuation.separator.namespace.tsx + 5: entity.name.tag.tsx + 6: support.class.component.tsx + 7: punctuation.definition.tag.end.tsx + pop: true + - match: '(<)\s*(?:([_$[:alpha:]][-_$[:alnum:].]*)(?)' + captures: + 1: punctuation.definition.tag.begin.tsx + 2: entity.name.tag.namespace.tsx + 3: punctuation.separator.namespace.tsx + 4: entity.name.tag.tsx + 5: support.class.component.tsx + push: + - match: "(?=[/]?>)" + pop: true + - include: comment + - include: type-arguments + - include: jsx-tag-attributes + - match: (>) + captures: + 1: punctuation.definition.tag.end.tsx + push: + - meta_content_scope: meta.jsx.children.tsx + - match: (?=|/\*|//) + captures: + 1: entity.other.attribute-name.namespace.tsx + 2: punctuation.separator.namespace.tsx + 3: entity.other.attribute-name.tsx + jsx-tag-attributes: + - match: \s+ + push: + - meta_scope: meta.tag.attributes.tsx + - match: "(?=[/]?>)" + pop: true + - include: comment + - include: jsx-tag-attribute-name + - include: jsx-tag-attribute-assignment + - include: jsx-string-double-quoted + - include: jsx-string-single-quoted + - include: jsx-evaluated-code + - include: jsx-tag-attributes-illegal + jsx-tag-attributes-illegal: + - match: \S+ + scope: invalid.illegal.attribute.tsx + jsx-tag-in-expression: + - match: |- + (?x) + (?:*]|&&|\|\||\?|\*\/|^await|[^\._$[:alnum:]]await|^return|[^\._$[:alnum:]]return|^default|[^\._$[:alnum:]]default|^yield|[^\._$[:alnum:]]yield|^)\s* + (?!<\s*[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s+[^=>])|,)) # look ahead is not type parameter of arrow + (?=(<)\s*(?:([_$[:alpha:]][-_$[:alnum:].]*)(?)) + push: + - match: '(?!(<)\s*(?:([_$[:alpha:]][-_$[:alnum:].]*)(?))' + pop: true + - include: jsx-tag + jsx-tag-without-attributes: + - match: '(<)\s*(?:([_$[:alpha:]][-_$[:alnum:].]*)(?)' + captures: + 1: punctuation.definition.tag.begin.tsx + 2: entity.name.tag.namespace.tsx + 3: punctuation.separator.namespace.tsx + 4: entity.name.tag.tsx + 5: support.class.component.tsx + 6: punctuation.definition.tag.end.tsx + push: + - meta_scope: meta.tag.without-attributes.tsx + - meta_content_scope: meta.jsx.children.tsx + - match: '()' + captures: + 1: punctuation.definition.tag.begin.tsx + 2: entity.name.tag.namespace.tsx + 3: punctuation.separator.namespace.tsx + 4: entity.name.tag.tsx + 5: support.class.component.tsx + 6: punctuation.definition.tag.end.tsx + pop: true + - include: jsx-children + jsx-tag-without-attributes-in-expression: + - match: '(?:*]|&&|\|\||\?|\*\/|^await|[^\._$[:alnum:]]await|^return|[^\._$[:alnum:]]return|^default|[^\._$[:alnum:]]default|^yield|[^\._$[:alnum:]]yield|^)\s*(?=(<)\s*(?:([_$[:alpha:]][-_$[:alnum:].]*)(?))' + push: + - match: '(?!(<)\s*(?:([_$[:alpha:]][-_$[:alnum:].]*)(?))' + pop: true + - include: jsx-tag-without-attributes + label: + - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(:)(?=\s*\{)' + captures: + 1: entity.name.label.tsx + 2: punctuation.separator.label.tsx + push: + - match: '(?<=\})' + pop: true + - include: decl-block + - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(:)' + captures: + 1: entity.name.label.tsx + 2: punctuation.separator.label.tsx + literal: + - include: numeric-literal + - include: boolean-literal + - include: null-literal + - include: undefined-literal + - include: numericConstant-literal + - include: array-literal + - include: this-literal + - include: super-literal + method-declaration: + - match: '(?x)(?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?[\(])' + captures: + 1: storage.modifier.tsx + 2: storage.modifier.tsx + 3: storage.modifier.async.tsx + 4: keyword.operator.new.tsx + 5: keyword.generator.asterisk.tsx + push: + - meta_scope: meta.method.declaration.tsx + - match: '(?=\}|;|,|$)|(?<=\})' + pop: true + - include: method-declaration-name + - include: function-body + - match: |- + (?x)(?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?[\(]) + captures: + 1: storage.modifier.tsx + 2: storage.modifier.tsx + 3: storage.modifier.async.tsx + 4: storage.type.property.tsx + 5: keyword.generator.asterisk.tsx + push: + - meta_scope: meta.method.declaration.tsx + - match: '(?=\}|;|,|$)|(?<=\})' + pop: true + - include: method-declaration-name + - include: function-body + method-declaration-name: + - match: |- + (?x)(?=((\b(?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?[\(]) + captures: + 1: storage.modifier.async.tsx + 2: storage.type.property.tsx + 3: keyword.generator.asterisk.tsx + push: + - meta_scope: meta.method.declaration.tsx + - match: '(?=\}|;|,)|(?<=\})' + pop: true + - include: method-declaration-name + - include: function-body + - match: |- + (?x)(?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?[\(]) + captures: + 1: storage.modifier.async.tsx + 2: storage.type.property.tsx + 3: keyword.generator.asterisk.tsx + push: + - match: (?=\(|\<) + pop: true + - include: method-declaration-name + object-member: + - include: comment + - include: object-literal-method-declaration + - match: '(?=\[)' + push: + - meta_scope: meta.object.member.tsx meta.object-literal.key.tsx + - match: '(?=:)|((?<=[\]])(?=\s*[\(\<]))' + pop: true + - include: comment + - include: array-literal + - match: '(?=[\''\"\`])' + push: + - meta_scope: meta.object.member.tsx meta.object-literal.key.tsx + - match: '(?=:)|((?<=[\''\"\`])(?=((\s*[\(\<,}])|(\s+(as)\s+))))' + pop: true + - include: comment + - include: string + - match: |- + (?x)(?=(\b(?) + )) | + ((async\s*)?( + ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + ( + [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends + ) | + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + ))) + scope: meta.object.member.tsx + captures: + 0: meta.object-literal.key.tsx + 1: entity.name.function.tsx + - match: '(?:[_$[:alpha:]][_$[:alnum:]]*)\s*(?=(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*:)' + scope: meta.object.member.tsx + captures: + 0: meta.object-literal.key.tsx + - match: \.\.\. + captures: + 0: keyword.operator.spread.tsx + push: + - meta_scope: meta.object.member.tsx + - match: '(?=,|\})' + pop: true + - include: expression + - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(?=,|\}|$|\/\/|\/\*)' + scope: meta.object.member.tsx + captures: + 1: variable.other.readwrite.tsx + - match: '(?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)\(\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))' + captures: + 1: storage.modifier.async.tsx + push: + - match: (?<=\)) + pop: true + - include: type-parameters + - match: \( + captures: + 0: meta.brace.round.tsx + push: + - match: \) + captures: + 0: meta.brace.round.tsx + pop: true + - include: expression-inside-possibly-arrow-parens + - match: '(?<=:)\s*(async)?\s*(\()(?=\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))' + captures: + 1: storage.modifier.async.tsx + 2: meta.brace.round.tsx + push: + - match: \) + captures: + 0: meta.brace.round.tsx + pop: true + - include: expression-inside-possibly-arrow-parens + - match: (?<=:)\s*(async)?\s*(?=\<\s*$) + captures: + 1: storage.modifier.async.tsx + push: + - match: (?<=\>) + pop: true + - include: type-parameters + - match: '(?<=\>)\s*(\()(?=\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))' + captures: + 1: meta.brace.round.tsx + push: + - match: \) + captures: + 0: meta.brace.round.tsx + pop: true + - include: expression-inside-possibly-arrow-parens + - include: possibly-arrow-return-type + - include: expression + - include: punctuation-comma + parameter-array-binding-pattern: + - match: '(?:(\.\.\.)\s*)?(\[)' + captures: + 1: keyword.operator.rest.tsx + 2: punctuation.definition.binding-pattern.array.tsx + push: + - match: '\]' + captures: + 0: punctuation.definition.binding-pattern.array.tsx + pop: true + - include: parameter-binding-element + - include: punctuation-comma + parameter-binding-element: + - include: comment + - include: string + - include: numeric-literal + - include: regex + - include: parameter-object-binding-pattern + - include: parameter-array-binding-pattern + - include: destructuring-parameter-rest + - include: variable-initializer + parameter-name: + - match: '(?) + )) | + ((async\s*)?( + ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + ( + [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends + ) | + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + )) | + # typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) => + (:\s*( + (<) | + ([(]\s*( + ([)]) | + (\.\.\.) | + ([_$[:alnum:]]+\s*( + ([:,?=])| + ([)]\s*=>) + )) + )) + )) | + (:\s*(?\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) | + (:\s*(=>|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*( + ((async\s+)?( + (function\s*[(<*]) | + (function\s+) | + ([_$[:alpha:]][_$[:alnum:]]*\s*=>) + )) | + ((async\s*)?( + ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + ( + [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends + ) | + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + ))) + captures: + 1: storage.modifier.tsx + 2: keyword.operator.rest.tsx + 3: entity.name.function.tsx variable.language.this.tsx + 4: entity.name.function.tsx + 5: keyword.operator.optional.tsx + - match: '(?x)(?:(?])" + pop: true + - include: type + paren-expression: + - match: \( + captures: + 0: meta.brace.round.tsx + push: + - match: \) + captures: + 0: meta.brace.round.tsx + pop: true + - include: expression + paren-expression-possibly-arrow: + - match: '(?<=[(=,])\s*(async)?(?=\s*((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?\(\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))' + captures: + 1: storage.modifier.async.tsx + push: + - match: (?<=\)) + pop: true + - include: paren-expression-possibly-arrow-with-typeparameters + - match: '(?<=[(=,]|=>|^return|[^\._$[:alnum:]]return)\s*(async)?(?=\s*((((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*))?\()|(<))\s*$)' + captures: + 1: storage.modifier.async.tsx + push: + - match: (?<=\)) + pop: true + - include: paren-expression-possibly-arrow-with-typeparameters + - include: possibly-arrow-return-type + paren-expression-possibly-arrow-with-typeparameters: + - include: type-parameters + - match: \( + captures: + 0: meta.brace.round.tsx + push: + - match: \) + captures: + 0: meta.brace.round.tsx + pop: true + - include: expression-inside-possibly-arrow-parens + possibly-arrow-return-type: + - match: '(?<=\)|^)\s*(:)(?=\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*=>)' + captures: + 1: meta.arrow.tsx meta.return.type.arrow.tsx keyword.operator.type.annotation.tsx + push: + - meta_content_scope: meta.arrow.tsx meta.return.type.arrow.tsx + - match: '(?==>|\{|(^\s*(export|function|class|interface|let|var|const|import|enum|namespace|module|type|abstract|declare)\s+))' + pop: true + - include: arrow-return-type-body + property-accessor: + - match: '(?|&&|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[\()]|\\.|\[([^\]\\]|\\.)+\]|\(([^\)\\]|\\.)+\))+\/([gimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$]))' + captures: + 1: punctuation.definition.string.begin.tsx + push: + - meta_scope: string.regexp.tsx + - match: "(/)([gimsuy]*)" + captures: + 1: punctuation.definition.string.end.tsx + 2: keyword.other.tsx + pop: true + - include: regexp + - match: '((?' + captures: + 0: keyword.other.back-reference.regexp + 1: variable.other.regexp + - match: '[?+*]|\{(\d+,\d+|\d+,|,\d+|\d+)\}\??' + scope: keyword.operator.quantifier.regexp + - match: \| + scope: keyword.operator.or.regexp + - match: (\()((\?=)|(\?!)|(\?<=)|(\?))?' + captures: + 0: punctuation.definition.group.regexp + 1: punctuation.definition.group.no-capture.regexp + 2: variable.other.regexp + push: + - meta_scope: meta.group.regexp + - match: \) + captures: + 0: punctuation.definition.group.regexp + pop: true + - include: regexp + - match: '(\[)(\^)?' + captures: + 1: punctuation.definition.character-class.regexp + 2: keyword.operator.negation.regexp + push: + - meta_scope: constant.other.character-class.set.regexp + - match: '(\])' + captures: + 1: punctuation.definition.character-class.regexp + pop: true + - match: '(?:.|(\\(?:[0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}))|(\\c[A-Z])|(\\.))\-(?:[^\]\\]|(\\(?:[0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}))|(\\c[A-Z])|(\\.))' + scope: constant.other.character-class.range.regexp + captures: + 1: constant.character.numeric.regexp + 2: constant.character.control.regexp + 3: constant.character.escape.backslash.regexp + 4: constant.character.numeric.regexp + 5: constant.character.control.regexp + 6: constant.character.escape.backslash.regexp + - include: regex-character-class + - include: regex-character-class + return-type: + - match: (?<=\))\s*(:)(?=\s*\S) + captures: + 1: keyword.operator.type.annotation.tsx + push: + - meta_scope: meta.return.type.tsx + - match: "(?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?\()) + | + (?:(EPSILON|MAX_SAFE_INTEGER|MAX_VALUE|MIN_SAFE_INTEGER|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY)\b(?!\$))) + captures: + 1: punctuation.accessor.tsx + 2: punctuation.accessor.optional.tsx + 3: support.variable.property.tsx + 4: support.constant.tsx + - match: |- + (?x) (?]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)?\() + captures: + 1: punctuation.accessor.tsx + 2: punctuation.accessor.optional.tsx + 3: support.constant.dom.tsx + 4: support.variable.property.dom.tsx + - match: |- + (?x)(?\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)?`)' + push: + - meta_scope: string.template.tsx + - match: (?=`) + pop: true + - match: '(?=(([_$[:alpha:]][_$[:alnum:]]*\s*\??\.\s*)*|(\??\.\s*)?)([_$[:alpha:]][_$[:alnum:]]*))' + push: + - match: '(?=(<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)?`)' + pop: true + - include: support-function-call-identifiers + - match: "([_$[:alpha:]][_$[:alnum:]]*)" + scope: entity.name.function.tagged-template.tsx + - include: type-arguments + - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(?=(<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))(([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>|\<\s*(((keyof|infer|typeof|readonly)\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\''[^\'']*\'')|(\"[^\"]*\")|(\`[^\`]*\`))(?=\s*([\<\>\,\.\[]|=>|&(?!&)|\|(?!\|)))))([^<>\(]|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(?<==)\>)*(?))*(?)*(?\s*)`)' + captures: + 1: entity.name.function.tagged-template.tsx + push: + - meta_scope: string.template.tsx + - match: (?=`) + pop: true + - include: type-arguments + - match: "([_$[:alpha:]][_$[:alnum:]]*)?(`)" + captures: + 1: entity.name.function.tagged-template.tsx + 2: punctuation.definition.string.template.begin.tsx + push: + - meta_scope: string.template.tsx + - match: "`" + captures: + 0: punctuation.definition.string.template.end.tsx + pop: true + - include: template-substitution-element + - include: string-character-escape + template-substitution-element: + - match: '\$\{' + captures: + 0: punctuation.definition.template-expression.begin.tsx + push: + - meta_scope: meta.template.expression.tsx + - meta_content_scope: meta.embedded.line.tsx + - match: '\}' + captures: + 0: punctuation.definition.template-expression.end.tsx + pop: true + - include: expression + ternary-expression: + - match: '(?!\?\.\s*[^[:digit:]])(\?)(?!\?)' + captures: + 1: keyword.operator.ternary.tsx + push: + - match: \s*(:) + captures: + 1: keyword.operator.ternary.tsx + pop: true + - include: expression + this-literal: + - match: '(?])|((?<=[\}>\]\)]|[_$[:alpha:]])\s*(?=\{)))' + pop: true + - include: type + - match: (:) + captures: + 1: keyword.operator.type.annotation.tsx + push: + - meta_scope: meta.type.annotation.tsx + - match: '(?])|(?=^\s*$)|((?<=\S)(?=\s*$))|((?<=[\}>\]\)]|[_$[:alpha:]])\s*(?=\{)))' + pop: true + - include: type + type-arguments: + - match: \< + captures: + 0: punctuation.definition.typeparameters.begin.tsx + push: + - meta_scope: meta.type.parameters.tsx + - match: \> + captures: + 0: punctuation.definition.typeparameters.end.tsx + pop: true + - include: type-arguments-body + type-arguments-body: + - match: '(?) + pop: true + - include: comment + - include: type-parameters + - match: '(?) + )) + ) + ) + ) + push: + - meta_scope: meta.type.function.tsx + - match: (?<=\)) + pop: true + - include: function-parameters + type-function-return-type: + - match: (=>)(?=\s*\S) + captures: + 1: storage.type.function.arrow.tsx + push: + - meta_scope: meta.type.function.return.tsx + - match: '(?)(?:\?]|//|$)' + pop: true + - include: type-function-return-type-core + - match: "=>" + captures: + 0: storage.type.function.arrow.tsx + push: + - meta_scope: meta.type.function.return.tsx + - match: '(?)(?]|//|^\s*$)|((?<=\S)(?=\s*$)))' + pop: true + - include: type-function-return-type-core + type-function-return-type-core: + - include: comment + - match: '(?<==>)(?=\s*\{)' + push: + - match: '(?<=\})' + pop: true + - include: type-object + - include: type-predicate-operator + - include: type + type-name: + - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(?:(\.)|(\?\.(?!\s*[[:digit:]])))\s*(<)' + captures: + 1: entity.name.type.module.tsx + 2: punctuation.accessor.tsx + 3: punctuation.accessor.optional.tsx + 4: meta.type.parameters.tsx punctuation.definition.typeparameters.begin.tsx + push: + - meta_content_scope: meta.type.parameters.tsx + - match: (>) + captures: + 1: meta.type.parameters.tsx punctuation.definition.typeparameters.end.tsx + pop: true + - include: type-arguments-body + - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(<)' + captures: + 1: entity.name.type.tsx + 2: meta.type.parameters.tsx punctuation.definition.typeparameters.begin.tsx + push: + - meta_content_scope: meta.type.parameters.tsx + - match: (>) + captures: + 1: meta.type.parameters.tsx punctuation.definition.typeparameters.end.tsx + pop: true + - include: type-arguments-body + - match: '([_$[:alpha:]][_$[:alnum:]]*)\s*(?:(\.)|(\?\.(?!\s*[[:digit:]])))' + captures: + 1: entity.name.type.module.tsx + 2: punctuation.accessor.tsx + 3: punctuation.accessor.optional.tsx + - match: "[_$[:alpha:]][_$[:alnum:]]*" + scope: entity.name.type.tsx + type-object: + - match: '\{' + captures: + 0: punctuation.definition.block.tsx + push: + - meta_scope: meta.object.type.tsx + - match: '\}' + captures: + 0: punctuation.definition.block.tsx + pop: true + - include: comment + - include: method-declaration + - include: indexer-declaration + - include: indexer-mapped-type-declaration + - include: field-declaration + - include: type-annotation + - match: \.\.\. + captures: + 0: keyword.operator.spread.tsx + push: + - match: '(?=\}|;|,|$)|(?<=\})' + pop: true + - include: type + - include: punctuation-comma + - include: punctuation-semicolon + - include: type + type-operators: + - include: typeof-operator + - match: '([&|])(?=\s*\{)' + captures: + 0: keyword.operator.type.tsx + push: + - match: '(?<=\})' + pop: true + - include: type-object + - match: "[&|]" + captures: + 0: keyword.operator.type.tsx + push: + - match: (?=\S) + pop: true + - match: '(?) + captures: + 1: punctuation.definition.typeparameters.end.tsx + pop: true + - include: comment + - match: '(?) + scope: keyword.operator.assignment.tsx + type-paren-or-function-parameters: + - match: \( + captures: + 0: meta.brace.round.tsx + push: + - meta_scope: meta.type.paren.cover.tsx + - match: \) + captures: + 0: meta.brace.round.tsx + pop: true + - match: |- + (?x)(?:(?) + )) + )) + )) | + (:\s*(?\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))))) + captures: + 1: storage.modifier.tsx + 2: keyword.operator.rest.tsx + 3: entity.name.function.tsx variable.language.this.tsx + 4: entity.name.function.tsx + 5: keyword.operator.optional.tsx + - match: '(?x)(?:(?) + )) | + ((async\s*)?( + ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + ( + [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends + ) | + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + )) | + # typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) => + (:\s*( + (<) | + ([(]\s*( + ([)]) | + (\.\.\.) | + ([_$[:alnum:]]+\s*( + ([:,?=])| + ([)]\s*=>) + )) + )) + )) | + (:\s*(?\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) | + (:\s*(=>|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*( + ((async\s+)?( + (function\s*[(<*]) | + (function\s+) | + ([_$[:alpha:]][_$[:alnum:]]*\s*=>) + )) | + ((async\s*)?( + ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + ( + [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends + ) | + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + ))) + captures: + 1: meta.definition.variable.tsx variable.other.constant.tsx entity.name.function.tsx + push: + - meta_scope: meta.var-single-variable.expr.tsx + - match: '(?=$|^|[;,=}]|((?) + )) | + ((async\s*)?( + ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + ( + [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends + ) | + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + )) | + # typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) => + (:\s*( + (<) | + ([(]\s*( + ([)]) | + (\.\.\.) | + ([_$[:alnum:]]+\s*( + ([:,?=])| + ([)]\s*=>) + )) + )) + )) | + (:\s*(?\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*))))))) | + (:\s*(=>|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*( + ((async\s+)?( + (function\s*[(<*]) | + (function\s+) | + ([_$[:alpha:]][_$[:alnum:]]*\s*=>) + )) | + ((async\s*)?( + ((<\s*$)|([\(]\s*((([\{\[]\s*)?$)|((\{([^\{\}]|(\{[^\{\}]*\}))*\})\s*((:\s*\{?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))|((\[([^\[\]]|(\[[^\[\]]*\]))*\])\s*((:\s*\[?$)|((\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+\s*)?=\s*)))))) | + # sure shot arrow functions even if => is on new line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? + [(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)* + ( + ([)]\s*:) | # (): + ((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param: + ) + ) | + ( + [<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends + ) | + # arrow function possible to detect only with => on same line + ( + (<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*\>)*>\s*)? # typeparameters + \(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters + (\s*:\s*([^<>\(\)\{\}]|\<([^<>]|\<[^<>]+\>)+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type + \s*=> # arrow operator + ) + )) + ))) + captures: + 1: meta.definition.variable.tsx entity.name.function.tsx + 2: keyword.operator.definiteassignment.tsx + push: + - meta_scope: meta.var-single-variable.expr.tsx + - match: '(?=$|^|[;,=}]|((?\s*$) + captures: + 1: keyword.operator.assignment.tsx + push: + - match: '(?=$|^|[,);}\]]|((?) + captures: + 1: punctuation.definition.tag.xml + 2: entity.name.tag.xml + pop: true + - match: " ([a-zA-Z-]+)" + scope: entity.other.attribute-name.xml + - include: doublequotedString + - include: singlequotedString + - match: '() + captures: + 1: punctuation.definition.tag.xml + 2: entity.name.tag.xml + 3: entity.other.attribute-name.documentroot.xml + pop: true + - include: internalSubset + - match: "<[!%]--" + captures: + 0: punctuation.definition.comment.xml + push: + - meta_scope: comment.block.xml + - match: "--%?>" + captures: + 0: punctuation.definition.comment.xml + pop: true + - match: '(<)((?:([-_a-zA-Z0-9]+)((:)))?([-_a-zA-Z0-9:]+))(?=(\s[^>]*)?>)' + captures: + 1: punctuation.definition.tag.xml + 3: entity.name.tag.namespace.xml + 4: entity.name.tag.xml + 5: punctuation.separator.namespace.xml + 6: entity.name.tag.localname.xml + push: + - meta_scope: meta.tag.no-content.xml + - match: "(>(<))/(?:([-_a-zA-Z0-9]+)((:)))?([-_a-zA-Z0-9:]+)(>)" + captures: + 1: punctuation.definition.tag.xml + 2: meta.scope.between-tag-pair.xml + 3: entity.name.tag.namespace.xml + 4: entity.name.tag.xml + 5: punctuation.separator.namespace.xml + 6: entity.name.tag.localname.xml + 7: punctuation.definition.tag.xml + pop: true + - include: tagStuff + - match: "() + captures: + 1: punctuation.definition.tag.xml + 2: entity.name.tag.namespace.xml + 3: entity.name.tag.xml + 4: punctuation.separator.namespace.xml + 5: entity.name.tag.localname.xml + pop: true + - include: tagStuff + - include: entity + - include: bare-ampersand + - match: <%@ + captures: + 0: punctuation.section.embedded.begin.xml + push: + - meta_scope: source.java-props.embedded.xml + - match: "%>" + captures: + 0: punctuation.section.embedded.end.xml + pop: true + - match: page|include|taglib + scope: keyword.other.page-props.xml + - match: "<%[!=]?(?!--)" + captures: + 0: punctuation.section.embedded.begin.xml + push: + - meta_scope: source.java.embedded.xml + - match: (?!--)%> + captures: + 0: punctuation.section.embedded.end.xml + pop: true + - include: scope:source.java + - match: '" + captures: + 0: punctuation.definition.string.end.xml + pop: true + EntityDecl: + - match: '() + captures: + 1: punctuation.definition.tag.xml + 2: keyword.other.entity.xml + 3: punctuation.definition.entity.xml + 4: variable.language.entity.xml + 5: keyword.other.entitytype.xml + pop: true + - include: doublequotedString + - include: singlequotedString + bare-ampersand: + - match: "&" + scope: invalid.illegal.bad-ampersand.xml + doublequotedString: + - match: '"' + captures: + 0: punctuation.definition.string.begin.xml + push: + - meta_scope: string.quoted.double.xml + - match: '"' + captures: + 0: punctuation.definition.string.end.xml + pop: true + - include: entity + - include: bare-ampersand + entity: + - match: "(&)([:a-zA-Z_][:a-zA-Z0-9_.-]*|#[0-9]+|#x[0-9a-fA-F]+)(;)" + scope: constant.character.entity.xml + captures: + 1: punctuation.definition.constant.xml + 3: punctuation.definition.constant.xml + internalSubset: + - match: '(\[)' + captures: + 1: punctuation.definition.constant.xml + push: + - meta_scope: meta.internalsubset.xml + - match: '(\])' + captures: + 1: punctuation.definition.constant.xml + pop: true + - include: EntityDecl + - include: parameterEntity + parameterEntity: + - match: "(%)([:a-zA-Z_][:a-zA-Z0-9_.-]*)(;)" + scope: constant.character.parameter-entity.xml + captures: + 1: punctuation.definition.constant.xml + 3: punctuation.definition.constant.xml + singlequotedString: + - match: "'" + captures: + 0: punctuation.definition.string.begin.xml + push: + - meta_scope: string.quoted.single.xml + - match: "'" + captures: + 0: punctuation.definition.string.end.xml + pop: true + - include: entity + - include: bare-ampersand + tagStuff: + - match: " (?:([-_a-zA-Z0-9]+)((:)))?([-_a-zA-Z0-9]+)=" + captures: + 1: entity.other.attribute-name.namespace.xml + 2: entity.other.attribute-name.xml + 3: punctuation.separator.namespace.xml + 4: entity.other.attribute-name.localname.xml + - include: doublequotedString + - include: singlequotedString diff --git a/syntect/minimal_grammars/batchfile.sublime-syntax b/syntect/minimal_grammars/batchfile.sublime-syntax new file mode 100644 index 0000000..07448d5 --- /dev/null +++ b/syntect/minimal_grammars/batchfile.sublime-syntax @@ -0,0 +1,328 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: Batch File +file_extensions: + - bat + - cmd +scope: source.batchfile +contexts: + main: + - include: commands + - include: comments + - include: constants + - include: controls + - include: escaped_characters + - include: labels + - include: numbers + - include: operators + - include: parens + - include: strings + - include: variables + command_set: + - match: '(?<=^|[\s@])(?i:SET)(?=$|\s)' + captures: + 0: keyword.command.batchfile + push: + - match: '(?=$\n|[&|><)])' + pop: true + - include: command_set_inside + command_set_group: + - match: \( + captures: + 0: punctuation.section.group.begin.batchfile + push: + - match: \) + captures: + 0: punctuation.section.group.end.batchfile + pop: true + - include: command_set_inside_arithmetic + command_set_inside: + - include: escaped_characters + - include: variables + - include: numbers + - include: parens + - include: command_set_strings + - include: strings + - match: "([^ ][^=]*)(=)" + captures: + 1: variable.other.readwrite.batchfile + 2: keyword.operator.assignment.batchfile + push: + - match: '(?=$\n|[&|><)])' + pop: true + - include: escaped_characters + - include: variables + - include: numbers + - include: parens + - include: strings + - match: '\s+/[aA]\s+' + push: + - meta_scope: meta.expression.set.batchfile + - match: '(?=$\n|[&|><)])' + pop: true + - match: '"' + captures: + 0: punctuation.definition.string.begin.batchfile + push: + - meta_scope: string.quoted.double.batchfile + - match: '"' + captures: + 0: punctuation.definition.string.end.batchfile + pop: true + - include: command_set_inside_arithmetic + - include: command_set_group + - include: variables + - include: command_set_inside_arithmetic + - include: command_set_group + - match: '\s+/[pP]\s+' + push: + - match: '(?=$\n|[&|><)])' + pop: true + - include: command_set_strings + - match: "([^ ][^=]*)(=)" + captures: + 1: variable.other.readwrite.batchfile + 2: keyword.operator.assignment.batchfile + push: + - meta_scope: meta.prompt.set.batchfile + - match: '(?=$\n|[&|><)])' + pop: true + - include: strings + command_set_inside_arithmetic: + - include: command_set_operators + - include: numbers + - match: "," + scope: punctuation.separator.batchfile + command_set_operators: + - match: '([^ ]*)(\+\=|\-\=|\*\=|\/\=|%%\=|&\=|\|\=|\^\=|<<\=|>>\=)' + captures: + 1: variable.other.readwrite.batchfile + 2: keyword.operator.assignment.augmented.batchfile + - match: \+|\-|/|\*|%%|\||&|\^|<<|>>|~ + scope: keyword.operator.arithmetic.batchfile + - match: "!" + scope: keyword.operator.logical.batchfile + - match: "([^ ][^=]*)(=)" + captures: + 1: variable.other.readwrite.batchfile + 2: keyword.operator.assignment.batchfile + command_set_strings: + - match: '(")\s*([^ ][^=]*)(=)' + captures: + 1: punctuation.definition.string.begin.batchfile + 2: variable.other.readwrite.batchfile + 3: keyword.operator.assignment.batchfile + push: + - meta_scope: string.quoted.double.batchfile + - match: '"' + captures: + 0: punctuation.definition.string.end.batchfile + pop: true + - include: variables + - include: numbers + - include: escaped_characters + commands: + - match: '(?<=^|[\s@])(?i:adprep|append|arp|assoc|at|atmadm|attrib|auditpol|autochk|autoconv|autofmt|bcdboot|bcdedit|bdehdcfg|bitsadmin|bootcfg|brea|cacls|cd|certreq|certutil|change|chcp|chdir|chglogon|chgport|chgusr|chkdsk|chkntfs|choice|cipher|clip|cls|clscluadmin|cluster|cmd|cmdkey|cmstp|color|comp|compact|convert|copy|cprofile|cscript|csvde|date|dcdiag|dcgpofix|dcpromo|defra|del|dfscmd|dfsdiag|dfsrmig|diantz|dir|dirquota|diskcomp|diskcopy|diskpart|diskperf|diskraid|diskshadow|dispdiag|doin|dnscmd|doskey|driverquery|dsacls|dsadd|dsamain|dsdbutil|dsget|dsmgmt|dsmod|dsmove|dsquery|dsrm|edit|endlocal|eraseesentutl|eventcreate|eventquery|eventtriggers|evntcmd|expand|extract|fc|filescrn|find|findstr|finger|flattemp|fonde|forfiles|format|freedisk|fsutil|ftp|ftype|fveupdate|getmac|gettype|gpfixup|gpresult|gpupdate|graftabl|hashgen|hep|helpctr|hostname|icacls|iisreset|inuse|ipconfig|ipxroute|irftp|ismserv|jetpack|klist|ksetup|ktmutil|ktpass|label|ldifd|ldp|lodctr|logman|logoff|lpq|lpr|macfile|makecab|manage-bde|mapadmin|md|mkdir|mklink|mmc|mode|more|mount|mountvol|move|mqbup|mqsvc|mqtgsvc|msdt|msg|msiexec|msinfo32|mstsc|nbtstat|net computer|net group|net localgroup|net print|net session|net share|net start|net stop|net use|net user|net view|net|netcfg|netdiag|netdom|netsh|netstat|nfsadmin|nfsshare|nfsstat|nlb|nlbmgr|nltest|nslookup|ntackup|ntcmdprompt|ntdsutil|ntfrsutl|openfiles|pagefileconfig|path|pathping|pause|pbadmin|pentnt|perfmon|ping|pnpunatten|pnputil|popd|powercfg|powershell|powershell_ise|print|prncnfg|prndrvr|prnjobs|prnmngr|prnport|prnqctl|prompt|pubprn|pushd|pushprinterconnections|pwlauncher|qappsrv|qprocess|query|quser|qwinsta|rasdial|rcp|rd|rdpsign|regentc|recover|redircmp|redirusr|reg|regini|regsvr32|relog|ren|rename|rendom|repadmin|repair-bde|replace|reset session|rxec|risetup|rmdir|robocopy|route|rpcinfo|rpcping|rsh|runas|rundll32|rwinsta|scp|sc|schtasks|scwcmd|secedit|serverceipoptin|servrmanagercmd|serverweroptin|setspn|setx|sfc|shadow|shift|showmount|shutdown|sort|ssh|start|storrept|subst|sxstrace|ysocmgr|systeminfo|takeown|tapicfg|taskkill|tasklist|tcmsetup|telnet|tftp|time|timeout|title|tlntadmn|tpmvscmgr|tpmvscmgr|tacerpt|tracert|tree|tscon|tsdiscon|tsecimp|tskill|tsprof|type|typeperf|tzutil|uddiconfig|umount|unlodctr|ver|verifier|verif|vol|vssadmin|w32tm|waitfor|wbadmin|wdsutil|wecutil|wevtutil|where|whoami|winnt|winnt32|winpop|winrm|winrs|winsat|wlbs|mic|wscript|xcopy)(?=$|\s)' + scope: keyword.command.batchfile + - match: '(?i)(?<=^|[\s@])(echo)(?:(?=$|\.|:)|\s+(?:(on|off)(?=\s*$))?)' + captures: + 1: keyword.command.batchfile + 2: keyword.other.special-method.batchfile + push: + - match: '(?=$\n|[&|><)])' + pop: true + - include: escaped_characters + - include: variables + - include: numbers + - include: strings + - match: '(?i)(?<=^|[\s@])(setlocal)(?:\s*$|\s+(EnableExtensions|DisableExtensions|EnableDelayedExpansion|DisableDelayedExpansion)(?=\s*$))' + captures: + 1: keyword.command.batchfile + 2: keyword.other.special-method.batchfile + - include: command_set + comments: + - match: '(?:^|(&))\s*(?=((?::[+=,;: ])))' + captures: + 1: keyword.operator.conditional.batchfile + push: + - match: \n + pop: true + - match: "((?::[+=,;: ]))" + captures: + 1: punctuation.definition.comment.batchfile + push: + - meta_scope: comment.line.colon.batchfile + - match: (?=\n) + pop: true + - match: '(?<=^|[\s@])(?i)(REM)(\.)' + captures: + 1: keyword.command.rem.batchfile + 2: punctuation.separator.batchfile + push: + - meta_scope: comment.line.rem.batchfile + - match: '(?=$\n|[&|><)])' + pop: true + - match: '(?<=^|[\s@])(?i:rem)\b' + captures: + 0: keyword.command.rem.batchfile + push: + - meta_scope: comment.line.rem.batchfile + - match: \n + pop: true + - match: "[><|]" + scope: invalid.illegal.unexpected-character.batchfile + constants: + - match: \b(?i:NUL)\b + scope: constant.language.batchfile + controls: + - match: (?i)(?<=^|\s)(?:call|exit(?=$|\s)|goto(?=$|\s|:)) + scope: keyword.control.statement.batchfile + - match: (?<=^|\s)(?i)(if)\s+(?:(not)\s+)?(exist|defined|errorlevel|cmdextversion)(?=\s) + captures: + 1: keyword.control.conditional.batchfile + 2: keyword.operator.logical.batchfile + 3: keyword.other.special-method.batchfile + - match: (?<=^|\s)(?i)(?:if|else)(?=$|\s) + scope: keyword.control.conditional.batchfile + - match: (?<=^|\s)(?i)for(?=\s) + scope: keyword.control.repeat.batchfile + escaped_characters: + - match: '%%|\^\^!|\^(?=.)|\^\n' + scope: constant.character.escape.batchfile + labels: + - match: '(?i)(?:^\s*|(?<=goto)\s*)(:)([^+=,;:\s].*)$' + captures: + 1: punctuation.separator.batchfile + 2: keyword.other.special-method.batchfile + numbers: + - match: '(?<=^|\s|=)(0[xX][0-9A-Fa-f]*|[+-]?\d+)(?=$|\s|<|>)' + scope: constant.numeric.batchfile + operators: + - match: '@(?=\S)' + scope: keyword.operator.at.batchfile + - match: (?<=\s)(?i:EQU|NEQ|LSS|LEQ|GTR|GEQ)(?=\s)|== + scope: keyword.operator.comparison.batchfile + - match: (?<=\s)(?i)(NOT)(?=\s) + scope: keyword.operator.logical.batchfile + - match: (?[&>]?" + scope: keyword.operator.redirection.batchfile + parens: + - match: \( + captures: + 0: punctuation.section.group.begin.batchfile + push: + - meta_scope: meta.group.batchfile + - match: \) + captures: + 0: punctuation.section.group.end.batchfile + pop: true + - match: ",|;" + scope: punctuation.separator.batchfile + - include: main + strings: + - match: '"' + captures: + 0: punctuation.definition.string.begin.batchfile + push: + - meta_scope: string.quoted.double.batchfile + - match: (")|(\n) + captures: + 1: punctuation.definition.string.end.batchfile + 2: invalid.illegal.newline.batchfile + pop: true + - match: "%%" + scope: constant.character.escape.batchfile + - include: variables + variable: + - match: "%(?=[^%]+%)" + captures: + 0: punctuation.definition.variable.begin.batchfile + push: + - meta_scope: variable.other.readwrite.batchfile + - match: (%)|\n + captures: + 1: punctuation.definition.variable.end.batchfile + pop: true + - match: ":~" + captures: + 0: punctuation.separator.batchfile + push: + - meta_scope: meta.variable.substring.batchfile + - match: (?=%|\n) + pop: true + - include: variable_substring + - match: ":" + captures: + 0: punctuation.separator.batchfile + push: + - meta_scope: meta.variable.substitution.batchfile + - match: (?=%|\n) + pop: true + - include: variable_replace + - match: "=" + captures: + 0: punctuation.separator.batchfile + push: + - match: (?=%|\n) + pop: true + - include: variable_delayed_expansion + - match: "[^%]+" + scope: string.unquoted.batchfile + variable_delayed_expansion: + - match: "!(?=[^!]+!)" + captures: + 0: punctuation.definition.variable.begin.batchfile + push: + - meta_scope: variable.other.readwrite.batchfile + - match: (!)|\n + captures: + 1: punctuation.definition.variable.end.batchfile + pop: true + - match: ":~" + captures: + 0: punctuation.separator.batchfile + push: + - meta_scope: meta.variable.substring.batchfile + - match: (?=!|\n) + pop: true + - include: variable_substring + - match: ":" + captures: + 0: punctuation.separator.batchfile + push: + - meta_scope: meta.variable.substitution.batchfile + - match: (?=!|\n) + pop: true + - include: escaped_characters + - include: variable_replace + - include: variable + - match: "=" + captures: + 0: punctuation.separator.batchfile + push: + - match: (?=!|\n) + pop: true + - include: variable + - match: "[^!]+" + scope: string.unquoted.batchfile + variable_replace: + - match: '[^=%!\n]+' + scope: string.unquoted.batchfile + variable_substring: + - match: '([+-]?\d+)(?:(,)([+-]?\d+))?' + captures: + 1: constant.numeric.batchfile + 2: punctuation.separator.batchfile + 3: constant.numeric.batchfile + variables: + - match: '(%)((~([fdpnxsatz]|\$PATH:)*)?\d|\*)' + captures: + 1: punctuation.definition.variable.batchfile + 2: variable.parameter.batchfile + - include: variable + - include: variable_delayed_expansion diff --git a/syntect/minimal_grammars/css.sublime-syntax b/syntect/minimal_grammars/css.sublime-syntax new file mode 100644 index 0000000..e199389 --- /dev/null +++ b/syntect/minimal_grammars/css.sublime-syntax @@ -0,0 +1,1392 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: CSS +file_extensions: + - css + - css.erb +first_line_match: |- + (?xi) + # Emacs modeline + -\*-(?:\s*(?=[^:;\s]+\s*-\*-)|(?:.*?[;\s]|(?<=-\*-))mode\s*:\s*) + css + (?=[\s;]|(?]?\d+|m)?|\sex)(?=:(?=\s*set?\s[^\n:]+:)|:(?!\s*set?\s))(?:(?:\s|\s*:\s*)\w*(?:\s*=(?:[^\n\\\s]|\\.)*)?)*[\s:](?:filetype|ft|syntax)\s*= + css + (?=\s|:|$) +scope: source.css +contexts: + main: + - include: comment-block + - include: escapes + - include: combinators + - include: selector + - include: at-rules + - include: rule-list + at-rules: + - match: \A(?:\xEF\xBB\xBF)?(?i:(?=\s*@charset\b)) + push: + - meta_scope: meta.at-rule.charset.css + - match: ;|(?=$) + captures: + 0: punctuation.terminator.rule.css + pop: true + - match: |- + (?x) # Possible errors: + \G + ((?!@charset)@\w+) # Not lowercase (@charset is case-sensitive) + | + \G(\s+) # Preceding whitespace + | + (@charset\S[^;]*) # No whitespace after @charset + | + (?<=@charset) # Before quoted charset name + (\x20{2,}|\t+) # More than one space used, or a tab + | + (?<=@charset\x20) # Beginning of charset name + ([^";]+) # Not double-quoted + | + ("[^"]+$) # Unclosed quote + | + (?<=") # After charset name + ([^;]+) # Unexpected junk instead of semicolon + captures: + 1: invalid.illegal.not-lowercase.charset.css + 2: invalid.illegal.leading-whitespace.charset.css + 3: invalid.illegal.no-whitespace.charset.css + 4: invalid.illegal.whitespace.charset.css + 5: invalid.illegal.not-double-quoted.charset.css + 6: invalid.illegal.unclosed-string.charset.css + 7: invalid.illegal.unexpected-characters.charset.css + - match: ((@)charset)(?=\s) + captures: + 1: keyword.control.at-rule.charset.css + 2: punctuation.definition.keyword.css + - match: '"' + captures: + 0: punctuation.definition.string.begin.css + push: + - meta_scope: string.quoted.double.css + - match: '"|$' + captures: + 0: punctuation.definition.string.end.css + pop: true + - match: '(?:\G|^)(?=(?:[^"])+$)' + push: + - meta_scope: invalid.illegal.unclosed.string.css + - match: $ + pop: true + - match: '(?i)((@)import)(?:\s+|$|(?=[''"]|/\*))' + captures: + 1: keyword.control.at-rule.import.css + 2: punctuation.definition.keyword.css + push: + - meta_scope: meta.at-rule.import.css + - match: ; + captures: + 0: punctuation.terminator.rule.css + pop: true + - match: \G\s*(?=/\*) + push: + - match: (?<=\*/)\s* + pop: true + - include: comment-block + - include: string + - include: url + - include: media-query-list + - match: '(?i)((@)font-face)(?=\s*|{|/\*|$)' + captures: + 1: keyword.control.at-rule.font-face.css + 2: punctuation.definition.keyword.css + push: + - meta_scope: meta.at-rule.font-face.css + - match: (?!\G) + pop: true + - include: comment-block + - include: escapes + - include: rule-list + - match: '(?i)(@)page(?=[\s:{]|/\*|$)' + captures: + 0: keyword.control.at-rule.page.css + 1: punctuation.definition.keyword.css + push: + - meta_scope: meta.at-rule.page.css + - match: '(?=\s*($|[:{;]))' + captures: + 0: keyword.control.at-rule.page.css + 1: punctuation.definition.keyword.css + pop: true + - include: rule-list + - match: (?i)(?=@media(\s|\(|/\*|$)) + push: + - match: '(?<=})(?!\G)' + pop: true + - match: (?i)\G(@)media + captures: + 0: keyword.control.at-rule.media.css + 1: punctuation.definition.keyword.css + push: + - meta_scope: meta.at-rule.media.header.css + - match: '(?=\s*[{;])' + pop: true + - include: media-query-list + - match: "{" + captures: + 0: punctuation.section.media.begin.bracket.curly.css + push: + - meta_scope: meta.at-rule.media.body.css + - match: "}" + captures: + 0: punctuation.section.media.end.bracket.curly.css + pop: true + - include: main + - match: '(?i)(?=@counter-style([\s''"{;]|/\*|$))' + push: + - match: '(?<=})(?!\G)' + pop: true + - match: (?i)\G(@)counter-style + captures: + 0: keyword.control.at-rule.counter-style.css + 1: punctuation.definition.keyword.css + push: + - meta_scope: meta.at-rule.counter-style.header.css + - match: '(?=\s*{)' + pop: true + - include: comment-block + - include: escapes + - match: |- + (?x) + (?:[-a-zA-Z_] | [^\x00-\x7F]) # First letter + (?:[-a-zA-Z0-9_] | [^\x00-\x7F] # Remainder of identifier + |\\(?:[0-9a-fA-F]{1,6}|.) + )* + scope: variable.parameter.style-name.css + captures: + - match: "{" + captures: + 0: punctuation.section.property-list.begin.bracket.curly.css + push: + - meta_scope: meta.at-rule.counter-style.body.css + - match: "}" + captures: + 0: punctuation.section.property-list.end.bracket.curly.css + pop: true + - include: comment-block + - include: escapes + - include: rule-list-innards + - match: '(?i)(?=@document([\s''"{;]|/\*|$))' + push: + - match: '(?<=})(?!\G)' + pop: true + - match: (?i)\G(@)document + captures: + 0: keyword.control.at-rule.document.css + 1: punctuation.definition.keyword.css + push: + - meta_scope: meta.at-rule.document.header.css + - match: '(?=\s*[{;])' + pop: true + - match: '(?i)(?>> + scope: invalid.deprecated.combinator.css + - match: '>>|>|\+|~' + scope: keyword.operator.combinator.css + commas: + - match: "," + scope: punctuation.separator.list.comma.css + comment-block: + - match: /\* + captures: + 0: punctuation.definition.comment.begin.css + push: + - meta_scope: comment.block.css + - match: \*/ + captures: + 0: punctuation.definition.comment.end.css + pop: true + escapes: + - match: '\\[0-9a-fA-F]{1,6}' + scope: constant.character.escape.codepoint.css + - match: \\$\s* + push: + - meta_scope: constant.character.escape.newline.css + - match: ^(?<:=]|\)|/\*) # Terminates cleanly + captures: + 1: support.type.property-name.media.css + 2: support.type.property-name.media.css + 3: support.type.vendored.property-name.media.css + media-query: + - match: \G + push: + - match: '(?=\s*[{;])' + pop: true + - include: comment-block + - include: escapes + - include: media-types + - match: '(?i)(?<=\s|^|,|\*/)(only|not)(?=\s|{|/\*|$)' + scope: keyword.operator.logical.$1.media.css + - match: (?i)(?<=\s|^|\*/|\))and(?=\s|/\*|$) + scope: keyword.operator.logical.and.media.css + - match: ',(?:(?:\s*,)+|(?=\s*[;){]))' + scope: invalid.illegal.comma.css + - include: commas + - match: \( + captures: + 0: punctuation.definition.parameters.begin.bracket.round.css + push: + - match: \) + captures: + 0: punctuation.definition.parameters.end.bracket.round.css + pop: true + - include: media-features + - include: media-feature-keywords + - match: ":" + scope: punctuation.separator.key-value.css + - match: ">=|<=|=|<|>" + scope: keyword.operator.comparison.css + - match: (\d+)\s*(/)\s*(\d+) + scope: meta.ratio.css + captures: + 1: constant.numeric.css + 2: keyword.operator.arithmetic.css + 3: constant.numeric.css + - include: numeric-values + - include: comment-block + media-query-list: + - match: '(?=\s*[^{;])' + push: + - match: '(?=\s*[{;])' + pop: true + - include: media-query + media-types: + - match: |- + (?xi) + (?<=^|\s|,|\*/) + (?: + # Valid media types + (all|print|screen|speech) + | + # Deprecated in Media Queries 4: http://dev.w3.org/csswg/mediaqueries/#media-types + (aural|braille|embossed|handheld|projection|tty|tv) + ) + (?=$|[{,\s;]|/\*) + captures: + 1: support.constant.media.css + 2: invalid.deprecated.constant.media.css + numeric-values: + - match: '(#)(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})\b' + scope: constant.other.color.rgb-value.hex.css + captures: + 1: punctuation.definition.constant.css + - match: |- + (?xi) (?+~|] # - Followed by another selector + | /\* # - Followed by a block comment + ) + | + # Name contains unescaped ASCII symbol + (?: # Check for acceptable preceding characters + [-a-zA-Z_0-9]|[^\x00-\x7F] # - Valid selector character + | \\(?:[0-9a-fA-F]{1,6}|.) # - Escape sequence + )* + (?: # Invalid punctuation + [!"'%&(*;+~|] # - Another selector + | /\* # - A block comment + ) + scope: entity.other.attribute-name.class.css + captures: + 1: punctuation.definition.entity.css + - match: |- + (?x) + (\#) + ( + -? + (?![0-9]) + (?:[-a-zA-Z0-9_]|[^\x00-\x7F]|\\(?:[0-9a-fA-F]{1,6}|.))+ + ) + (?=$|[\s,.\#)\[:{>+~|]|/\*) + scope: entity.other.attribute-name.id.css + captures: + 1: punctuation.definition.entity.css + - match: '\[' + captures: + 0: punctuation.definition.entity.begin.bracket.square.css + push: + - meta_scope: meta.attribute-selector.css + - match: '\]' + captures: + 0: punctuation.definition.entity.end.bracket.square.css + pop: true + - include: comment-block + - include: string + - match: '(?<=["''\s]|^|\*/)\s*([iI])\s*(?=[\s\]]|/\*|$)' + captures: + 1: storage.modifier.ignore-case.css + - match: '(?x)(?<==)\s*((?!/\*)(?:[^\\"''\s\]]|\\.)+)' + captures: + 1: string.unquoted.attribute-value.css + - include: escapes + - match: "[~|^$*]?=" + scope: keyword.operator.pattern.css + - match: \| + scope: punctuation.separator.css + - match: |- + (?x) + # Qualified namespace prefix + ( -?(?!\d)(?:[\w-]|[^\x00-\x7F]|\\(?:[0-9a-fA-F]{1,6}|.))+ + | \* + ) + # Lookahead to ensure there's a valid identifier ahead + (?= + \| (?!\s|=|$|\]) + (?: -?(?!\d) + | [\\\w-] + | [^\x00-\x7F] + ) + ) + captures: + 1: entity.other.namespace-prefix.css + - match: |- + (?x) + (-?(?!\d)(?>[\w-]|[^\x00-\x7F]|\\(?:[0-9a-fA-F]{1,6}|.))+) + \s* + (?=[~|^\]$*=]|/\*) + captures: + 1: entity.other.attribute-name.css + - include: pseudo-classes + - include: pseudo-elements + - include: functional-pseudo-classes + - match: |- + (?x) (?\s,.\#|){:\[]|/\*|$) + scope: entity.name.tag.css + unicode-range: + - match: '(?]+)>' + scope: link + captures: + 1: punctuation.definition.begin.gfm + 2: entity.gfm + 3: punctuation.definition.end.gfm + 4: markup.underline.link.gfm + - match: '^\s*(\[)([^\]]+)(\])\s*(:)\s*(\S+)' + scope: link + captures: + 1: punctuation.definition.begin.gfm + 2: entity.gfm + 3: punctuation.definition.end.gfm + 4: punctuation.separator.key-value.gfm + 5: markup.underline.link.gfm + - match: '^\s*([*+-])[ \t]+' + captures: + 1: variable.unordered.list.gfm + - match: '^\s*(\d+\.)[ \t]+' + captures: + 1: variable.ordered.list.gfm + - match: ^\s*(>) + captures: + 1: support.quote.gfm + push: + - meta_scope: comment.quote.gfm + - match: ^\s*?$ + pop: true + - include: main + - match: '(?<=^|\s|"|''|\(|\[)(@)(\w[-\w:]*)(?=[\s"''.,;\)\]])' + captures: + 1: variable.mention.gfm + 2: string.username.gfm + - match: '(?<=^|\s|"|''|\(|\[)(#)(\d+)(?=[\s"''\.,;\)\]])' + captures: + 1: variable.issue.tag.gfm + 2: string.issue.number.gfm + - match: ( )$ + captures: + 1: linebreak.gfm + - match: ) + scope: comment.block.html.js + captures: + 0: punctuation.definition.comment.html.js + 2: punctuation.definition.comment.html.js + - match: (?|&&|\|\|)\s*(/)(?![/*+?])(?=.*/)' + captures: + 1: punctuation.definition.string.begin.js + push: + - meta_scope: string.regexp.js + - match: "(/)([gimsuy]*)" + captures: + 1: punctuation.definition.string.end.js + 2: meta.flag.regexp + pop: true + - include: scope:source.js.regexp + - match: \? + captures: + 0: keyword.operator.ternary.js + push: + - match: ":" + captures: + 0: keyword.operator.ternary.js + pop: true + - include: prevent_object_keys_matching + - include: main + - include: operators + - include: method_calls + - include: function_calls + - include: numbers + - include: objects + - include: properties + - match: '((?" + scope: storage.type.function.arrow.js + - include: function_params + - match: '([a-zA-Z_$][\w$]*)(?=\s*=>)' + captures: + 0: meta.parameters.js + 1: variable.parameter.function.js + - match: '(\d[\w$]*)' + captures: + 0: meta.parameters.js + 1: invalid.illegal.identifier.js + comments: + - match: (/\*)(\*/) + scope: comment.block.empty.js + captures: + 1: punctuation.definition.comment.begin.js + 2: punctuation.definition.comment.end.js + - match: /\*\* + captures: + 0: punctuation.definition.comment.begin.js + push: + - meta_scope: comment.block.documentation.js + - match: \*/ + captures: + 0: punctuation.definition.comment.end.js + pop: true + - include: scope:source.jsdoc + - match: /\* + captures: + 0: punctuation.definition.comment.begin.js + push: + - meta_scope: comment.block.js + - match: \*/ + captures: + 0: punctuation.definition.comment.end.js + pop: true + - match: // + captures: + 0: punctuation.definition.comment.js + push: + - meta_scope: comment.line.double-slash.js + - match: $ + pop: true + function_body: + - match: "{" + captures: + 0: punctuation.definition.function.body.begin.bracket.curly.js + push: + - match: "}" + captures: + 0: punctuation.definition.function.body.end.bracket.curly.js + pop: true + - include: main + function_calls: + - match: '([\w$]+)\s*(?=\()' + push: + - meta_scope: meta.function-call.js + - match: (?<=\)) + pop: true + - include: arguments + function_innards: + - match: (?:\b(async)\b\s*)?\b(function)\b(?:\s*(\*))? + captures: + 1: storage.modifier.async.js + 2: storage.type.function.js + 3: storage.modifier.generator.js + - match: '[a-zA-Z_$][\w$]*(?=\s*\()' + scope: entity.name.function.js + - include: function_params + - include: comments + function_params: + - match: \( + captures: + 0: punctuation.definition.parameters.begin.bracket.round.js + push: + - meta_scope: meta.parameters.js + - match: \) + captures: + 0: punctuation.definition.parameters.end.bracket.round.js + pop: true + - match: '(\.\.\.)([a-zA-Z_$][\w$]*)' + captures: + 1: keyword.operator.spread.js + 2: variable.parameter.rest.function.js + - include: main + - match: '[a-zA-Z_$][\w$]*' + scope: variable.parameter.function.js + interpolated_js: + - match: '\${' + captures: + 0: punctuation.section.embedded.js + push: + - meta_scope: source.js.embedded.source + - match: "}" + captures: + 0: punctuation.section.embedded.js + pop: true + - match: "{" + captures: + 0: meta.brace.curly.js + push: + - match: "}" + captures: + 0: meta.brace.curly.js + pop: true + - include: main + - include: main + method_calls: + - match: '(\.)\s*([\w$]+)\s*(?=\()' + captures: + 1: meta.delimiter.method.period.js + push: + - meta_scope: meta.method-call.js + - match: (?<=\)) + pop: true + - include: arguments + numbers: + - match: '\b(?>=|>>>=|\|=' + scope: keyword.operator.assignment.compound.bitwise.js + - match: "<<|>>>|>>" + scope: keyword.operator.bitwise.shift.js + - match: "!==|!=|<=|>=|===|==|<|>" + scope: keyword.operator.comparison.js + - match: '&&|!!|!|\|\|' + scope: keyword.operator.logical.js + - match: '&|\||\^|~' + scope: keyword.operator.bitwise.js + - match: "=|:" + scope: keyword.operator.assignment.js + - match: "--" + scope: keyword.operator.decrement.js + - match: \+\+ + scope: keyword.operator.increment.js + - match: '%|\*|/|-|\+' + scope: keyword.operator.js + prevent_object_keys_matching: + - match: (\w+)(?=\s*:) + captures: + properties: + - match: '(\.)\s*([A-Z][A-Z0-9_$]*\b\$*)(?=\s*\.\s*[a-zA-Z_$]\w*)' + captures: + 1: meta.delimiter.property.period.js + 2: constant.other.object.property.js + - match: '(\.)\s*(\$*[a-zA-Z_$][\w$]*)(?=\s*\.\s*[a-zA-Z_$]\w*)' + captures: + 1: meta.delimiter.property.period.js + 2: variable.other.object.property.js + - match: '(\.)\s*([A-Z][A-Z0-9_$]*\b\$*)' + captures: + 1: meta.delimiter.property.period.js + 2: constant.other.property.js + - match: '(\.)\s*(\$*[a-zA-Z_$][\w$]*)' + captures: + 1: meta.delimiter.property.period.js + 2: variable.other.property.js + - match: '(\.)\s*([0-9][\w$]*)' + captures: + 1: meta.delimiter.property.period.js + 2: invalid.illegal.identifier.js + string_escapes: + - match: '\\u(?![A-Fa-f0-9]{4}|{[A-Fa-f0-9]+})[^''"]*' + scope: invalid.illegal.unicode-escape.js + - match: '\\u(?:[A-Fa-f0-9]{4}|({)([A-Fa-f0-9]+)(}))' + scope: constant.character.escape.js + captures: + 1: punctuation.definition.unicode-escape.begin.bracket.curly.js + 3: punctuation.definition.unicode-escape.end.bracket.curly.js + - match: '\\(x[0-9A-Fa-f]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)' + scope: constant.character.escape.js + strings: + - match: "'" + captures: + 0: punctuation.definition.string.begin.js + push: + - meta_scope: string.quoted.single.js + - match: "'" + captures: + 0: punctuation.definition.string.end.js + pop: true + - include: string_escapes + - match: '"' + captures: + 0: punctuation.definition.string.begin.js + push: + - meta_scope: string.quoted.double.js + - match: '"' + captures: + 0: punctuation.definition.string.end.js + pop: true + - include: string_escapes + - match: ((\w+)?(html|HTML|Html))\s*(`) + captures: + 1: entity.name.function.js + 4: punctuation.definition.string.begin.js + push: + - meta_scope: string.quoted.template.html.js + - match: "`" + captures: + 0: punctuation.definition.string.end.js + pop: true + - include: string_escapes + - include: interpolated_js + - include: scope:text.html.basic + - match: (?<=innerHTML)\s*(\+?=)\s*(?=`) + captures: + 1: keyword.operator.assignment.js + push: + - meta_content_scope: string.quoted.template.html.js + - match: (?<=`) + captures: + 0: punctuation.definition.string.end.js + pop: true + - match: "`" + captures: + 0: punctuation.definition.string.begin.js + push: + - match: "`" + captures: + 0: punctuation.definition.string.end.js + pop: true + - include: string_escapes + - include: interpolated_js + - include: scope:text.html.basic + - match: (Relay\.QL|gql)\s*(`) + captures: + 1: entity.name.function.js + 2: punctuation.definition.string.begin.js + push: + - meta_scope: string.quoted.template.graphql.js + - match: "`" + captures: + 0: punctuation.definition.string.end.js + pop: true + - include: string_escapes + - include: interpolated_js + - include: scope:source.graphql + - match: (sql|SQL|Sql)\s*(`) + captures: + 1: entity.name.function.js + 2: punctuation.definition.string.begin.js + push: + - meta_scope: string.quoted.template.sql.js + - match: "`" + captures: + 0: punctuation.definition.string.end.js + pop: true + - include: string_escapes + - include: interpolated_js + - include: scope:source.sql + - match: "`" + captures: + 0: punctuation.definition.string.begin.js + push: + - meta_scope: string.quoted.template.js + - match: "`" + captures: + 0: punctuation.definition.string.end.js + pop: true + - include: string_escapes + - include: interpolated_js + switch_statement: + - match: \bswitch\b + captures: + 0: keyword.control.switch.js + push: + - meta_scope: meta.switch-statement.js + - match: "}" + captures: + 0: punctuation.definition.section.switch-block.end.bracket.curly.js + pop: true + - match: \( + captures: + 0: punctuation.definition.switch-expression.begin.bracket.round.js + push: + - match: \) + captures: + 0: punctuation.definition.switch-expression.end.bracket.round.js + pop: true + - include: main + - match: "{" + captures: + 0: punctuation.definition.section.switch-block.begin.bracket.curly.js + push: + - match: "(?=})" + pop: true + - match: \bcase\b + captures: + 0: keyword.control.case.js + push: + - match: ":" + captures: + 0: punctuation.definition.section.case-statement.js + pop: true + - include: prevent_object_keys_matching + - include: main + - match: (?:^\s*)?\b(default)\b\s*(:) + captures: + 1: keyword.control.default.js + 2: punctuation.definition.section.case-statement.js + - include: main diff --git a/syntect/minimal_grammars/ruby.sublime-syntax b/syntect/minimal_grammars/ruby.sublime-syntax new file mode 100644 index 0000000..7bcd04a --- /dev/null +++ b/syntect/minimal_grammars/ruby.sublime-syntax @@ -0,0 +1,1531 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: Ruby +file_extensions: + - Appfile + - Appraisals + - arb + - Berksfile + - Brewfile + - cap + - Capfile + - capfile + - cgi + - cr + - Dangerfile + - Deliverfile + - Fastfile + - fcgi + - gemspec + - Guardfile + - irbrc + - opal + - Podfile + - podspec + - prawn + - pryrc + - Puppetfile + - rabl + - rake + - Rakefile + - Rantfile + - rb + - rbx + - rjs + - ru + - ruby + - Schemafile + - Snapfile + - thor + - Thorfile + - Vagrantfile +first_line_match: |- + (?x) + # Hashbang + ^\#!.*(?:\s|\/) + (?:ruby|macruby|rake|jruby|rbx|ruby_executable_hooks) + (?:$|\s) + | + # Modeline + (?i: + # Emacs + -\*-(?:\s*(?=[^:;\s]+\s*-\*-)|(?:.*?[;\s]|(?<=-\*-))mode\s*:\s*) + ruby + (?=[\s;]|(?]?\d+|m)?|\sex)(?=:(?=\s*set?\s[^\n:]+:)|:(?!\s*set?\s))(?:(?:\s|\s*:\s*)\w*(?:\s*=(?:[^\n\\\s]|\\.)*)?)*[\s:](?:filetype|ft|syntax)\s*= + ruby + (?=\s|:|$) + ) +scope: source.ruby +contexts: + main: + - match: |- + (?x) + ^\s*(class)\s+ + ( + ( + [.a-zA-Z0-9_:]+ + (\s*(<)\s*[.a-zA-Z0-9_:]+)? # class A < B + ) + | + ((<<)\s*[.a-zA-Z0-9_:]+) # class << C + ) + scope: meta.class.ruby + captures: + 1: keyword.control.class.ruby + 2: entity.name.type.class.ruby + 4: entity.other.inherited-class.ruby + 5: punctuation.separator.inheritance.ruby + 6: variable.other.object.ruby + 7: punctuation.definition.variable.ruby + - match: |- + (?x) + ^\s*(module)\s+ + ( + ([A-Z]\w*(::))? + ([A-Z]\w*(::))? + ([A-Z]\w*(::))* + [A-Z]\w* + ) + scope: meta.module.ruby + captures: + 1: keyword.control.module.ruby + 2: entity.name.type.module.ruby + 3: entity.other.inherited-class.module.first.ruby + 4: punctuation.separator.inheritance.ruby + 5: entity.other.inherited-class.module.second.ruby + 6: punctuation.separator.inheritance.ruby + 7: entity.other.inherited-class.module.third.ruby + 8: punctuation.separator.inheritance.ruby + - match: (?[a-zA-Z_]\w*(?>[?!])?)(:)(?!:)' + comment: symbols as hash key (1.9 syntax) + scope: constant.other.symbol.hashkey.ruby + captures: + 1: punctuation.definition.constant.hashkey.ruby + - match: '(?[a-zA-Z_]\w*(?>[?!])?)(?=\s*=>)' + comment: symbols as hash key (1.8 syntax) + scope: constant.other.symbol.hashkey.ruby + captures: + 1: punctuation.definition.constant.ruby + - match: '(?|_|\*|\$|\?|:|"|-[0adFiIlpv])' + scope: variable.other.readwrite.global.pre-defined.ruby + captures: + 1: punctuation.definition.variable.ruby + - match: '\b(ENV)\[' + captures: + 1: variable.other.constant.ruby + push: + - meta_scope: meta.environment-variable.ruby + - match: "]" + pop: true + - include: main + - match: '\b[A-Z]\w*(?=((\.|::)[A-Za-z]|\[))' + scope: support.class.ruby + - match: '\b((abort|at_exit|autoload|binding|callcc|caller|caller_locations|chomp|chop|eval|exec|exit|fork|format|gets|global_variables|gsub|lambda|load|local_variables|open|p|print|printf|proc|putc|puts|rand|readline|readlines|select|set_trace_func|sleep|spawn|sprintf|srand|sub|syscall|system|test|trace_var|trap|untrace_var|warn)\b(?![?!])|autoload\?|exit!)' + scope: support.function.kernel.ruby + - match: '\b[_A-Z]\w*\b' + scope: variable.other.constant.ruby + - match: |- + (?x) + (?=def\b) # optimization to help Oniguruma fail fast + (?<=^|\s)(def)\s+ + ( + (?>[a-zA-Z_]\w*(?>\.|::))? # method prefix + (?> # method name + [a-zA-Z_]\w*(?>[?!]|=(?!>))? + | + ===?|!=|>[>=]?|<=>|<[<=]?|[%&`/\|]|\*\*?|=?~|[-+]@?|\[]=? + ) + ) + \s*(\() + comment: The method pattern comes from the symbol pattern. See there for an explanation. + captures: + 1: keyword.control.def.ruby + 2: entity.name.function.ruby + 3: punctuation.definition.parameters.ruby + push: + - meta_scope: meta.function.method.with-arguments.ruby + - match: \) + captures: + 0: punctuation.definition.parameters.ruby + pop: true + - match: '(?![\s,)])' + push: + - match: (?=,|\)\s*$) + pop: true + - match: '\G([&*]?)(?:([_a-zA-Z]\w*(:))|([_a-zA-Z]\w*))' + captures: + 1: storage.type.variable.ruby + 2: constant.other.symbol.hashkey.parameter.function.ruby + 3: punctuation.definition.constant.hashkey.ruby + 4: variable.parameter.function.ruby + - include: main + - match: |- + (?x) + (?=def\b) # optimization to help Oniguruma fail fast + (?<=^|\s)(def)\s+ + ( + (?>[a-zA-Z_]\w*(?>\.|::))? # method prefix + (?> # method name + [a-zA-Z_]\w*(?>[?!]|=(?!>))? + | + ===?|!=|>[>=]?|<=>|<[<=]?|[%&`/\|]|\*\*?|=?~|[-+]@?|\[]=? + ) + ) + [ \t] + (?=[ \t]*[^\s#;]) # make sure the following is not comment + comment: same as the previous rule, but without parentheses around the arguments + captures: + 1: keyword.control.def.ruby + 2: entity.name.function.ruby + push: + - meta_scope: meta.function.method.with-arguments.ruby + - match: $ + pop: true + - match: '(?![\s,])' + push: + - match: (?=,|$) + pop: true + - match: '\G([&*]?)(?:([_a-zA-Z]\w*(:))|([_a-zA-Z]\w*))' + captures: + 1: storage.type.variable.ruby + 2: constant.other.symbol.hashkey.parameter.function.ruby + 3: punctuation.definition.constant.hashkey.ruby + 4: variable.parameter.function.ruby + - include: main + - match: |- + (?x) + (?=def\b) # optimization to help Oniguruma fail fast + (?<=^|\s)(def)\b + ( + \s+ + ( + (?>[a-zA-Z_]\w*(?>\.|::))? # method prefix + (?> # method name + [a-zA-Z_]\w*(?>[?!]|=(?!>))? + | + ===?|!=|>[>=]?|<=>|<[<=]?|[%&`/\|]|\*\*?|=?~|[-+]@?|\[]=? + ) + ) + )? + comment: the optional name is just to catch the def also without a method-name + scope: meta.function.method.without-arguments.ruby + captures: + 1: keyword.control.def.ruby + 3: entity.name.function.ruby + - match: |- + (?x) + \b + ( + [\d](?>_?\d)* # 100_000 + (\.(?![^[:space:][:digit:]])(?>_?\d)*)? # fractional part + ([eE][-+]?\d(?>_?\d)*)? # 1.23e-4 + | + 0 + (?: + [xX]\h(?>_?\h)*| + [oO]?[0-7](?>_?[0-7])*| + [bB][01](?>_?[01])*| + [dD]\d(?>_?\d)* + ) # A base indicator can only be used with an integer + )\b + scope: constant.numeric.ruby + - match: ":'" + comment: symbol literal with '' delimitor + captures: + 0: punctuation.definition.symbol.begin.ruby + push: + - meta_scope: constant.other.symbol.ruby + - match: "'" + captures: + 0: punctuation.definition.symbol.end.ruby + pop: true + - match: '\\[''\\]' + scope: constant.character.escape.ruby + - match: ':"' + comment: symbol literal with "" delimitor + captures: + 0: punctuation.section.symbol.begin.ruby + push: + - meta_scope: constant.other.symbol.interpolated.ruby + - match: '"' + captures: + 0: punctuation.section.symbol.end.ruby + pop: true + - include: interpolated_ruby + - include: escaped_char + - match: (?|=>|==|=~|!~|!=|;|$| + if|else|elsif|then|do|end|unless|while|until|or|and + ) + | + $ + ) + comment: regular expression literal with interpolation + captures: + 1: string.regexp.interpolated.ruby + 2: punctuation.section.regexp.ruby + push: + - meta_content_scope: string.regexp.interpolated.ruby + - match: "((/[eimnosux]*))" + captures: + 1: string.regexp.interpolated.ruby + 2: punctuation.section.regexp.ruby + pop: true + - include: regex_sub + - match: "%r{" + captures: + 0: punctuation.section.regexp.begin.ruby + push: + - meta_scope: string.regexp.interpolated.ruby + - match: "}[eimnosux]*" + captures: + 0: punctuation.section.regexp.end.ruby + pop: true + - include: regex_sub + - include: nest_curly_r + - match: '%r\[' + captures: + 0: punctuation.section.regexp.begin.ruby + push: + - meta_scope: string.regexp.interpolated.ruby + - match: "][eimnosux]*" + captures: + 0: punctuation.section.regexp.end.ruby + pop: true + - include: regex_sub + - include: nest_brackets_r + - match: '%r\(' + captures: + 0: punctuation.section.regexp.begin.ruby + push: + - meta_scope: string.regexp.interpolated.ruby + - match: '\)[eimnosux]*' + captures: + 0: punctuation.section.regexp.end.ruby + pop: true + - include: regex_sub + - include: nest_parens_r + - match: "%r<" + captures: + 0: punctuation.section.regexp.begin.ruby + push: + - meta_scope: string.regexp.interpolated.ruby + - match: ">[eimnosux]*" + captures: + 0: punctuation.section.regexp.end.ruby + pop: true + - include: regex_sub + - include: nest_ltgt_r + - match: '%r([^\w])' + captures: + 0: punctuation.section.regexp.begin.ruby + push: + - meta_scope: string.regexp.interpolated.ruby + - match: '\1[eimnosux]*' + captures: + 0: punctuation.section.regexp.end.ruby + pop: true + - include: regex_sub + - match: '%I\[' + captures: + 0: punctuation.section.array.begin.ruby + push: + - meta_scope: constant.other.symbol.interpolated.ruby + - match: "]" + captures: + 0: punctuation.section.array.end.ruby + pop: true + - include: interpolated_ruby + - include: escaped_char + - include: nest_brackets_i + - match: '%I\(' + captures: + 0: punctuation.section.array.begin.ruby + push: + - meta_scope: constant.other.symbol.interpolated.ruby + - match: \) + captures: + 0: punctuation.section.array.end.ruby + pop: true + - include: interpolated_ruby + - include: escaped_char + - include: nest_parens_i + - match: "%I<" + captures: + 0: punctuation.section.array.begin.ruby + push: + - meta_scope: constant.other.symbol.interpolated.ruby + - match: ">" + captures: + 0: punctuation.section.array.end.ruby + pop: true + - include: interpolated_ruby + - include: escaped_char + - include: nest_ltgt_i + - match: "%I{" + captures: + 0: punctuation.section.array.begin.ruby + push: + - meta_scope: constant.other.symbol.interpolated.ruby + - match: "}" + captures: + 0: punctuation.section.array.end.ruby + pop: true + - include: interpolated_ruby + - include: escaped_char + - include: nest_curly_i + - match: '%I([^\w])' + captures: + 0: punctuation.section.array.begin.ruby + push: + - meta_scope: constant.other.symbol.interpolated.ruby + - match: \1 + captures: + 0: punctuation.section.array.end.ruby + pop: true + - include: interpolated_ruby + - include: escaped_char + - match: '%i\[' + captures: + 0: punctuation.section.array.begin.ruby + push: + - meta_scope: constant.other.symbol.ruby + - match: "]" + captures: + 0: punctuation.section.array.end.ruby + pop: true + - match: '\\]|\\\\' + scope: constant.character.escape.ruby + - include: nest_brackets + - match: '%i\(' + captures: + 0: punctuation.section.array.begin.ruby + push: + - meta_scope: constant.other.symbol.ruby + - match: \) + captures: + 0: punctuation.section.array.end.ruby + pop: true + - match: \\\)|\\\\ + scope: constant.character.escape.ruby + - include: nest_parens + - match: "%i<" + captures: + 0: punctuation.section.array.begin.ruby + push: + - meta_scope: constant.other.symbol.ruby + - match: ">" + captures: + 0: punctuation.section.array.end.ruby + pop: true + - match: \\>|\\\\ + scope: constant.character.escape.ruby + - include: nest_ltgt + - match: "%i{" + captures: + 0: punctuation.section.array.begin.ruby + push: + - meta_scope: constant.other.symbol.ruby + - match: "}" + captures: + 0: punctuation.section.array.end.ruby + pop: true + - match: '\\}|\\\\' + scope: constant.character.escape.ruby + - include: nest_curly + - match: '%i([^\w])' + captures: + 0: punctuation.section.array.begin.ruby + push: + - meta_scope: constant.other.symbol.ruby + - match: \1 + captures: + 0: punctuation.section.array.end.ruby + pop: true + - match: \\. + comment: Cant be named because its not neccesarily an escape. + - match: '%W\[' + captures: + 0: punctuation.section.array.begin.ruby + push: + - meta_scope: string.quoted.other.interpolated.ruby + - match: "]" + captures: + 0: punctuation.section.array.end.ruby + pop: true + - include: interpolated_ruby + - include: escaped_char + - include: nest_brackets_i + - match: '%W\(' + captures: + 0: punctuation.section.array.begin.ruby + push: + - meta_scope: string.quoted.other.interpolated.ruby + - match: \) + captures: + 0: punctuation.section.array.end.ruby + pop: true + - include: interpolated_ruby + - include: escaped_char + - include: nest_parens_i + - match: "%W<" + captures: + 0: punctuation.section.array.begin.ruby + push: + - meta_scope: string.quoted.other.interpolated.ruby + - match: ">" + captures: + 0: punctuation.section.array.end.ruby + pop: true + - include: interpolated_ruby + - include: escaped_char + - include: nest_ltgt_i + - match: "%W{" + captures: + 0: punctuation.section.array.begin.ruby + push: + - meta_scope: string.quoted.other.interpolated.ruby + - match: "}" + captures: + 0: punctuation.section.array.end.ruby + pop: true + - include: interpolated_ruby + - include: escaped_char + - include: nest_curly_i + - match: '%W([^\w])' + captures: + 0: punctuation.section.array.begin.ruby + push: + - meta_scope: string.quoted.other.interpolated.ruby + - match: \1 + captures: + 0: punctuation.section.array.end.ruby + pop: true + - include: interpolated_ruby + - include: escaped_char + - match: '%w\[' + captures: + 0: punctuation.section.array.begin.ruby + push: + - meta_scope: string.quoted.other.ruby + - match: "]" + captures: + 0: punctuation.section.array.end.ruby + pop: true + - match: '\\]|\\\\' + scope: constant.character.escape.ruby + - include: nest_brackets + - match: '%w\(' + captures: + 0: punctuation.section.array.begin.ruby + push: + - meta_scope: string.quoted.other.ruby + - match: \) + captures: + 0: punctuation.section.array.end.ruby + pop: true + - match: \\\)|\\\\ + scope: constant.character.escape.ruby + - include: nest_parens + - match: "%w<" + captures: + 0: punctuation.section.array.begin.ruby + push: + - meta_scope: string.quoted.other.ruby + - match: ">" + captures: + 0: punctuation.section.array.end.ruby + pop: true + - match: \\>|\\\\ + scope: constant.character.escape.ruby + - include: nest_ltgt + - match: "%w{" + captures: + 0: punctuation.section.array.begin.ruby + push: + - meta_scope: string.quoted.other.ruby + - match: "}" + captures: + 0: punctuation.section.array.end.ruby + pop: true + - match: '\\}|\\\\' + scope: constant.character.escape.ruby + - include: nest_curly + - match: '%w([^\w])' + captures: + 0: punctuation.section.array.begin.ruby + push: + - meta_scope: string.quoted.other.ruby + - match: \1 + captures: + 0: punctuation.section.array.end.ruby + pop: true + - match: \\. + comment: Cant be named because its not neccesarily an escape. + - match: '%[Qx]?\(' + captures: + 0: punctuation.definition.string.begin.ruby + push: + - meta_scope: string.quoted.other.interpolated.ruby + - match: \) + captures: + 0: punctuation.definition.string.end.ruby + pop: true + - include: interpolated_ruby + - include: escaped_char + - include: nest_parens_i + - match: '%[Qx]?\[' + captures: + 0: punctuation.definition.string.begin.ruby + push: + - meta_scope: string.quoted.other.interpolated.ruby + - match: "]" + captures: + 0: punctuation.definition.string.end.ruby + pop: true + - include: interpolated_ruby + - include: escaped_char + - include: nest_brackets_i + - match: "%[Qx]?{" + captures: + 0: punctuation.definition.string.begin.ruby + push: + - meta_scope: string.quoted.other.interpolated.ruby + - match: "}" + captures: + 0: punctuation.definition.string.end.ruby + pop: true + - include: interpolated_ruby + - include: escaped_char + - include: nest_curly_i + - match: "%[Qx]?<" + captures: + 0: punctuation.definition.string.begin.ruby + push: + - meta_scope: string.quoted.other.interpolated.ruby + - match: ">" + captures: + 0: punctuation.definition.string.end.ruby + pop: true + - include: interpolated_ruby + - include: escaped_char + - include: nest_ltgt_i + - match: '%[Qx]([^\w])' + captures: + 0: punctuation.definition.string.begin.ruby + push: + - meta_scope: string.quoted.other.interpolated.ruby + - match: \1 + captures: + 0: punctuation.definition.string.end.ruby + pop: true + - include: interpolated_ruby + - include: escaped_char + - match: '%([^\w\s=])' + captures: + 0: punctuation.definition.string.begin.ruby + push: + - meta_scope: string.quoted.other.interpolated.ruby + - match: \1 + captures: + 0: punctuation.definition.string.end.ruby + pop: true + - include: interpolated_ruby + - include: escaped_char + - match: '%q\(' + captures: + 0: punctuation.definition.string.begin.ruby + push: + - meta_scope: string.quoted.other.ruby + - match: \) + captures: + 0: punctuation.definition.string.end.ruby + pop: true + - match: \\\)|\\\\ + scope: constant.character.escape.ruby + - include: nest_parens + - match: "%q<" + captures: + 0: punctuation.definition.string.begin.ruby + push: + - meta_scope: string.quoted.other.ruby + - match: ">" + captures: + 0: punctuation.definition.string.end.ruby + pop: true + - match: \\>|\\\\ + scope: constant.character.escape.ruby + - include: nest_ltgt + - match: '%q\[' + captures: + 0: punctuation.definition.string.begin.ruby + push: + - meta_scope: string.quoted.other.ruby + - match: "]" + captures: + 0: punctuation.definition.string.end.ruby + pop: true + - match: '\\]|\\\\' + scope: constant.character.escape.ruby + - include: nest_brackets + - match: "%q{" + captures: + 0: punctuation.definition.string.begin.ruby + push: + - meta_scope: string.quoted.other.ruby + - match: "}" + captures: + 0: punctuation.definition.string.end.ruby + pop: true + - match: '\\}|\\\\' + scope: constant.character.escape.ruby + - include: nest_curly + - match: '%q([^\w])' + captures: + 0: punctuation.definition.string.begin.ruby + push: + - meta_scope: string.quoted.other.ruby + - match: \1 + captures: + 0: punctuation.definition.string.end.ruby + pop: true + - match: \\. + comment: Cant be named because its not neccesarily an escape. + - match: '%s\(' + captures: + 0: punctuation.definition.symbol.begin.ruby + push: + - meta_scope: constant.other.symbol.ruby + - match: \) + captures: + 0: punctuation.definition.symbol.end.ruby + pop: true + - match: \\\)|\\\\ + scope: constant.character.escape.ruby + - include: nest_parens + - match: "%s<" + captures: + 0: punctuation.definition.symbol.begin.ruby + push: + - meta_scope: constant.other.symbol.ruby + - match: ">" + captures: + 0: punctuation.definition.symbol.end.ruby + pop: true + - match: \\>|\\\\ + scope: constant.character.escape.ruby + - include: nest_ltgt + - match: '%s\[' + captures: + 0: punctuation.definition.symbol.begin.ruby + push: + - meta_scope: constant.other.symbol.ruby + - match: "]" + captures: + 0: punctuation.definition.symbol.end.ruby + pop: true + - match: '\\]|\\\\' + scope: constant.character.escape.ruby + - include: nest_brackets + - match: "%s{" + captures: + 0: punctuation.definition.symbol.begin.ruby + push: + - meta_scope: constant.other.symbol.ruby + - match: "}" + captures: + 0: punctuation.definition.symbol.end.ruby + pop: true + - match: '\\}|\\\\' + scope: constant.character.escape.ruby + - include: nest_curly + - match: '%s([^\w])' + captures: + 0: punctuation.definition.symbol.begin.ruby + push: + - meta_scope: constant.other.symbol.ruby + - match: \1 + captures: + 0: punctuation.definition.symbol.end.ruby + pop: true + - match: \\. + comment: Cant be named because its not neccesarily an escape. + - match: |- + (?x) + (? + [$a-zA-Z_]\w*(?>[?!]|=(?![>=]))? + | + ===?|<=>|>[>=]?|<[<=]?|[%&`/\|]|\*\*?|=?~|[-+]@?|\[]=? + | + @@?[a-zA-Z_]\w* + ) + comment: symbols + scope: constant.other.symbol.ruby + captures: + 1: punctuation.definition.constant.ruby + - match: ^=begin + comment: multiline comments + captures: + 0: punctuation.definition.comment.ruby + push: + - meta_scope: comment.block.documentation.ruby + - match: ^=end + captures: + 0: punctuation.definition.comment.ruby + pop: true + - match: '(^[ \t]+)?(?=#)' + captures: + 1: punctuation.whitespace.comment.leading.ruby + push: + - match: (?!\G) + pop: true + - match: "#" + captures: + 0: punctuation.definition.comment.ruby + push: + - meta_scope: comment.line.number-sign.ruby + - match: \n + pop: true + - include: yard + - match: '(?<<[-~](["''`]?)((?:[_\w]+_|)HTML)\b\1))' + comment: Heredoc with embedded html + push: + - meta_scope: meta.embedded.block.html + - match: (?!\G) + pop: true + - match: '(?><<[-~](["''`]?)((?:[_\w]+_|)HTML)\b\1)' + captures: + 0: punctuation.definition.string.begin.ruby + push: + - meta_scope: string.unquoted.heredoc.ruby + - meta_content_scope: text.html + - match: ^\s*\2$\n? + captures: + 0: punctuation.definition.string.end.ruby + pop: true + - include: heredoc + - include: interpolated_ruby + - include: scope:text.html.basic + - include: escaped_char + - match: '(?=(?><<[-~](["''`]?)((?:[_\w]+_|)XML)\b\1))' + comment: Heredoc with embedded xml + push: + - meta_scope: meta.embedded.block.xml + - match: (?!\G) + pop: true + - match: '(?><<[-~](["''`]?)((?:[_\w]+_|)XML)\b\1)' + captures: + 0: punctuation.definition.string.begin.ruby + push: + - meta_scope: string.unquoted.heredoc.ruby + - meta_content_scope: text.xml + - match: ^\s*\2$\n? + captures: + 0: punctuation.definition.string.end.ruby + pop: true + - include: heredoc + - include: interpolated_ruby + - include: scope:text.xml + - include: escaped_char + - match: '(?=(?><<[-~](["''`]?)((?:[_\w]+_|)SQL)\b\1))' + comment: Heredoc with embedded sql + push: + - meta_scope: meta.embedded.block.sql + - match: (?!\G) + pop: true + - match: '(?><<[-~](["''`]?)((?:[_\w]+_|)SQL)\b\1)' + captures: + 0: punctuation.definition.string.begin.ruby + push: + - meta_scope: string.unquoted.heredoc.ruby + - meta_content_scope: source.sql + - match: ^\s*\2$\n? + captures: + 0: punctuation.definition.string.end.ruby + pop: true + - include: heredoc + - include: interpolated_ruby + - include: scope:source.sql + - include: escaped_char + - match: '(?=(?><<[-~](["''`]?)((?:[_\w]+_|)GRAPHQL)\b\1))' + comment: Heredoc with embedded GraphQL + push: + - meta_scope: meta.embedded.block.graphql + - match: (?!\G) + pop: true + - match: '(?><<[-~](["''`]?)((?:[_\w]+_|)GRAPHQL)\b\1)' + captures: + 0: punctuation.definition.string.begin.ruby + push: + - meta_scope: string.unquoted.heredoc.ruby + - meta_content_scope: source.graphql + - match: ^\s*\2$\n? + captures: + 0: punctuation.definition.string.end.ruby + pop: true + - include: heredoc + - include: interpolated_ruby + - include: scope:source.graphql + - include: escaped_char + - match: '(?=(?><<[-~](["''`]?)((?:[_\w]+_|)CSS)\b\1))' + comment: Heredoc with embedded css + push: + - meta_scope: meta.embedded.block.css + - match: (?!\G) + pop: true + - match: '(?><<[-~](["''`]?)((?:[_\w]+_|)CSS)\b\1)' + captures: + 0: punctuation.definition.string.begin.ruby + push: + - meta_scope: string.unquoted.heredoc.ruby + - meta_content_scope: source.css + - match: ^\s*\2$\n? + captures: + 0: punctuation.definition.string.end.ruby + pop: true + - include: heredoc + - include: interpolated_ruby + - include: scope:source.css + - include: escaped_char + - match: '(?=(?><<[-~](["''`]?)((?:[_\w]+_|)CPP)\b\1))' + comment: Heredoc with embedded c++ + push: + - meta_scope: meta.embedded.block.cpp + - match: (?!\G) + pop: true + - match: '(?><<[-~](["''`]?)((?:[_\w]+_|)CPP)\b\1)' + captures: + 0: punctuation.definition.string.begin.ruby + push: + - meta_scope: string.unquoted.heredoc.ruby + - meta_content_scope: source.cpp + - match: ^\s*\2$\n? + captures: + 0: punctuation.definition.string.end.ruby + pop: true + - include: heredoc + - include: interpolated_ruby + - include: scope:source.cpp + - include: escaped_char + - match: '(?=(?><<[-~](["''`]?)((?:[_\w]+_|)C)\b\1))' + comment: Heredoc with embedded c + push: + - meta_scope: meta.embedded.block.c + - match: (?!\G) + pop: true + - match: '(?><<[-~](["''`]?)((?:[_\w]+_|)C)\b\1)' + captures: + 0: punctuation.definition.string.begin.ruby + push: + - meta_scope: string.unquoted.heredoc.ruby + - meta_content_scope: source.c + - match: ^\s*\2$\n? + captures: + 0: punctuation.definition.string.end.ruby + pop: true + - include: heredoc + - include: interpolated_ruby + - include: scope:source.c + - include: escaped_char + - match: '(?=(?><<[-~](["''`]?)((?:[_\w]+_|)(?:JS|JAVASCRIPT))\b\1))' + comment: Heredoc with embedded javascript + push: + - meta_scope: meta.embedded.block.js + - match: (?!\G) + pop: true + - match: '(?><<[-~](["''`]?)((?:[_\w]+_|)(?:JS|JAVASCRIPT))\b\1)' + captures: + 0: punctuation.definition.string.begin.ruby + push: + - meta_scope: string.unquoted.heredoc.ruby + - meta_content_scope: source.js + - match: ^\s*\2$\n? + captures: + 0: punctuation.definition.string.end.ruby + pop: true + - include: heredoc + - include: interpolated_ruby + - include: scope:source.js + - include: escaped_char + - match: '(?=(?><<[-~](["''`]?)((?:[_\w]+_|)JQUERY)\b\1))' + comment: Heredoc with embedded jQuery javascript + push: + - meta_scope: meta.embedded.block.js.jquery + - match: (?!\G) + pop: true + - match: '(?><<[-~](["''`]?)((?:[_\w]+_|)JQUERY)\b\1)' + captures: + 0: punctuation.definition.string.begin.ruby + push: + - meta_scope: string.unquoted.heredoc.ruby + - meta_content_scope: source.js.jquery + - match: ^\s*\2$\n? + captures: + 0: punctuation.definition.string.end.ruby + pop: true + - include: heredoc + - include: interpolated_ruby + - include: scope:source.js.jquery + - include: escaped_char + - match: '(?=(?><<[-~](["''`]?)((?:[_\w]+_|)(?:SH|SHELL))\b\1))' + comment: Heredoc with embedded shell + push: + - meta_scope: meta.embedded.block.shell + - match: (?!\G) + pop: true + - match: '(?><<[-~](["''`]?)((?:[_\w]+_|)(?:SH|SHELL))\b\1)' + captures: + 0: punctuation.definition.string.begin.ruby + push: + - meta_scope: string.unquoted.heredoc.ruby + - meta_content_scope: source.shell + - match: ^\s*\2$\n? + captures: + 0: punctuation.definition.string.end.ruby + pop: true + - include: heredoc + - include: interpolated_ruby + - include: scope:source.shell + - include: escaped_char + - match: '(?=(?><<[-~](["''`]?)((?:[_\w]+_|)LUA)\b\1))' + comment: Heredoc with embedded lua + push: + - meta_scope: meta.embedded.block.lua + - match: (?!\G) + pop: true + - match: '(?><<[-~](["''`]?)((?:[_\w]+_|)LUA)\b\1)' + captures: + 0: punctuation.definition.string.begin.ruby + push: + - meta_scope: string.unquoted.heredoc.ruby + - meta_content_scope: source.lua + - match: ^\s*\2$\n? + captures: + 0: punctuation.definition.string.end.ruby + pop: true + - include: heredoc + - include: interpolated_ruby + - include: scope:source.lua + - include: escaped_char + - match: '(?=(?><<[-~](["''`]?)((?:[_\w]+_|)RUBY)\b\1))' + comment: Heredoc with embedded ruby + push: + - meta_scope: meta.embedded.block.ruby + - match: (?!\G) + pop: true + - match: '(?><<[-~](["''`]?)((?:[_\w]+_|)RUBY)\b\1)' + captures: + 0: punctuation.definition.string.begin.ruby + push: + - meta_scope: string.unquoted.heredoc.ruby + - meta_content_scope: source.ruby + - match: ^\s*\2$\n? + captures: + 0: punctuation.definition.string.end.ruby + pop: true + - include: heredoc + - include: interpolated_ruby + - include: scope:source.ruby + - include: escaped_char + - match: '(?>=\s*<<(["''`]?)(\w+)\1)' + captures: + 0: punctuation.definition.string.begin.ruby + push: + - meta_scope: string.unquoted.heredoc.ruby + - match: ^\2$ + captures: + 0: punctuation.definition.string.end.ruby + pop: true + - include: heredoc + - include: interpolated_ruby + - include: escaped_char + - match: '(?>((<<[-~](["''`]?)(\w+)\3,\s?)*<<[-~](["''`]?)(\w+)\5))' + comment: heredoc with multiple inputs and indented terminator + captures: + 0: punctuation.definition.string.begin.ruby + push: + - meta_scope: string.unquoted.heredoc.ruby + - match: ^\s*\6$ + captures: + 0: punctuation.definition.string.end.ruby + pop: true + - include: heredoc + - include: interpolated_ruby + - include: escaped_char + - match: '(?<={|{\s|[^A-Za-z0-9_]do|^do|[^A-Za-z0-9_]do\s|^do\s)(\|)' + captures: + 1: punctuation.separator.variable.ruby + push: + - match: (?" + scope: punctuation.separator.key-value + - match: "->" + scope: support.function.kernel.ruby + - match: '<<=|%=|&{1,2}=|\*=|\*\*=|\+=|-=|\^=|\|{1,2}=|<<' + scope: keyword.operator.assignment.augmented.ruby + - match: '<=>|<(?!<|=)|>(?!<|=|>)|<=|>=|===|==|=~|!=|!~|(?<=[ \t])\?' + scope: keyword.operator.comparison.ruby + - match: '(?> + scope: keyword.operator.other.ruby + - match: ; + scope: punctuation.separator.statement.ruby + - match: "," + scope: punctuation.separator.object.ruby + - match: '(::)\s*(?=[A-Z])' + comment: Mark as namespace separator if double colons followed by capital letter + captures: + 1: punctuation.separator.namespace.ruby + - match: '(\.|::)\s*(?![A-Z])' + comment: Mark as method separator if double colons not followed by capital letter + captures: + 1: punctuation.separator.method.ruby + - match: ":" + comment: Must come after method and constant separators to prefer double colons + scope: punctuation.separator.other.ruby + - match: "{" + scope: punctuation.section.scope.begin.ruby + - match: "}" + scope: punctuation.section.scope.end.ruby + - match: '\[' + scope: punctuation.section.array.begin.ruby + - match: "]" + scope: punctuation.section.array.end.ruby + - match: \(|\) + scope: punctuation.section.function.ruby + escaped_char: + - match: '\\(?:[0-7]{1,3}|x[\da-fA-F]{1,2}|.)' + scope: constant.character.escape.ruby + heredoc: + - match: '^<<[-~]?\w+' + push: + - match: $ + pop: true + - include: main + interpolated_ruby: + - match: "#{" + captures: + 0: punctuation.section.embedded.begin.ruby + push: + - meta_scope: meta.embedded.line.ruby + - meta_content_scope: source.ruby + - match: "}" + captures: + 0: punctuation.section.embedded.end.ruby + pop: true + - include: nest_curly_and_self + - include: main + - match: '(#@)[a-zA-Z_]\w*' + scope: variable.other.readwrite.instance.ruby + captures: + 1: punctuation.definition.variable.ruby + - match: '(#@@)[a-zA-Z_]\w*' + scope: variable.other.readwrite.class.ruby + captures: + 1: punctuation.definition.variable.ruby + - match: '(#\$)[a-zA-Z_]\w*' + scope: variable.other.readwrite.global.ruby + captures: + 1: punctuation.definition.variable.ruby + nest_brackets: + - match: '\[' + captures: + 0: punctuation.section.scope.ruby + push: + - match: "]" + captures: + 0: punctuation.section.scope.ruby + pop: true + - include: nest_brackets + nest_brackets_i: + - match: '\[' + captures: + 0: punctuation.section.scope.ruby + push: + - match: "]" + captures: + 0: punctuation.section.scope.ruby + pop: true + - include: interpolated_ruby + - include: escaped_char + - include: nest_brackets_i + nest_brackets_r: + - match: '\[' + captures: + 0: punctuation.section.scope.ruby + push: + - match: "]" + captures: + 0: punctuation.section.scope.ruby + pop: true + - include: regex_sub + - include: nest_brackets_r + nest_curly: + - match: "{" + captures: + 0: punctuation.section.scope.ruby + push: + - match: "}" + captures: + 0: punctuation.section.scope.ruby + pop: true + - include: nest_curly + nest_curly_and_self: + - match: "{" + captures: + 0: punctuation.section.scope.ruby + push: + - match: "}" + captures: + 0: punctuation.section.scope.ruby + pop: true + - include: nest_curly_and_self + - include: main + nest_curly_i: + - match: "{" + captures: + 0: punctuation.section.scope.ruby + push: + - match: "}" + captures: + 0: punctuation.section.scope.ruby + pop: true + - include: interpolated_ruby + - include: escaped_char + - include: nest_curly_i + nest_curly_r: + - match: "{" + captures: + 0: punctuation.section.scope.ruby + push: + - match: "}" + captures: + 0: punctuation.section.scope.ruby + pop: true + - include: regex_sub + - include: nest_curly_r + nest_ltgt: + - match: < + captures: + 0: punctuation.section.scope.ruby + push: + - match: ">" + captures: + 0: punctuation.section.scope.ruby + pop: true + - include: nest_ltgt + nest_ltgt_i: + - match: < + captures: + 0: punctuation.section.scope.ruby + push: + - match: ">" + captures: + 0: punctuation.section.scope.ruby + pop: true + - include: interpolated_ruby + - include: escaped_char + - include: nest_ltgt_i + nest_ltgt_r: + - match: < + captures: + 0: punctuation.section.scope.ruby + push: + - match: ">" + captures: + 0: punctuation.section.scope.ruby + pop: true + - include: regex_sub + - include: nest_ltgt_r + nest_parens: + - match: \( + captures: + 0: punctuation.section.scope.ruby + push: + - match: \) + captures: + 0: punctuation.section.scope.ruby + pop: true + - include: nest_parens + nest_parens_i: + - match: \( + captures: + 0: punctuation.section.scope.ruby + push: + - match: \) + captures: + 0: punctuation.section.scope.ruby + pop: true + - include: interpolated_ruby + - include: escaped_char + - include: nest_parens_i + nest_parens_r: + - match: \( + captures: + 0: punctuation.section.scope.ruby + push: + - match: \) + captures: + 0: punctuation.section.scope.ruby + pop: true + - include: regex_sub + - include: nest_parens_r + regex_sub: + - include: interpolated_ruby + - include: escaped_char + - match: '({)\d+(,\d+)?(})' + scope: string.regexp.arbitrary-repetition.ruby + captures: + 1: punctuation.definition.arbitrary-repetition.ruby + 3: punctuation.definition.arbitrary-repetition.ruby + - match: '\[(?:\^?])?' + captures: + 0: punctuation.definition.character-class.ruby + push: + - meta_scope: string.regexp.character-class.ruby + - match: "]" + captures: + 0: punctuation.definition.character-class.ruby + pop: true + - include: escaped_char + - match: '\(\?#' + captures: + 0: punctuation.definition.comment.begin.ruby + push: + - meta_scope: comment.line.number-sign.ruby + - match: \) + captures: + 0: punctuation.definition.comment.end.ruby + pop: true + - include: escaped_char + - match: \( + captures: + 0: punctuation.definition.group.ruby + push: + - meta_scope: string.regexp.group.ruby + - match: \) + captures: + 0: punctuation.definition.group.ruby + pop: true + - include: regex_sub + - match: '(?<=^|\s)(#)\s(?=[[a-zA-Z0-9,. \t?!-][^\x{00}-\x{7F}]]*$)' + comment: We are restrictive in what we allow to go after the comment character to avoid false positives, since the availability of comments depend on regexp flags. + captures: + 1: punctuation.definition.comment.ruby + push: + - meta_scope: comment.line.number-sign.ruby + - match: $\n? + captures: + 0: punctuation.definition.comment.ruby + pop: true + yard: + - include: yard_comment + - include: yard_name_types + - include: yard_tag + - include: yard_types + - include: yard_directive + yard_comment: + - match: (@)(abstract|api|author|deprecated|example|note|overload|since|todo|version)(?=\s)(.*)$ + comment: For YARD tags that follow the tag-comment pattern + captures: + 1: comment.line.keyword.punctuation.yard.ruby + 2: comment.line.keyword.yard.ruby + 3: comment.line.string.yard.ruby + yard_directive: + - match: '(@!)(attribute|endgroup|group|macro|method|parse|scope|visibility)(\s+((\[).+(])))?(?=\s)(.*)$' + comment: For YARD directives + captures: + 1: comment.line.keyword.punctuation.yard.ruby + 2: comment.line.keyword.yard.ruby + 3: comment.line.yard.ruby + 4: comment.line.type.yard.ruby + 5: comment.line.punctuation.yard.ruby + 6: comment.line.punctuation.yard.ruby + 7: comment.line.string.yard.ruby + yard_name_types: + - match: '(@)(attr|attr_reader|attr_writer|option|param|see|yieldparam)(?=\s)(\s+([a-z_][a-zA-Z_]*))?(\s+((\[).+(])))?(.*)$' + comment: For YARD tags that follow the tag-name-types-comment pattern + captures: + 1: comment.line.keyword.punctuation.yard.ruby + 2: comment.line.keyword.yard.ruby + 3: comment.line.yard.ruby + 4: comment.line.parameter.yard.ruby + 5: comment.line.yard.ruby + 6: comment.line.type.yard.ruby + 7: comment.line.punctuation.yard.ruby + 8: comment.line.punctuation.yard.ruby + 9: comment.line.string.yard.ruby + yard_tag: + - match: (@)(private)$ + comment: For YARD tags that are just the tag + captures: + 1: comment.line.keyword.punctuation.yard.ruby + 2: comment.line.keyword.yard.ruby + yard_types: + - match: '(@)(raise|return|yield(?:return)?)(?=\s)(\s+((\[).+(])))?(.*)$' + comment: For YARD tags that follow the tag-types-comment pattern + captures: + 1: comment.line.keyword.punctuation.yard.ruby + 2: comment.line.keyword.yard.ruby + 3: comment.line.yard.ruby + 4: comment.line.type.yard.ruby + 5: comment.line.punctuation.yard.ruby + 6: comment.line.punctuation.yard.ruby + 7: comment.line.string.yard.ruby diff --git a/syntect/minimal_grammars/rust.sublime-syntax b/syntect/minimal_grammars/rust.sublime-syntax new file mode 100644 index 0000000..55f4c9f --- /dev/null +++ b/syntect/minimal_grammars/rust.sublime-syntax @@ -0,0 +1,368 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: Rust +file_extensions: + - rs +scope: source.rust +contexts: + main: + - match: \b(impl)\b + comment: Implementation + captures: + 1: storage.type.rust + push: + - match: '\{' + pop: true + - include: block_comment + - include: line_comment + - include: sigils + - include: mut + - include: dyn + - include: ref_lifetime + - include: core_types + - include: core_marker + - include: core_traits + - include: std_types + - include: std_traits + - include: type_params + - include: where + - match: \bfor\b + scope: storage.type.rust + - include: type + - include: block_doc_comment + - include: block_comment + - include: line_doc_comment + - include: line_comment + - match: '#\!?\[' + comment: Attribute + push: + - meta_scope: meta.attribute.rust + - match: '\]' + pop: true + - include: string_literal + - include: block_doc_comment + - include: block_comment + - include: line_doc_comment + - include: line_comment + - match: 'b?''([^''\\]|\\(x[0-9A-Fa-f]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.))''' + comment: Single-quote string literal (character) + scope: string.quoted.single.rust + - include: string_literal + - include: raw_string_literal + - match: '\b[0-9][0-9_]*\.[0-9][0-9_]*([eE][+-]?[0-9_]+)?(f32|f64)?\b' + comment: Floating point literal (fraction) + scope: constant.numeric.float.rust + - match: '\b[0-9][0-9_]*(\.[0-9][0-9_]*)?[eE][+-]?[0-9_]+(f32|f64)?\b' + comment: Floating point literal (exponent) + scope: constant.numeric.float.rust + - match: '\b[0-9][0-9_]*(\.[0-9][0-9_]*)?([eE][+-]?[0-9_]+)?(f32|f64)\b' + comment: Floating point literal (typed) + scope: constant.numeric.float.rust + - match: '\b[0-9][0-9_]*([ui](8|16|32|64|128|s|size))?\b' + comment: Integer literal (decimal) + scope: constant.numeric.integer.decimal.rust + - match: '\b0x[a-fA-F0-9_]+([ui](8|16|32|64|128|s|size))?\b' + comment: Integer literal (hexadecimal) + scope: constant.numeric.integer.hexadecimal.rust + - match: '\b0o[0-7_]+([ui](8|16|32|64|128|s|size))?\b' + comment: Integer literal (octal) + scope: constant.numeric.integer.octal.rust + - match: '\b0b[01_]+([ui](8|16|32|64|128|s|size))?\b' + comment: Integer literal (binary) + scope: constant.numeric.integer.binary.rust + - match: \bstatic\b + comment: Static storage modifier + scope: storage.modifier.static.rust + - match: \b(true|false)\b + comment: Boolean constant + scope: constant.language.boolean.rust + - match: \b(async|await|break|continue|else|if|in|for|loop|match|return|try|while)\b + comment: Control keyword + scope: keyword.control.rust + - match: \b(crate|extern|mod|let|ref|use|super|move)\b + comment: Keyword + scope: keyword.other.rust + - match: \b(abstract|alignof|become|do|final|macro|offsetof|override|priv|proc|pure|sizeof|typeof|virtual|yield)\b + comment: Reserved keyword + scope: invalid.deprecated.rust + - include: unsafe + - include: sigils + - include: self + - include: mut + - include: dyn + - include: impl + - include: box + - include: lifetime + - include: ref_lifetime + - include: const + - include: pub + - match: (=>|::|\bas\b) + comment: Miscellaneous operator + scope: keyword.operator.misc.rust + - match: (&&|\|\||==|!=) + comment: Comparison operator + scope: keyword.operator.comparison.rust + - match: (\+=|-=|/=|\*=|%=|\^=|&=|\|=|<<=|>>=|=) + comment: Assignment operator + scope: keyword.operator.assignment.rust + - match: (!|\+|-|/|\*|%|\^|&|\||<<|>>) + comment: Arithmetic operator + scope: keyword.operator.arithmetic.rust + - match: (<=|>=|<|>) + comment: Comparison operator (second group because of regex precedence) + scope: keyword.operator.comparison.rust + - include: core_types + - include: core_vars + - include: core_marker + - include: core_traits + - include: std_types + - include: std_traits + - match: \b(macro_rules|compile_error|format_args|env|option_env|concat_idents|concat|line|column|file|stringify|include|include_str|include_bytes|module_path|cfg)! + comment: Built-in macro + scope: support.function.builtin.rust + - match: \b(panic|assert|assert_eq|assert_ne|debug_assert|debug_assert_eq|debug_assert_ne|try|write|writeln|unreachable|unimplemented)! + comment: Core macro + scope: support.function.core.rust + - match: \b(format|print|println|eprint|eprintln|select|vec)! + comment: Standard library macro + scope: support.function.std.rust + - match: \b(log|error|warn|info|debug|trace|log_enabled)! + comment: Logging macro + scope: support.function.log.rust + - match: '\b([a-zA-Z_][a-zA-Z0-9_]*\!)\s*[({\[]' + comment: Invokation of a macro + captures: + 1: entity.name.function.macro.rust + - match: '\b([A-Za-z][A-Za-z0-9_]*|_[A-Za-z0-9_]+)\s*\(' + comment: Function call + captures: + 1: entity.name.function.rust + - match: '\b([A-Za-z][A-Za-z0-9_]*|_[A-Za-z0-9_]+)\s*(::)(?=\s*<.*>\s*\()' + comment: Function call with type parameters + captures: + 1: entity.name.function.rust + 2: keyword.operator.misc.rust + push: + - match: \( + captures: + 1: entity.name.function.rust + 2: keyword.operator.misc.rust + pop: true + - include: type_params + - match: '\b(fn)\s+([A-Za-z][A-Za-z0-9_]*|_[A-Za-z0-9_]+)' + comment: Function definition + captures: + 1: keyword.other.fn.rust + 2: entity.name.function.rust + push: + - match: '[\{;]' + pop: true + - include: block_comment + - include: line_comment + - include: sigils + - include: self + - include: mut + - include: dyn + - include: impl + - include: ref_lifetime + - include: core_types + - include: core_marker + - include: core_traits + - include: std_types + - include: std_traits + - include: type_params + - include: const + - include: where + - include: unsafe + - match: fn + comment: Function arguments + scope: keyword.other.fn.rust + - match: '\b(enum|struct|trait|union)\s+([a-zA-Z_][a-zA-Z0-9_]*)' + comment: Type declaration + captures: + 1: storage.type.rust + 2: entity.name.type.rust + push: + - match: '[\{\(;]' + pop: true + - include: block_comment + - include: line_comment + - include: core_traits + - include: std_traits + - include: type_params + - include: core_types + - include: pub + - include: where + - match: '\b(type)\s+([a-zA-Z_][a-zA-Z0-9_]*)' + comment: Type alias + captures: + 1: storage.type.rust + 2: entity.name.type.rust + push: + - match: ; + pop: true + - include: block_comment + - include: line_comment + - include: sigils + - include: mut + - include: dyn + - include: impl + - include: lifetime + - include: ref_lifetime + - include: core_types + - include: core_marker + - include: core_traits + - include: std_types + - include: std_traits + - include: type_params + block_comment: + - match: /\* + comment: Block comment + push: + - meta_scope: comment.block.rust + - match: \*/ + pop: true + - include: block_doc_comment + - include: block_comment + block_doc_comment: + - match: '/\*[\*!](?![\*/])' + comment: Block documentation comment + push: + - meta_scope: comment.block.documentation.rust + - match: \*/ + pop: true + - include: block_doc_comment + - include: block_comment + box: + - match: \bbox\b + comment: Box storage modifier + scope: storage.modifier.box.rust + const: + - match: \bconst\b + comment: Const storage modifier + scope: storage.modifier.const.rust + core_marker: + - match: \b(Copy|Send|Sized|Sync)\b + comment: Core trait (marker) + scope: support.type.marker.rust + core_traits: + - match: \b(Drop|Fn|FnMut|FnOnce|Clone|PartialEq|PartialOrd|Eq|Ord|AsRef|AsMut|Into|From|Default|Iterator|Extend|IntoIterator|DoubleEndedIterator|ExactSizeIterator)\b + comment: Core trait + scope: support.type.core.rust + core_types: + - match: \b(bool|char|usize|isize|u8|u16|u32|u64|u128|i8|i16|i32|i64|i128|f32|f64|str|Self|Option|Result)\b + comment: Built-in/core type + scope: storage.type.core.rust + core_vars: + - match: \b(Some|None|Ok|Err)\b + comment: Core type variant + scope: support.constant.core.rust + dyn: + - match: \bdyn\b + comment: Dynamic modifier + scope: storage.modifier.dyn.rust + escaped_character: + - match: '\\(x[0-9A-Fa-f]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)' + scope: constant.character.escape.rust + impl: + - match: \bimpl\b + comment: Existential type modifier + scope: storage.modifier.impl.rust + lifetime: + - match: '''([a-zA-Z_][a-zA-Z0-9_]*)\b' + comment: Named lifetime + scope: storage.modifier.lifetime.rust + captures: + 1: entity.name.lifetime.rust + line_comment: + - match: // + comment: Single-line comment + push: + - meta_scope: comment.line.double-slash.rust + - match: $ + pop: true + line_doc_comment: + - match: "//[!/](?=[^/])" + comment: Single-line documentation comment + push: + - meta_scope: comment.line.documentation.rust + - match: $ + pop: true + mut: + - match: \bmut\b + comment: Mutable storage modifier + scope: storage.modifier.mut.rust + pub: + - match: \bpub\b + comment: Visibility modifier + scope: storage.modifier.visibility.rust + raw_string_literal: + - match: b?r(#*)" + comment: Raw double-quote string literal + push: + - meta_scope: string.quoted.double.raw.rust + - match: '"\1' + pop: true + ref_lifetime: + - match: '&(''([a-zA-Z_][a-zA-Z0-9_]*))\b' + comment: Reference with named lifetime + captures: + 1: storage.modifier.lifetime.rust + 2: entity.name.lifetime.rust + self: + - match: \bself\b + comment: Self variable + scope: variable.language.rust + sigils: + - match: '[&*](?=[a-zA-Z0-9_\(\[\|\"]+)' + comment: Sigil + scope: keyword.operator.sigil.rust + std_traits: + - match: \b(ToOwned|ToString)\b + comment: Standard library trait + scope: support.type.std.rust + std_types: + - match: \b(Box|String|Vec|Path|PathBuf)\b + comment: Standard library type + scope: storage.class.std.rust + string_literal: + - match: b?" + comment: Double-quote string literal + push: + - meta_scope: string.quoted.double.rust + - match: '"' + pop: true + - include: escaped_character + type: + - match: '\b([A-Za-z][_A-Za-z0-9]*|_[_A-Za-z0-9]+)\b' + comment: A type + scope: entity.name.type.rust + type_params: + - match: "<(?![=<])" + comment: Type parameters + push: + - meta_scope: meta.type_params.rust + - match: "(?" + pop: true + - include: block_comment + - include: line_comment + - include: sigils + - include: mut + - include: dyn + - include: impl + - include: lifetime + - include: core_types + - include: core_marker + - include: core_traits + - include: std_types + - include: std_traits + - include: type_params + unsafe: + - match: \bunsafe\b + comment: Unsafe code keyword + scope: keyword.other.unsafe.rust + where: + - match: \bwhere\b + comment: Generic where clause + scope: keyword.other.where.rust diff --git a/syntect/minimal_grammars/shell-unix-bash.sublime-syntax b/syntect/minimal_grammars/shell-unix-bash.sublime-syntax new file mode 100644 index 0000000..10bba02 --- /dev/null +++ b/syntect/minimal_grammars/shell-unix-bash.sublime-syntax @@ -0,0 +1,659 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: Shell Script +file_extensions: + - sh + - bash + - ksh + - zsh + - zsh-theme + - zshenv + - zlogin + - zlogout + - zprofile + - zshrc + - bashrc + - bash_aliases + - bash_profile + - bash_login + - profile + - bash_logout + - .textmate_init + - npmrc + - PKGBUILD + - install + - cygport + - bats + - ebuild +first_line_match: |- + (?x) + # Hashbang + ^\#!.*(?:\s|\/) + (?:bash|zsh|sh|tcsh|ksh|dash|ash|csh|rc) + (?:$|\s) + | + # Modeline + (?i: + # Emacs + -\*-(?:\s*(?=[^:;\s]+\s*-\*-)|(?:.*?[;\s]|(?<=-\*-))mode\s*:\s*) + (?:shell-script|sh) + (?=[\s;]|(?]?\d+|m)?|\sex)(?=:(?=\s*set?\s[^\n:]+:)|:(?!\s* set?\s))(?:(?:\s|\s*:\s*)\w*(?:\s*=(?:[^\n\\\s]|\\.)*)?)*[\s:](?:filetype|ft|syntax)\s*= + sh + (?=\s|:|$) + ) +scope: source.shell +contexts: + main: + - include: comment + - include: pipeline + - include: list + - include: compound-command + - include: loop + - include: string + - include: function-definition + - include: variable + - include: interpolation + - include: heredoc + - include: herestring + - include: redirection + - include: pathname + - include: keyword + - include: support + comment: + - match: '(^\s+)?(?<=^|\W)(?|&&|\|\|' + comment: do we want a special rule for ( expr )? + scope: keyword.operator.logical.shell + - match: '(?[>=]?|==|!=|^|\|{1,2}|&{1,2}|\?|\:|,|=|[*/%+\-&^|]=|<<=|>>=' + scope: keyword.operator.arithmetic.shell + - match: "0[xX][0-9A-Fa-f]+" + scope: constant.numeric.hex.shell + - match: '0\d+' + scope: constant.numeric.octal.shell + - match: '\d{1,2}#[0-9a-zA-Z@_]+' + scope: constant.numeric.other.shell + - match: \d+ + scope: constant.numeric.integer.shell + pathname: + - match: (?<=\s|:|=|^)~ + scope: keyword.operator.tilde.shell + - match: \*|\? + scope: keyword.operator.glob.shell + - match: '([?*+@!])(\()' + captures: + 1: keyword.operator.extglob.shell + 2: punctuation.definition.extglob.shell + push: + - meta_scope: meta.structure.extglob.shell + - match: \) + captures: + 0: punctuation.definition.extglob.shell + pop: true + - include: main + pipeline: + - match: (?<=^|;|&|\s)(time)(?=\s|;|&|$) + scope: keyword.other.shell + - match: "[|!]" + scope: keyword.operator.pipe.shell + redirection: + - match: '[><]\(' + captures: + 0: punctuation.definition.string.begin.shell + push: + - meta_scope: string.interpolated.process-substitution.shell + - match: \) + captures: + 0: punctuation.definition.string.end.shell + pop: true + - include: main + - match: '(?])(&>|\d*>&\d*|\d*(>>|>|<)|\d*<&|\d*<>)(?![<>])' + scope: keyword.operator.redirect.shell + string: + - match: \\. + scope: constant.character.escape.shell + - match: "'" + captures: + 0: punctuation.definition.string.begin.shell + push: + - meta_scope: string.quoted.single.shell + - match: "'" + captures: + 0: punctuation.definition.string.end.shell + pop: true + - match: \$?" + captures: + 0: punctuation.definition.string.begin.shell + push: + - meta_scope: string.quoted.double.shell + - match: '"' + captures: + 0: punctuation.definition.string.end.shell + pop: true + - match: '\\[\$`"\\\n]' + scope: constant.character.escape.shell + - include: variable + - include: interpolation + - match: \$' + captures: + 0: punctuation.definition.string.begin.shell + push: + - meta_scope: string.quoted.single.dollar.shell + - match: "'" + captures: + 0: punctuation.definition.string.end.shell + pop: true + - match: \\(a|b|e|f|n|r|t|v|\\|') + scope: constant.character.escape.ansi-c.shell + - match: '\\[0-9]{3}' + scope: constant.character.escape.octal.shell + - match: '\\x[0-9a-fA-F]{2}' + scope: constant.character.escape.hex.shell + - match: \\c. + scope: constant.character.escape.control-char.shell + support: + - match: (?<=^|;|&|\s)(?::|\.)(?=\s|;|&|$) + scope: support.function.builtin.shell + - match: (?<=^|;|&|\s)(?:alias|bg|bind|break|builtin|caller|cd|command|compgen|complete|dirs|disown|echo|enable|eval|exec|exit|false|fc|fg|getopts|hash|help|history|jobs|kill|let|logout|popd|printf|pushd|pwd|read|readonly|set|shift|shopt|source|suspend|test|times|trap|true|type|ulimit|umask|unalias|unset|wait)(?=\s|;|&|$) + scope: support.function.builtin.shell + variable: + - match: '(\$)[a-zA-Z_][a-zA-Z0-9_]*' + scope: variable.other.normal.shell + captures: + 1: punctuation.definition.variable.shell + - match: '(\$)[-*@#?$!0_]' + scope: variable.other.special.shell + captures: + 1: punctuation.definition.variable.shell + - match: '(\$)[1-9]' + scope: variable.other.positional.shell + captures: + 1: punctuation.definition.variable.shell + - match: '\${' + captures: + 0: punctuation.definition.variable.shell + push: + - meta_scope: variable.other.bracket.shell + - match: "}" + captures: + 0: punctuation.definition.variable.shell + pop: true + - match: '!|:[-=?]?|\*|@|#{1,2}|%{1,2}|/' + scope: keyword.operator.expansion.shell + - match: '(\[)([^\]]+)(\])' + captures: + 1: punctuation.section.array.shell + 3: punctuation.section.array.shell + - include: variable + - include: string diff --git a/syntect/minimal_grammars/yaml.sublime-syntax b/syntect/minimal_grammars/yaml.sublime-syntax new file mode 100644 index 0000000..682c770 --- /dev/null +++ b/syntect/minimal_grammars/yaml.sublime-syntax @@ -0,0 +1,219 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: YAML +file_extensions: + - clang-format + - eslintrc + - eyaml + - eyml + - yaml + - yamllint + - yaml.erb + - yml + - yml.erb + - sls + - stylelintrc + - sublime-syntax + - Boxfile + - ksy +first_line_match: ^(#cloud-config|---) +scope: source.yaml +contexts: + main: + - include: erb + - include: comment + - match: \t+ + scope: invalid.illegal.whitespace.yaml + - match: ^--- + scope: punctuation.definition.directives.end.yaml + - match: ^\.\.\. + scope: punctuation.definition.document.end.yaml + - match: '^(\s*)(?:(-)|(?:(?:(-)(\s*))?([^!@#%&*>,][^:#]*\S)\s*(:)))(?:\s+((!)[^!\s]+))?\s+(?=\||>)' + captures: + 2: punctuation.definition.entry.yaml + 3: punctuation.definition.entry.yaml + 5: entity.name.tag.yaml + 6: punctuation.separator.key-value.yaml + 7: keyword.other.tag.local.yaml + 8: punctuation.definition.tag.local.yaml + push: + - meta_content_scope: string.unquoted.block.yaml + - match: '^((?!$)(?!\1\s+)|(?=\s\4(-|[^\s!@#%&*>,].*:\s+)))' + pop: true + - match: \G + push: + - match: $ + pop: true + - include: comment + - include: constants + - include: erb + - match: '^(\s*)([^!@#%&*>,][^:#]*\S)\s*(:)(?:\s+((!)[^!\s]+))?\s+(?=\||>)' + captures: + 2: entity.name.tag.yaml + 3: punctuation.separator.key-value.yaml + 4: keyword.other.tag.local.yaml + 5: punctuation.definition.tag.local.yaml + push: + - meta_content_scope: string.unquoted.block.yaml + - match: ^(?!$)(?!\1\s+) + pop: true + - match: \G + push: + - match: $ + pop: true + - include: comment + - include: constants + - include: erb + - match: (<<)\s*(:)\s+(.+)$ + captures: + 1: entity.name.tag.merge.yaml + 2: punctuation.separator.key-value.yaml + - match: '(?>^(\s*)(-)?\s*)([^!{@#%&*>,''"][^#]*?)(:)\s+((!!)omap)?' + captures: + 2: punctuation.definition.entry.yaml + 3: entity.name.tag.yaml + 4: punctuation.separator.key-value.yaml + 5: keyword.other.omap.yaml + 6: punctuation.definition.tag.omap.yaml + push: + - match: '^((?!\1\s+)|(?=\1\s*(-|[^!@#%&*>,].*:\s+|#)))' + pop: true + - include: scalar-content + - match: '^(\s*)(-)?\s*(?:(('')([^'']*?)(''))|((")([^"]*?)(")))(:)\s+((!!)omap)?' + captures: + 10: punctuation.definition.string.end.yaml + 11: punctuation.separator.key-value.yaml + 12: keyword.other.omap.yaml + 13: punctuation.definition.tag.omap.yaml + 2: punctuation.definition.entry.yaml + 3: string.quoted.single.yaml + 4: punctuation.definition.string.begin.yaml + 5: entity.name.tag.yaml + 6: punctuation.definition.string.end.yaml + 7: string.quoted.double.yaml + 8: punctuation.definition.string.begin.yaml + 9: entity.name.tag.yaml + push: + - match: '^((?!\1\s+)|(?=\1\s*(-|[^!@#%&*>,].*:\s+|#)))' + pop: true + - include: scalar-content + - match: '^(\s*)(-)\s+(?:((!!)omap)|((!)[^!\s]+)|(?![!@#%&*>,]))' + captures: + 2: punctuation.definition.entry.yaml + 3: keyword.other.omap.yaml + 4: punctuation.definition.tag.omap.yaml + 5: keyword.other.tag.local.yaml + 6: punctuation.definition.tag.local.yaml + push: + - match: '^((?!\1\s+)|(?=\1\s*(-|[^!@#%&*>,].*:\s+|#)))' + pop: true + - include: scalar-content + - include: variables + - include: strings + comment: + - match: '(?<=^|\s)#(?!{)' + captures: + 0: punctuation.definition.comment.yaml + push: + - meta_scope: comment.line.number-sign.yaml + - match: $ + pop: true + constants: + - match: (?<=\s)(true|false|null|True|False|Null|TRUE|FALSE|NULL|~)(?=\s*$) + scope: constant.language.yaml + date: + - match: '([0-9]{4}-[0-9]{2}-[0-9]{2})\s*($|(?=#)(?!#{))' + captures: + 1: constant.other.date.yaml + erb: + - match: <%+(?!>)=? + captures: + 0: punctuation.definition.embedded.begin.ruby + push: + - meta_scope: meta.embedded.line.ruby + - meta_content_scope: source.ruby.rails + - match: (%)> + captures: + 0: punctuation.definition.embedded.end.ruby + 1: source.ruby.rails + pop: true + - match: (#).*?(?=%>) + scope: comment.line.number-sign.ruby + captures: + 1: punctuation.definition.comment.ruby + - include: scope:source.ruby.rails + escaped_char: + - match: '\\u[A-Fa-f0-9]{4}' + scope: constant.character.escape.yaml + - match: '\\U[A-Fa-f0-9]{8}' + scope: constant.character.escape.yaml + - match: '\\x[0-9A-Fa-f]{2}' + scope: constant.character.escape.yaml + - match: '\\[0abtnvfre "/\\N_LP]' + scope: constant.character.escape.yaml + - match: '\\(u.{4}|U.{8}|x.{2}|.)' + scope: invalid.illegal.escape.yaml + numeric: + - match: '[-+]?[0-9]+(?=\s*($|#(?!#{)))' + scope: constant.numeric.integer.yaml + - match: '0o[0-7]+(?=\s*($|#(?!#{)))' + scope: constant.numeric.octal.yaml + - match: '0x[0-9a-fA-F]+(?=\s*($|#(?!#{)))' + scope: constant.numeric.hexadecimal.yaml + - match: '[-+]?(.[0-9]+|[0-9]+(.[0-9]*)?)([eE][-+]?[0-9]+)?(?=\s*($|#(?!#{)))' + scope: constant.numeric.float.yaml + - match: '[-+]?(.inf|.Inf|.INF)(?=\s*($|#(?!#{)))' + scope: constant.numeric.float.yaml + - match: '(.nan|.NaN|.NAN)(?=\s*($|#(?!#{)))' + scope: constant.numeric.float.yaml + scalar-content: + - include: comment + - match: '!(?=\s)' + scope: punctuation.definition.tag.non-specific.yaml + - include: constants + - include: date + - include: numeric + - include: strings + strings: + - match: '"' + captures: + 0: punctuation.definition.string.begin.yaml + push: + - meta_scope: string.quoted.double.yaml + - match: '"' + captures: + 0: punctuation.definition.string.end.yaml + pop: true + - include: escaped_char + - include: erb + - match: "'" + captures: + 0: punctuation.definition.string.begin.yaml + push: + - meta_scope: string.quoted.single.yaml + - match: "''" + scope: constant.character.escape.yaml + - include: erb + - match: "'" + captures: + 0: punctuation.definition.string.end.yaml + pop: true + - match: "`" + captures: + 0: punctuation.definition.string.begin.yaml + push: + - meta_scope: string.interpolated.yaml + - match: "`" + captures: + 0: punctuation.definition.string.end.yaml + pop: true + - include: escaped_char + - include: erb + - match: '[^\s"''\n](?!\s*#(?!{))([^#\n]|((? ThemeSet: ... def load_syntax_folder(path: str) -> SyntaxSet: ... -def load_default_syntax() -> SyntaxSet: ... +def load_default_syntax(use_thread: bool) -> SyntaxSet: ... +def load_core_syntax(use_thread: bool) -> SyntaxSet: ... def highlight(text: str, language: str, syntax_set: SyntaxSet, theme: Theme) -> List[Tuple[Style, str]]: ... def escape_to_console(all_ranges: List[Tuple[Style, str]],