[gtksourceview] cmake.lang: multiple improvements to the "variable" context



commit 4007ba012e9a9c6736297e3ff3917268f6cc37c3
Author: Роман Донченко <dpb corrigendum ru>
Date:   Sun Nov 12 18:28:46 2017 +0300

    cmake.lang: multiple improvements to the "variable" context
    
    * rename to "variable-reference", since that's the official name of the
      corresponding syntax element;
    * add support for nesting;
    * apply the "special char" style to the ${} markers;
    * highlight escape sequences in variable names;
    * highlight disallowed characters in variable names.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=790345

 data/language-specs/cmake.lang |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/data/language-specs/cmake.lang b/data/language-specs/cmake.lang
index a95c673..53fdc6d 100644
--- a/data/language-specs/cmake.lang
+++ b/data/language-specs/cmake.lang
@@ -682,13 +682,30 @@
       <keyword>WHILE</keyword>
     </context>
 
-    <context id="variable" style-ref="variable"
+    <context id="escape-sequence">
+      <match>(\\([trn;]|[^A-Za-z0-9;]))|(\\(.|$))</match>
+      <include>
+        <context sub-pattern="1" style-ref="def:special-char"/>
+        <context sub-pattern="3" style-ref="def:error"/>
+      </include>
+    </context>
+
+    <context id="disallowed-variable-reference-char" style-ref="def:error" extend-parent="false">
+      <match>[^A-Za-z0-9_./+-]</match>
+    </context>
+
+    <context id="variable-reference" style-ref="variable"
              style-inside="true" end-at-line-end="true"
     >
       <start>\$\{</start>
       <end>\}</end>
       <include>
+        <context sub-pattern="0" where="start" style-ref="def:special-char"/>
+        <context sub-pattern="0" where="end" style-ref="def:special-char"/>
         <context ref="builtin-variable"/>
+        <context ref="variable-reference"/>
+        <context ref="escape-sequence"/>
+        <context ref="disallowed-variable-reference-char"/>
       </include>
     </context>
 
@@ -698,7 +715,7 @@
       <include>
         <context sub-pattern="1" where="start" style-ref="builtin-command"/>
         <context sub-pattern="2" where="start" style-ref="variable"/>
-        <context ref="variable"/>
+        <context ref="variable-reference"/>
         <context ref="constant"/>
         <context ref="def:shell-like-comment"/>
       </include>
@@ -706,7 +723,7 @@
 
     <context id="cmake">
       <include>
-        <context ref="variable"/>
+        <context ref="variable-reference"/>
         <context ref="variable-assignment"/>
         <context ref="def:shell-like-comment"/>
         <context ref="constant"/>


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