[gtksourceview: 3/4] scss.lang, less.lang: Fix single-line comments not ignored



commit 228eaabedec96f3cf9debeded78cc0165d8d0c73
Author: Jeffery To <jeffery to gmail com>
Date:   Tue Jan 21 03:41:59 2020 +0800

    scss.lang, less.lang: Fix single-line comments not ignored
    
    This fixes the declaration/selector test to ignore content inside of
    single-line comments.

 data/language-specs/less.lang       | 10 +++++++---
 data/language-specs/scss.lang       | 13 +++++++++----
 tests/syntax-highlighting/file.less |  5 +++++
 tests/syntax-highlighting/file.scss |  5 +++++
 4 files changed, 26 insertions(+), 7 deletions(-)
---
diff --git a/data/language-specs/less.lang b/data/language-specs/less.lang
index 2f483944..bedfd061 100644
--- a/data/language-specs/less.lang
+++ b/data/language-specs/less.lang
@@ -398,8 +398,8 @@
     <context id="less-declaration-value">
       <start extended="true">
         (?(DEFINE)
-          (?&lt;escape_comment_start&gt; (?: \\ /\* )+ )
-          (?&lt;escape&gt;               (?: \\ .   )+ )
+          (?&lt;escape_comment_start&gt; (?: \\ /[/*] )+ )
+          (?&lt;escape&gt;               (?: \\ .     )+ )
 
           (?&lt;escape_not_interpolation_start&gt; (?: \\ (?! @{ ) . )+ )
 
@@ -407,12 +407,14 @@
             (?: (?: @ (?! { ) )+ | (?: (?&lt;! @ ) { )+ )
           )
           (?&lt;comment_start_chars&gt;
-            (?: (?: / (?! \* ) )+ | (?: (?&lt;! / ) \* )+ )
+            (?: (?: (?&lt;! / ) / (?! [/*] ) )+ | (?: (?&lt;! / ) \* )+ )
           )
           (?&lt;comment_end_chars&gt;
             (?: (?: \* (?! / ) )+ | (?: (?&lt;! \* ) / )+ )
           )
 
+          (?&lt;single_line_comment&gt; // .* )
+
           (?&lt;interpolation&gt;  # recursive subpattern to find matching braces
             @{
             (?:
@@ -440,6 +442,7 @@
                 )+
               ) |
               (?&amp;parentheses) |
+              (?&amp;single_line_comment) |
               (?&amp;multiline_comment) |
               (?&amp;double_quote_string) |
               (?&amp;single_quote_string)
@@ -513,6 +516,7 @@
                   )+
                 ) |
                 (?&amp;parentheses) |
+                (?&amp;single_line_comment) |
                 (?&amp;multiline_comment) |
                 (?&amp;double_quote_string) |
                 (?&amp;single_quote_string)
diff --git a/data/language-specs/scss.lang b/data/language-specs/scss.lang
index 63ffa8e9..5d7ee953 100644
--- a/data/language-specs/scss.lang
+++ b/data/language-specs/scss.lang
@@ -409,20 +409,22 @@
     <context id="scss-declaration-value">
       <start extended="true">
         (?(DEFINE)
-          (?&lt;escape_interpolation_start&gt; (?: \\ \#{ )+ )
-          (?&lt;escape_comment_start&gt;       (?: \\ /\* )+ )
-          (?&lt;escape&gt;                     (?: \\ .   )+ )
+          (?&lt;escape_interpolation_start&gt; (?: \\ \#{   )+ )
+          (?&lt;escape_comment_start&gt;       (?: \\ /[/*] )+ )
+          (?&lt;escape&gt;                     (?: \\ .     )+ )
 
           (?&lt;interpolation_start_chars&gt;
             (?: (?: \# (?! { ) )+ | (?: (?&lt;! \# ) { )+ )
           )
           (?&lt;comment_start_chars&gt;
-            (?: (?: / (?! \* ) )+ | (?: (?&lt;! / ) \* )+ )
+            (?: (?: (?&lt;! / ) / (?! [/*] ) )+ | (?: (?&lt;! / ) \* )+ )
           )
           (?&lt;comment_end_chars&gt;
             (?: (?: \* (?! / ) )+ | (?: (?&lt;! \* ) / )+ )
           )
 
+          (?&lt;single_line_comment&gt; // .* )
+
           (?&lt;interpolation&gt;  # recursive subpattern to find matching braces
             \#{
             (?:
@@ -438,6 +440,7 @@
               ) |
               (?&amp;interpolation) |
               (?&amp;parentheses) |
+              (?&amp;single_line_comment) |
               (?&amp;multiline_comment) |
               (?&amp;double_quote_string) |
               (?&amp;single_quote_string)
@@ -460,6 +463,7 @@
               ) |
               (?&amp;interpolation) |
               (?&amp;parentheses) |
+              (?&amp;single_line_comment) |
               (?&amp;multiline_comment) |
               (?&amp;double_quote_string) |
               (?&amp;single_quote_string)
@@ -539,6 +543,7 @@
                 ) |
                 (?&amp;interpolation) |
                 (?&amp;parentheses) |
+                (?&amp;single_line_comment) |
                 (?&amp;multiline_comment) |
                 (?&amp;double_quote_string) |
                 (?&amp;single_quote_string)
diff --git a/tests/syntax-highlighting/file.less b/tests/syntax-highlighting/file.less
index 594fcaba..a6f9d486 100644
--- a/tests/syntax-highlighting/file.less
+++ b/tests/syntax-highlighting/file.less
@@ -425,6 +425,8 @@ div {
     // incorrectly highlighted declarations
     display:block
     ;
+    display:block // {
+    ;
 
     // selectors
     input:focus { opacity: 0.5; }
@@ -450,6 +452,9 @@ div {
 
     a:focus[id=' ] \' \; ; '] { color: blue; }
     a:focus[id=' @{var}    '] { color: blue; }
+
+    a:focus // ;
+    { color: blue; }
 }
 
 
diff --git a/tests/syntax-highlighting/file.scss b/tests/syntax-highlighting/file.scss
index 695a771a..a764ae45 100644
--- a/tests/syntax-highlighting/file.scss
+++ b/tests/syntax-highlighting/file.scss
@@ -457,6 +457,8 @@ div {
     // incorrectly highlighted declarations
     display:block
     ;
+    display:block // {
+    ;
 
     // selectors
     input:focus { opacity: 0.5; }
@@ -488,6 +490,9 @@ div {
 
     a:focus[id=' ] \' \; ;      '] { color: blue; }
     a:focus[id=' #{ \' '' ';' } '] { color: blue; }
+
+    a:focus // ;
+    { color: blue; }
 }
 
 


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