[gtksourceview: 6/14] javascript.lang: Add number-start and number-end regexes



commit a880ff8e4b5da33316df2ab0350beae1814430c4
Author: Jeffery To <jeffery to gmail com>
Date:   Sun Jun 7 03:10:14 2020 +0800

    javascript.lang: Add number-start and number-end regexes

 data/language-specs/javascript-literals.lang    | 36 +++++--------------------
 data/language-specs/javascript.lang             |  8 ++++++
 data/language-specs/typescript-js-literals.lang | 30 ++++-----------------
 3 files changed, 19 insertions(+), 55 deletions(-)
---
diff --git a/data/language-specs/javascript-literals.lang b/data/language-specs/javascript-literals.lang
index e52ff891..c711cd71 100644
--- a/data/language-specs/javascript-literals.lang
+++ b/data/language-specs/javascript-literals.lang
@@ -70,11 +70,7 @@
         <!-- <DecimalLiteral> -->
         <context id="_choice-decimal" style-ref="js:decimal" end-parent="true">
           <start extended="true">
-            (?&lt;! \%{js:identifier-char} | \. )
-            (?=
-              \%{_decimal}
-              (?! \%{js:identifier-part} | \. )
-            )
+            \%{js:number-start} (?= \%{_decimal} \%{js:number-end} )
           </start>
           <end>\%{_decimal}</end>
         </context> <!-- /_choice-decimal -->
@@ -87,11 +83,7 @@
         <!-- <DecimalBigIntegerLiteral> -->
         <context id="_choice-decimal-big-integer" style-ref="js:decimal" end-parent="true">
           <start extended="true">
-            (?&lt;! \%{js:identifier-char} | \. )
-            (?=
-              \%{_decimal-integer} n
-              (?! \%{js:identifier-part} | \. )
-            )
+            \%{js:number-start} (?= \%{_decimal-integer} n \%{js:number-end} )
           </start>
           <end>\%{_decimal-integer}n</end>
         </context> <!-- /_choice-decimal-big-integer -->
@@ -103,11 +95,7 @@
         <!-- <BinaryIntegerLiteral> -->
         <context id="_choice-binary-integer" style-ref="js:binary-integer" end-parent="true">
           <start extended="true">
-            (?&lt;! \%{js:identifier-char} | \. )
-            (?=
-              \%{_binary-integer} n?
-              (?! \%{js:identifier-part} | \. )
-            )
+            \%{js:number-start} (?= \%{_binary-integer} n? \%{js:number-end} )
           </start>
           <end>\%{_binary-integer}n?</end>
         </context> <!-- /_choice-binary-integer -->
@@ -119,11 +107,7 @@
         <!-- <OctalIntegerLiteral> -->
         <context id="_choice-octal-integer" style-ref="js:octal-integer" end-parent="true">
           <start extended="true">
-            (?&lt;! \%{js:identifier-char} | \. )
-            (?=
-              \%{_octal-integer} n?
-              (?! \%{js:identifier-part} | \. )
-            )
+            \%{js:number-start} (?= \%{_octal-integer} n? \%{js:number-end} )
           </start>
           <end>\%{_octal-integer}n?</end>
         </context> <!-- /_choice-octal-integer -->
@@ -135,11 +119,7 @@
 
         <context id="_choice-hex-integer" style-ref="js:hex-integer" end-parent="true">
           <start extended="true">
-            (?&lt;! \%{js:identifier-char} | \. )
-            (?=
-              \%{_hex-integer} n?
-              (?! \%{js:identifier-part} | \. )
-            )
+            \%{js:number-start} (?= \%{_hex-integer} n? \%{js:number-end} )
           </start>
           <end>\%{_hex-integer}n?</end>
         </context> <!-- /_choice-hex-integer -->
@@ -151,11 +131,7 @@
         <!-- Annex B: <LegacyOctalIntegerLiteral> -->
         <context id="_choice-legacy-octal-integer" style-ref="js:error" end-parent="true">
           <start extended="true">
