From d71c05f9d9c6ba01856f45d377e3e592737e1359 Mon Sep 17 00:00:00 2001 From: Alexandre Borela Date: Thu, 18 Jan 2018 13:35:56 -0200 Subject: [PATCH 01/20] [FJSX15] Add anchor --- .../string/regex/anchor.sublime-syntax | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 syntaxes/fjsx15/literal/string/regex/anchor.sublime-syntax 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 From aec6ca676de92c4887a17950f3073ff5ba20051b Mon Sep 17 00:00:00 2001 From: Alexandre Borela Date: Thu, 18 Jan 2018 13:36:25 -0200 Subject: [PATCH 02/20] [FJSX15] Add backref --- .../string/regex/backref.sublime-syntax | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 syntaxes/fjsx15/literal/string/regex/backref.sublime-syntax 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 From 72c33bb9de149701ff8e0d860f16b31d46e3f591 Mon Sep 17 00:00:00 2001 From: Alexandre Borela Date: Thu, 18 Jan 2018 13:36:49 -0200 Subject: [PATCH 03/20] [FJSX15] Add backslash --- .../string/regex/backslash.sublime-syntax | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 syntaxes/fjsx15/literal/string/regex/backslash.sublime-syntax 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..7195c0fb --- /dev/null +++ b/syntaxes/fjsx15/literal/string/regex/backslash.sublime-syntax @@ -0,0 +1,34 @@ +%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: | + (?x)\s* + (\\ + (?> \\ + | c[A-Z] + | x[\da-fA-F]{2} + | u[\da-fA-F]{4} + | [0fnrtv] + ) + ) + captures: + 1: constant.character.escape.backslash.regexp.js.fjsx15 + pop: true From b6016e854162aab21fa4408b27c756c0112a3ac0 Mon Sep 17 00:00:00 2001 From: Alexandre Borela Date: Thu, 18 Jan 2018 13:37:04 -0200 Subject: [PATCH 04/20] [FJSX15] Add capturing group --- .../regex/capturing-group.sublime-syntax | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 syntaxes/fjsx15/literal/string/regex/capturing-group.sublime-syntax 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..6deae445 --- /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: (\() + captures: + 1: punctuation.definition.group.begin.regexp.js.fjsx15 + set: [ meta, close, regex-content ] + + close: + - match: (\)) + 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 From 36a10219935aa5f7c763c866cf03c95af985b134 Mon Sep 17 00:00:00 2001 From: Alexandre Borela Date: Thu, 18 Jan 2018 13:37:16 -0200 Subject: [PATCH 05/20] [FJSX15] Add non capturing group --- .../regex/non-capturing-group.sublime-syntax | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 syntaxes/fjsx15/literal/string/regex/non-capturing-group.sublime-syntax 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..1f0b79b4 --- /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: (\(\?:) + captures: + 1: punctuation.definition.group.no-capture.begin.regexp.js.fjsx15 + set: [ meta, close, regex-content ] + + close: + - match: (\)) + 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 From 734e114ddc8918130786c7820621f22f28f5fcc5 Mon Sep 17 00:00:00 2001 From: Alexandre Borela Date: Thu, 18 Jan 2018 13:40:09 -0200 Subject: [PATCH 06/20] [FJSX15] Speed up --- .../literal/string/regex/capturing-group.sublime-syntax | 4 ++-- .../literal/string/regex/non-capturing-group.sublime-syntax | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/syntaxes/fjsx15/literal/string/regex/capturing-group.sublime-syntax b/syntaxes/fjsx15/literal/string/regex/capturing-group.sublime-syntax index 6deae445..d8708c0b 100644 --- a/syntaxes/fjsx15/literal/string/regex/capturing-group.sublime-syntax +++ b/syntaxes/fjsx15/literal/string/regex/capturing-group.sublime-syntax @@ -19,13 +19,13 @@ scope: ... contexts: main: - - match: (\() + - match: \s*(\() captures: 1: punctuation.definition.group.begin.regexp.js.fjsx15 set: [ meta, close, regex-content ] close: - - match: (\)) + - match: \s*(\)) captures: 1: punctuation.definition.group.end.regexp.js.fjsx15 pop: true diff --git a/syntaxes/fjsx15/literal/string/regex/non-capturing-group.sublime-syntax b/syntaxes/fjsx15/literal/string/regex/non-capturing-group.sublime-syntax index 1f0b79b4..aebed3ce 100644 --- a/syntaxes/fjsx15/literal/string/regex/non-capturing-group.sublime-syntax +++ b/syntaxes/fjsx15/literal/string/regex/non-capturing-group.sublime-syntax @@ -19,13 +19,13 @@ scope: ... contexts: main: - - match: (\(\?:) + - match: \s*(\(\?:) captures: 1: punctuation.definition.group.no-capture.begin.regexp.js.fjsx15 set: [ meta, close, regex-content ] close: - - match: (\)) + - match: \s*(\)) captures: 1: punctuation.definition.group.no-capture.end.regexp.js.fjsx15 pop: true From 889de55e643884d6d618021c0126ca904fa1faa2 Mon Sep 17 00:00:00 2001 From: Alexandre Borela Date: Thu, 18 Jan 2018 13:40:29 -0200 Subject: [PATCH 07/20] [FJSX15] Add quantifier --- .../string/regex/quantifier.sublime-syntax | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 syntaxes/fjsx15/literal/string/regex/quantifier.sublime-syntax 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..586ba59b --- /dev/null +++ b/syntaxes/fjsx15/literal/string/regex/quantifier.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.quantifier.regexp.js.fjsx15 + pop: true From b540744e725a6c1af7570ded029ae8bf2ad1bc01 Mon Sep 17 00:00:00 2001 From: Alexandre Borela Date: Thu, 18 Jan 2018 13:40:50 -0200 Subject: [PATCH 08/20] [FJSX15] Add lookahead --- .../string/regex/lookahead.sublime-syntax | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 syntaxes/fjsx15/literal/string/regex/lookahead.sublime-syntax 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 From 78c6a6c19bf38ec40e392ec66f180e772b5a27e1 Mon Sep 17 00:00:00 2001 From: Alexandre Borela Date: Thu, 18 Jan 2018 13:41:06 -0200 Subject: [PATCH 09/20] [FJSX15] Add negative lookahead --- .../regex/negative-lookahead.sublime-syntax | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 syntaxes/fjsx15/literal/string/regex/negative-lookahead.sublime-syntax 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 From eab51399bd92d3b9548758abedad65713095e064 Mon Sep 17 00:00:00 2001 From: Alexandre Borela Date: Thu, 18 Jan 2018 13:45:22 -0200 Subject: [PATCH 10/20] [FJSX15] Add operator --- .../string/regex/operator.sublime-syntax | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 syntaxes/fjsx15/literal/string/regex/operator.sublime-syntax 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 From c21db7fad87eb73d4563152cbaba936f8d58fece Mon Sep 17 00:00:00 2001 From: Alexandre Borela Date: Thu, 18 Jan 2018 13:45:45 -0200 Subject: [PATCH 11/20] [FJSX15] Add basic character class --- .../regex/character-class.sublime-syntax | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 syntaxes/fjsx15/literal/string/regex/character-class.sublime-syntax 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..2a9c89f8 --- /dev/null +++ b/syntaxes/fjsx15/literal/string/regex/character-class.sublime-syntax @@ -0,0 +1,46 @@ +%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.character-class.begin.regexp.js.fjsx15 + 2: keyword.operator.negation.regexp.js.fjsx15 + set: [ meta, close, content ] + + close: + - match: (\]) + captures: + 1: punctuation.definition.character-class.end.regexp.js.fjsx15 + pop: true + - match: (?=\s*\S) + push: content + + content: + # - include: backslash + - include: pop-now + + meta: + - meta_scope: meta.group.regexp.js.fjsx15 + - include: pop-now + + pop-now: + - match: "" + pop: true From 1c1e851ea3335c4824b2841560218f92617d7e81 Mon Sep 17 00:00:00 2001 From: Alexandre Borela Date: Thu, 18 Jan 2018 13:45:59 -0200 Subject: [PATCH 12/20] [FJSX15] Update regex entry point --- .../literal/string/regex.sublime-syntax | 54 ++++++++++++------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/syntaxes/fjsx15/literal/string/regex.sublime-syntax b/syntaxes/fjsx15/literal/string/regex.sublime-syntax index 5ab225a9..9540f831 100644 --- a/syntaxes/fjsx15/literal/string/regex.sublime-syntax +++ b/syntaxes/fjsx15/literal/string/regex.sublime-syntax @@ -19,25 +19,41 @@ scope: ... contexts: main: - - match: | - (?x) - \s*/ - (?= - .*? - (? Date: Thu, 18 Jan 2018 13:46:15 -0200 Subject: [PATCH 13/20] [FJSX15] Prevent ambiguity in regex groups --- .../fjsx15/literal/string/regex/capturing-group.sublime-syntax | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntaxes/fjsx15/literal/string/regex/capturing-group.sublime-syntax b/syntaxes/fjsx15/literal/string/regex/capturing-group.sublime-syntax index d8708c0b..73987cae 100644 --- a/syntaxes/fjsx15/literal/string/regex/capturing-group.sublime-syntax +++ b/syntaxes/fjsx15/literal/string/regex/capturing-group.sublime-syntax @@ -19,7 +19,7 @@ scope: ... contexts: main: - - match: \s*(\() + - match: \s*(\()(?!\?) captures: 1: punctuation.definition.group.begin.regexp.js.fjsx15 set: [ meta, close, regex-content ] From f7610caa5094932a218ca76f6b4f03bafae8fb83 Mon Sep 17 00:00:00 2001 From: Alexandre Borela Date: Thu, 18 Jan 2018 13:52:55 -0200 Subject: [PATCH 14/20] [FJSX15] Escape forward slash --- syntaxes/fjsx15/literal/string/regex/backslash.sublime-syntax | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntaxes/fjsx15/literal/string/regex/backslash.sublime-syntax b/syntaxes/fjsx15/literal/string/regex/backslash.sublime-syntax index 7195c0fb..262ddb68 100644 --- a/syntaxes/fjsx15/literal/string/regex/backslash.sublime-syntax +++ b/syntaxes/fjsx15/literal/string/regex/backslash.sublime-syntax @@ -26,7 +26,7 @@ contexts: | c[A-Z] | x[\da-fA-F]{2} | u[\da-fA-F]{4} - | [0fnrtv] + | [0fnrtv/] ) ) captures: From ad28ece164c656df63e236d781f844b902ca4340 Mon Sep 17 00:00:00 2001 From: Alexandre Borela Date: Thu, 18 Jan 2018 13:55:39 -0200 Subject: [PATCH 15/20] [FJSX15] Make backslash greedy --- syntaxes/fjsx15/literal/string/regex/backslash.sublime-syntax | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/syntaxes/fjsx15/literal/string/regex/backslash.sublime-syntax b/syntaxes/fjsx15/literal/string/regex/backslash.sublime-syntax index 262ddb68..b86aaf21 100644 --- a/syntaxes/fjsx15/literal/string/regex/backslash.sublime-syntax +++ b/syntaxes/fjsx15/literal/string/regex/backslash.sublime-syntax @@ -26,7 +26,8 @@ contexts: | c[A-Z] | x[\da-fA-F]{2} | u[\da-fA-F]{4} - | [0fnrtv/] + | [0fnrtv] + | . ) ) captures: From a32866f06c5335b4547969c7a8a27b26380ac2d1 Mon Sep 17 00:00:00 2001 From: Alexandre Borela Date: Thu, 18 Jan 2018 13:58:59 -0200 Subject: [PATCH 16/20] [FJSX15] Add brace quantifier --- .../literal/string/regex/quantifier.sublime-syntax | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/syntaxes/fjsx15/literal/string/regex/quantifier.sublime-syntax b/syntaxes/fjsx15/literal/string/regex/quantifier.sublime-syntax index 586ba59b..f8ba44d2 100644 --- a/syntaxes/fjsx15/literal/string/regex/quantifier.sublime-syntax +++ b/syntaxes/fjsx15/literal/string/regex/quantifier.sublime-syntax @@ -19,7 +19,20 @@ 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 From 4762778945588ec0f29a7012ca03a1cb5426ce8f Mon Sep 17 00:00:00 2001 From: Alexandre Borela Date: Thu, 18 Jan 2018 14:03:29 -0200 Subject: [PATCH 17/20] [FJSX15] Add character class escapes --- .../literal/string/regex/backslash.sublime-syntax | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/syntaxes/fjsx15/literal/string/regex/backslash.sublime-syntax b/syntaxes/fjsx15/literal/string/regex/backslash.sublime-syntax index b86aaf21..805c0e89 100644 --- a/syntaxes/fjsx15/literal/string/regex/backslash.sublime-syntax +++ b/syntaxes/fjsx15/literal/string/regex/backslash.sublime-syntax @@ -19,14 +19,18 @@ 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] + (?> c[A-Z] | x[\da-fA-F]{2} | u[\da-fA-F]{4} - | [0fnrtv] | . ) ) From 79e2de056795a1bf28ce57ad1aca161caa81f385 Mon Sep 17 00:00:00 2001 From: Alexandre Borela Date: Thu, 18 Jan 2018 15:49:17 -0200 Subject: [PATCH 18/20] [FJSX15] Fix missing meta scope --- syntaxes/fjsx15/literal/string/regex.sublime-syntax | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/syntaxes/fjsx15/literal/string/regex.sublime-syntax b/syntaxes/fjsx15/literal/string/regex.sublime-syntax index 9540f831..aeaf3b41 100644 --- a/syntaxes/fjsx15/literal/string/regex.sublime-syntax +++ b/syntaxes/fjsx15/literal/string/regex.sublime-syntax @@ -21,7 +21,9 @@ contexts: main: - match: \s*(/) captures: - 1: punctuation.definition.string.begin.js.fjsx15 + 1: >- + string.regexp.js.fjsx15 + punctuation.definition.string.begin.js.fjsx15 set: [ regex-meta, close-regex, From 11775c0895170e300e3f2978daac74d59f95a0e2 Mon Sep 17 00:00:00 2001 From: Alexandre Borela Date: Thu, 18 Jan 2018 15:49:37 -0200 Subject: [PATCH 19/20] [FJSX15] Fix character class meta scope --- .../fjsx15/literal/string/regex/character-class.sublime-syntax | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntaxes/fjsx15/literal/string/regex/character-class.sublime-syntax b/syntaxes/fjsx15/literal/string/regex/character-class.sublime-syntax index 2a9c89f8..4d8a1c8f 100644 --- a/syntaxes/fjsx15/literal/string/regex/character-class.sublime-syntax +++ b/syntaxes/fjsx15/literal/string/regex/character-class.sublime-syntax @@ -38,7 +38,7 @@ contexts: - include: pop-now meta: - - meta_scope: meta.group.regexp.js.fjsx15 + - meta_scope: constant.other.character-class.regexp.js.fjsx15 - include: pop-now pop-now: From 70064c014fef1b62724d9683d10e508d22cd730f Mon Sep 17 00:00:00 2001 From: Alexandre Borela Date: Thu, 18 Jan 2018 15:58:39 -0200 Subject: [PATCH 20/20] [FJSX15] Add range scopes --- .../regex/character-class.sublime-syntax | 23 ++++++----- .../character-class/range.sublime-syntax | 38 +++++++++++++++++++ 2 files changed, 51 insertions(+), 10 deletions(-) create mode 100644 syntaxes/fjsx15/literal/string/regex/character-class/range.sublime-syntax diff --git a/syntaxes/fjsx15/literal/string/regex/character-class.sublime-syntax b/syntaxes/fjsx15/literal/string/regex/character-class.sublime-syntax index 4d8a1c8f..f337a4a5 100644 --- a/syntaxes/fjsx15/literal/string/regex/character-class.sublime-syntax +++ b/syntaxes/fjsx15/literal/string/regex/character-class.sublime-syntax @@ -19,26 +19,29 @@ scope: ... contexts: main: - - match: \s*(\[)(\^)? + - match: \s*((\[)(\^)?) captures: - 1: punctuation.definition.character-class.begin.regexp.js.fjsx15 - 2: keyword.operator.negation.regexp.js.fjsx15 - set: [ meta, close, content ] + 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: punctuation.definition.character-class.end.regexp.js.fjsx15 + 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: backslash - - include: pop-now - - meta: - - meta_scope: constant.other.character-class.regexp.js.fjsx15 + - 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: 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