[gtksourceview: 2/9] css.lang (and family): Clean up regular expression groups
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview: 2/9] css.lang (and family): Clean up regular expression groups
- Date: Tue, 2 Jun 2020 18:31:19 +0000 (UTC)
commit 1f50e98c77a645257fd59728e4978b2b57ce268b
Author: Jeffery To <jeffery to gmail com>
Date: Tue Jun 2 01:25:15 2020 +0800
css.lang (and family): Clean up regular expression groups
* Remove unnecessary groups
* Prefer non-capturing groups
data/language-specs/css.lang | 4 ++--
data/language-specs/less.lang | 16 +++++++---------
data/language-specs/scss.lang | 20 +++++++++-----------
3 files changed, 18 insertions(+), 22 deletions(-)
---
diff --git a/data/language-specs/css.lang b/data/language-specs/css.lang
index 3b2b02f9..15e59e18 100644
--- a/data/language-specs/css.lang
+++ b/data/language-specs/css.lang
@@ -280,7 +280,7 @@
</context>
<context id="hexadecimal-color" style-ref="color">
- <match>#([a-f0-9]{8}|[a-f0-9]{6}|[a-f0-9]{4}|[a-f0-9]{3})\%]</match>
+ <match>#(?:[a-f0-9]{8}|[a-f0-9]{6}|[a-f0-9]{4}|[a-f0-9]{3})\%]</match>
</context>
<context id="css3-named-color" style-ref="color">
@@ -2507,7 +2507,7 @@
<context id="nth-pseudo-class" end-parent="true">
<start extended="true">
- \%[ (nth-child | nth-of-type | nth-last-child | nth-last-of-type) \(
+ \%[ (?: nth-child | nth-of-type | nth-last-child | nth-last-of-type ) \(
</start>
<end>\)</end>
<include>
diff --git a/data/language-specs/less.lang b/data/language-specs/less.lang
index bedfd061..5d11a679 100644
--- a/data/language-specs/less.lang
+++ b/data/language-specs/less.lang
@@ -62,7 +62,7 @@
<!-- global -->
<define-regex id="identifier">[\w-]+</define-regex>
- <define-regex id="statement-end" extended="true">;|(?=})</define-regex>
+ <define-regex id="statement-end">;|(?=})</define-regex>
<context id="embedded-lang-hook"/>
@@ -152,12 +152,10 @@
also not sure what are Less' rules regarding hyphen vs subtraction -->
<context id="arithmetic-operator" style-ref="operator-symbol">
<match extended="true">
- (
- [+*/] |
- (?<! \%{css:single-identifier-char} )
- -
- (?! \%{css:single-identifier-char} )
- )
+ [+*/] |
+ (?<! \%{css:single-identifier-char} )
+ -
+ (?! \%{css:single-identifier-char} )
</match>
</context>
@@ -495,7 +493,7 @@
)
)
- (
+ (?:
\+_?: | # property merge
:
(?:
@@ -750,7 +748,7 @@
</context>
<context id="guard-comparison-operator" style-ref="operator-symbol">
- <match>(>=?|=<?|<)</match>
+ <match>>=?|=<?|<</match>
</context>
<context id="guard-test">
diff --git a/data/language-specs/scss.lang b/data/language-specs/scss.lang
index 5d7ee953..9a3024c3 100644
--- a/data/language-specs/scss.lang
+++ b/data/language-specs/scss.lang
@@ -133,12 +133,10 @@
a division operation -->
<context id="arithmetic-operator" style-ref="operator-symbol">
<match extended="true">
- (
- [+*%] |
- (?<! \%{css:single-identifier-char} )
- -
- (?! \%{css:single-identifier-char} )
- )
+ [+*%] |
+ (?<! \%{css:single-identifier-char} )
+ -
+ (?! \%{css:single-identifier-char} )
</match>
</context>
@@ -147,7 +145,7 @@
</context>
<context id="comparison-operator" style-ref="operator-symbol">
- <match>(<=?|>=?|[=!]=)</match>
+ <match><=?|>=?|[=!]=</match>
</context>
<context id="logical-operator" style-ref="logical-operator">
@@ -688,7 +686,7 @@
-->
<context id="at-debug-warn-error">
- <start>@(debug|warn|error)\%]</start>
+ <start>@(?:debug|warn|error)\%]</start>
<include>
<context sub-pattern="0" where="start" style-ref="css:at-rule"/>
<context ref="css:embedded-lang-hook"/>
@@ -705,7 +703,7 @@
-->
<context id="at-if-else-if">
- <start>@(if|else\s+if)\%]</start>
+ <start>@(?:if|else\s+if)\%]</start>
<include>
<context sub-pattern="0" where="start" style-ref="css:at-rule"/>
<context ref="css:embedded-lang-hook"/>
@@ -954,8 +952,8 @@
<context id="parent-combinator">
<match>(&)(\%{css:identifier-chars}?)</match>
<include>
- <context sub-pattern="1" style-ref="css:combinator"/>
- <context sub-pattern="2" style-ref="selector-fragment"/>
+ <context sub-pattern="1" style-ref="css:combinator"/>
+ <context sub-pattern="2" style-ref="selector-fragment"/>
</include>
</context>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]