-            (?&lt;! \%{js:identifier-char} | \. )
-            (?=
-              \%{_legacy-octal-integer}
-              (?! \%{js:identifier-part} | \. )
-            )
+            \%{js:number-start} (?= \%{_legacy-octal-integer} \%{js:number-end} )
           </start>
           <end>\%{_legacy-octal-integer}</end>
         </context> <!-- /_choice-legacy-octal-integer -->
diff --git a/data/language-specs/javascript.lang b/data/language-specs/javascript.lang
index df39df16..f2736729 100644
--- a/data/language-specs/javascript.lang
+++ b/data/language-specs/javascript.lang
@@ -287,6 +287,14 @@
           so we move the definitions of these regexes here
     -->
 
+    <define-regex id="number-start" extended="true">
+      (?&lt;! \%{identifier-char} | \. )
+    </define-regex> <!-- /number-start -->
+
+    <define-regex id="number-end" extended="true">
+      (?! \%{identifier-part} | \. )
+    </define-regex> <!-- /number-end -->
+
     <!-- async function (ES2017)
          no line terminator allowed between "async" and "function" -->
     <define-regex id="function-expression-keyword" extended="true">
diff --git a/data/language-specs/typescript-js-literals.lang b/data/language-specs/typescript-js-literals.lang
index 58c82f70..8ef69688 100644
--- a/data/language-specs/typescript-js-literals.lang
+++ b/data/language-specs/typescript-js-literals.lang
@@ -58,11 +58,7 @@
 
         <context id="_choice-decimal" style-ref="js:decimal" end-parent="true">
           <start extended="true">
-            (?&lt;! \%{js:identifier-char} | \. )
-            (?=
-              \%{_decimal}
-              (?! \%{js:identifier-part} | \. )
-            )
+            \%{js:number-start} (?= \%{_decimal} \%{js:number-end} )
           </start>
           <end>\%{_decimal}</end>
         </context> <!-- /_choice-decimal -->
@@ -73,11 +69,7 @@
 
         <context id="_choice-decimal-big-integer" style-ref="js:decimal" end-parent="true">
           <start extended="true">
-            (?&lt;! \%{js:identifier-char} | \. )
-            (?=
-              \%{_decimal-integer} n
-              (?! \%{js:identifier-part} | \. )
-            )
+            \%{js:number-start} (?= \%{_decimal-integer} n \%{js:number-end} )
           </start>
           <end>\%{_decimal-integer}n</end>
         </context> <!-- /_choice-decimal-big-integer -->
@@ -88,11 +80,7 @@
 
         <context id="_choice-binary-integer" style-ref="js:binary-integer" end-parent="true">
           <start extended="true">
-            (?&lt;! \%{js:identifier-char} | \. )
-            (?=
-              \%{_binary-integer} n?
-              (?! \%{js:identifier-part} | \. )
-            )
+            \%{js:number-start} (?= \%{_binary-integer} n? \%{js:number-end} )
           </start>
           <end>\%{_binary-integer}n?</end>
         </context> <!-- /_choice-binary-integer -->
@@ -103,11 +91,7 @@
 
         <context id="_choice-octal-integer" style-ref="js:octal-integer" end-parent="true">
           <start extended="true">
-            (?&lt;! \%{js:identifier-char} | \. )
-            (?=
-              \%{_octal-integer} n?
-              (?! \%{js:identifier-part} | \. )
-            )
+            \%{js:number-start} (?= \%{_octal-integer} n? \%{js:number-end} )
           </start>
           <end>\%{_octal-integer}n?</end>
         </context> <!-- /_choice-octal-integer -->
@@ -118,11 +102,7 @@
 
         <context id="_choice-hex-integer" style-ref="js:hex-integer" end-parent="true">
           <start extended="true">
-            (?&lt;! \%{js:identifier-char} | \. )
-            (?=
-              \%{_hex-integer} n?
-              (?! \%{js:identifier-part} | \. )
-            )
+            \%{js:number-start} (?= \%{_hex-integer} n? \%{js:number-end} )
           </start>
           <end>\%{_hex-integer}n?</end>
         </context> <!-- /_choice-hex-integer -->


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]