diff --git a/syntaxes/fjsx15/literal/string/regex.sublime-syntax b/syntaxes/fjsx15/literal/string/regex.sublime-syntax index 5ab225a9..aeaf3b41 100644 --- a/syntaxes/fjsx15/literal/string/regex.sublime-syntax +++ b/syntaxes/fjsx15/literal/string/regex.sublime-syntax @@ -19,25 +19,43 @@ scope: ... contexts: main: - - match: | - (?x) - \s*/ - (?= - .*? - (?- + string.regexp.js.fjsx15 + punctuation.definition.string.begin.js.fjsx15 + set: [ + regex-meta, + close-regex, + regex-content + ] + + close-regex: + - match: \s*(/)([a-z]*) captures: 1: punctuation.definition.string.end.js.fjsx15 - 2: regex.flag.js.fjsx15 + 2: keyword.other.flag.js.fjsx15 + pop: true + - match: (?=\s*\S) + push: regex-content + + pop-now: + - match: "" pop: true + + regex-content: + - include: Packages/Naomi/syntaxes/fjsx15/literal/string/regex/anchor.sublime-syntax + - include: Packages/Naomi/syntaxes/fjsx15/literal/string/regex/backref.sublime-syntax + - include: Packages/Naomi/syntaxes/fjsx15/literal/string/regex/backslash.sublime-syntax + - include: Packages/Naomi/syntaxes/fjsx15/literal/string/regex/capturing-group.sublime-syntax + - include: Packages/Naomi/syntaxes/fjsx15/literal/string/regex/character-class.sublime-syntax + - include: Packages/Naomi/syntaxes/fjsx15/literal/string/regex/lookahead.sublime-syntax + - include: Packages/Naomi/syntaxes/fjsx15/literal/string/regex/negative-lookahead.sublime-syntax + - include: Packages/Naomi/syntaxes/fjsx15/literal/string/regex/non-capturing-group.sublime-syntax + - include: Packages/Naomi/syntaxes/fjsx15/literal/string/regex/operator.sublime-syntax + - include: Packages/Naomi/syntaxes/fjsx15/literal/string/regex/quantifier.sublime-syntax + - include: pop-now + + regex-meta: + - meta_content_scope: string.regexp.js.fjsx15 + - include: pop-now diff --git a/syntaxes/fjsx15/literal/string/regex/anchor.sublime-syntax b/syntaxes/fjsx15/literal/string/regex/anchor.sublime-syntax new file mode 100644 index 00000000..e747a324 --- /dev/null +++ b/syntaxes/fjsx15/literal/string/regex/anchor.sublime-syntax @@ -0,0 +1,26 @@ +%YAML1.2 +--- + +# Licensed under the Apache License, Version 2.0 (the “License”); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an “AS IS” BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +hidden: true + +scope: ... + +contexts: + main: + # ^ $ \b + - match: \s*((?>\\b|\^|\$)) + captures: + 1: keyword.control.anchor.regexp.js.fjsx15 + pop: true diff --git a/syntaxes/fjsx15/literal/string/regex/backref.sublime-syntax b/syntaxes/fjsx15/literal/string/regex/backref.sublime-syntax new file mode 100644 index 00000000..6bd553f5 --- /dev/null +++ b/syntaxes/fjsx15/literal/string/regex/backref.sublime-syntax @@ -0,0 +1,25 @@ +%YAML1.2 +--- + +# Licensed under the Apache License, Version 2.0 (the “License”); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an “AS IS” BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +hidden: true + +scope: ... + +contexts: + main: + - match: \s*(\\[1-9][0-9]*) + captures: + 1: keyword.other.back-reference.regexp.js.fjsx15 + pop: true diff --git a/syntaxes/fjsx15/literal/string/regex/backslash.sublime-syntax b/syntaxes/fjsx15/literal/string/regex/backslash.sublime-syntax new file mode 100644 index 00000000..805c0e89 --- /dev/null +++ b/syntaxes/fjsx15/literal/string/regex/backslash.sublime-syntax @@ -0,0 +1,39 @@ +%YAML1.2 +--- + +# Licensed under the Apache License, Version 2.0 (the “License”); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an “AS IS” BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +hidden: true + +scope: ... + +contexts: + main: + # Character classes/sets. + - match: (?i)\s*(\\[wsd]|) + captures: + 1: constant.other.character-class.escape.backslash.regexp + pop: true + # Other escape sequences. + - match: | + (?x)\s* + (\\ + (?> c[A-Z] + | x[\da-fA-F]{2} + | u[\da-fA-F]{4} + | . + ) + ) + captures: + 1: constant.character.escape.backslash.regexp.js.fjsx15 + pop: true diff --git a/syntaxes/fjsx15/literal/string/regex/capturing-group.sublime-syntax b/syntaxes/fjsx15/literal/string/regex/capturing-group.sublime-syntax new file mode 100644 index 00000000..73987cae --- /dev/null +++ b/syntaxes/fjsx15/literal/string/regex/capturing-group.sublime-syntax @@ -0,0 +1,41 @@ +%YAML1.2 +--- + +# Licensed under the Apache License, Version 2.0 (the “License”); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an “AS IS” BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +hidden: true + +scope: ... + +contexts: + main: + - match: \s*(\()(?!\?) + captures: + 1: punctuation.definition.group.begin.regexp.js.fjsx15 + set: [ meta, close, regex-content ] + + close: + - match: \s*(\)) + captures: + 1: punctuation.definition.group.end.regexp.js.fjsx15 + pop: true + - match: (?=\s*\S) + push: regex-content + + meta: + - meta_scope: meta.group.regexp.js.fjsx15 + - match: "" + pop: true + + regex-content: + - include: Packages/Naomi/syntaxes/fjsx15/literal/string/regex.sublime-syntax#regex-content diff --git a/syntaxes/fjsx15/literal/string/regex/character-class.sublime-syntax b/syntaxes/fjsx15/literal/string/regex/character-class.sublime-syntax new file mode 100644 index 00000000..f337a4a5 --- /dev/null +++ b/syntaxes/fjsx15/literal/string/regex/character-class.sublime-syntax @@ -0,0 +1,49 @@ +%YAML1.2 +--- + +# Licensed under the Apache License, Version 2.0 (the “License”); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an “AS IS” BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +hidden: true + +scope: ... + +contexts: + main: + - match: \s*((\[)(\^)?) + captures: + 1: constant.other.character-class.regexp.js.fjsx15 + 2: punctuation.definition.character-class.begin.regexp.js.fjsx15 + 3: keyword.operator.negation.regexp.js.fjsx15 + set: [ close, content ] + + close: + - match: (\]) + captures: + 1: >- + constant.other.character-class.regexp.js.fjsx15 + punctuation.definition.character-class.end.regexp.js.fjsx15 + pop: true + - match: (?=\s*\S) + push: content + + content: + - include: Packages/Naomi/syntaxes/fjsx15/literal/string/regex/character-class/range.sublime-syntax + - include: Packages/Naomi/syntaxes/fjsx15/literal/string/regex/backslash.sublime-syntax + - match: . + scope: constant.other.character-class.regexp.js.fjsx15 + pop: true + - include: pop-now + + pop-now: + - match: "" + pop: true diff --git a/syntaxes/fjsx15/literal/string/regex/character-class/range.sublime-syntax b/syntaxes/fjsx15/literal/string/regex/character-class/range.sublime-syntax new file mode 100644 index 00000000..91e48e86 --- /dev/null +++ b/syntaxes/fjsx15/literal/string/regex/character-class/range.sublime-syntax @@ -0,0 +1,38 @@ +%YAML1.2 +--- + +# Licensed under the Apache License, Version 2.0 (the “License”); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an “AS IS” BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +hidden: true + +scope: ... + +variables: + possibleRange: | + (?> \w + | \d + | \\ + (?> c[A-Z] + | x[\da-fA-F]{2} + | u[\da-fA-F]{4} + ) + ) + +contexts: + main: + - match: | + (?xi)\s* + ({{possibleRange}}-{{possibleRange}}) + captures: + 1: constant.other.character-class.range.regexp.js.fjsx15 + pop: true diff --git a/syntaxes/fjsx15/literal/string/regex/lookahead.sublime-syntax b/syntaxes/fjsx15/literal/string/regex/lookahead.sublime-syntax new file mode 100644 index 00000000..bcd8a2fd --- /dev/null +++ b/syntaxes/fjsx15/literal/string/regex/lookahead.sublime-syntax @@ -0,0 +1,41 @@ +%YAML1.2 +--- + +# Licensed under the Apache License, Version 2.0 (the “License”); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an “AS IS” BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +hidden: true + +scope: ... + +contexts: + main: + - match: \s*(\(\?=) + captures: + 1: punctuation.definition.group.assertion.begin.regexp.js.fjsx15 + set: [ meta, close, regex-content ] + + close: + - match: \s*(\)) + captures: + 1: punctuation.definition.group.assertion.end.regexp.js.fjsx15 + pop: true + - match: (?=\s*\S) + push: regex-content + + meta: + - meta_scope: meta.group.assertion.look-ahead.regexp.js.fjsx15 + - match: "" + pop: true + + regex-content: + - include: Packages/Naomi/syntaxes/fjsx15/literal/string/regex.sublime-syntax#regex-content diff --git a/syntaxes/fjsx15/literal/string/regex/negative-lookahead.sublime-syntax b/syntaxes/fjsx15/literal/string/regex/negative-lookahead.sublime-syntax new file mode 100644 index 00000000..4869b516 --- /dev/null +++ b/syntaxes/fjsx15/literal/string/regex/negative-lookahead.sublime-syntax @@ -0,0 +1,41 @@ +%YAML1.2 +--- + +# Licensed under the Apache License, Version 2.0 (the “License”); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an “AS IS” BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +hidden: true + +scope: ... + +contexts: + main: + - match: \s*(\(\?!) + captures: + 1: punctuation.definition.group.assertion.begin.regexp.js.fjsx15 + set: [ meta, close, regex-content ] + + close: + - match: \s*(\)) + captures: + 1: punctuation.definition.group.assertion.end.regexp.js.fjsx15 + pop: true + - match: (?=\s*\S) + push: regex-content + + meta: + - meta_scope: meta.group.assertion.look-ahead.negative.regexp.js.fjsx15 + - match: "" + pop: true + + regex-content: + - include: Packages/Naomi/syntaxes/fjsx15/literal/string/regex.sublime-syntax#regex-content diff --git a/syntaxes/fjsx15/literal/string/regex/non-capturing-group.sublime-syntax b/syntaxes/fjsx15/literal/string/regex/non-capturing-group.sublime-syntax new file mode 100644 index 00000000..aebed3ce --- /dev/null +++ b/syntaxes/fjsx15/literal/string/regex/non-capturing-group.sublime-syntax @@ -0,0 +1,41 @@ +%YAML1.2 +--- + +# Licensed under the Apache License, Version 2.0 (the “License”); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an “AS IS” BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +hidden: true + +scope: ... + +contexts: + main: + - match: \s*(\(\?:) + captures: + 1: punctuation.definition.group.no-capture.begin.regexp.js.fjsx15 + set: [ meta, close, regex-content ] + + close: + - match: \s*(\)) + captures: + 1: punctuation.definition.group.no-capture.end.regexp.js.fjsx15 + pop: true + - match: (?=\s*\S) + push: regex-content + + meta: + - meta_scope: meta.group.regexp.js.fjsx15 + - match: "" + pop: true + + regex-content: + - include: Packages/Naomi/syntaxes/fjsx15/literal/string/regex.sublime-syntax#regex-content diff --git a/syntaxes/fjsx15/literal/string/regex/operator.sublime-syntax b/syntaxes/fjsx15/literal/string/regex/operator.sublime-syntax new file mode 100644 index 00000000..0b8fafc0 --- /dev/null +++ b/syntaxes/fjsx15/literal/string/regex/operator.sublime-syntax @@ -0,0 +1,25 @@ +%YAML1.2 +--- + +# Licensed under the Apache License, Version 2.0 (the “License”); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an “AS IS” BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +hidden: true + +scope: ... + +contexts: + main: + - match: \s*(\|) + captures: + 1: keyword.operator.or.regexp.js.fjsx15 + pop: true diff --git a/syntaxes/fjsx15/literal/string/regex/quantifier.sublime-syntax b/syntaxes/fjsx15/literal/string/regex/quantifier.sublime-syntax new file mode 100644 index 00000000..f8ba44d2 --- /dev/null +++ b/syntaxes/fjsx15/literal/string/regex/quantifier.sublime-syntax @@ -0,0 +1,38 @@ +%YAML1.2 +--- + +# Licensed under the Apache License, Version 2.0 (the “License”); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an “AS IS” BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +hidden: true + +scope: ... + +contexts: + main: + # Operator quantifier. + - match: \s*([*+]?\??) + captures: + 1: keyword.operator.quantifier.regexp.js.fjsx15 + pop: true + # Brace quantifier. + - match: | + (?x) + (\{ + (?> \d+,\d+ + | \d+, + | \d+ + ) + }) + captures: + 1: keyword.operator.quantifier.regexp + pop: true