[gtksourceview/gtksourceview-4-2] ruby.lang: fix octal and hex string literals, change their style



commit fe230354e2112c688ca37c5fa7b0bbb254cb6691
Author: Vlasta Vesely <vlastavesely protonmail ch>
Date:   Sat Jan 4 21:54:40 2020 +0100

    ruby.lang: fix octal and hex string literals, change their style

 data/language-specs/ruby.lang     | 7 ++++---
 tests/syntax-highlighting/file.rb | 6 +++++-
 2 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/data/language-specs/ruby.lang b/data/language-specs/ruby.lang
index 3b83c4d6..99beeced 100644
--- a/data/language-specs/ruby.lang
+++ b/data/language-specs/ruby.lang
@@ -43,6 +43,7 @@
     <style id="decimal"              name="Decimal number"        map-to="def:decimal"/>
     <style id="base-n-integer"       name="Base-N number"         map-to="def:base-n-integer"/>
     <style id="numeric-literal"      name="Numeric literal"       map-to="def:base-n-integer"/>
+    <style id="string-literal"       name="String literal"        map-to="def:string"/>
     <style id="string"               name="String"                map-to="def:string"/>
     <style id="literal"              name="Literal"               map-to="def:special-char"/>
     <style id="builtin"              name="Builtin"               map-to="def:type"/>
@@ -405,8 +406,8 @@
       
<match>(?&lt;!\.\.\.\.)((?&lt;![\w\.])|(?&lt;=\.\.))0[bB][01](_?[01])*((?![\w\.])|(?=\.\.)|(?=\.[a-zA-Z_]))(?!\.\.\.\.)</match>
     </context>
 
-    <context id="numeric-literal" style-ref="numeric-literal">
-      <match>(?&lt;!\.\.\.\.)((?&lt;![\w\.])|(?&lt;=\.\.))\?((\\[MC]-){1,2}|\\?)\S</match>
+    <context id="string-literal" style-ref="string-literal">
+      
<match>(?&lt;!\.\.\.\.)((?&lt;![\w\.])|(?&lt;=\.\.))\?((\\[MC]-){1,2}|\\?)(x[a-fA-F0-9]{2}|[0-7]{3}|\S)</match>
     </context>
 
     <!-- in double quotes and backticks -->
@@ -737,7 +738,7 @@
         <context ref="hex"/>
         <context ref="octal"/>
         <context ref="binary"/>
-        <context ref="numeric-literal"/>
+        <context ref="string-literal"/>
         <context ref="regex-alt-form"/>
         <context ref="regex-simple"/>
         <context ref="non-interpolated-literal"/>
diff --git a/tests/syntax-highlighting/file.rb b/tests/syntax-highlighting/file.rb
index e3224b73..28c126c8 100644
--- a/tests/syntax-highlighting/file.rb
+++ b/tests/syntax-highlighting/file.rb
@@ -11,5 +11,9 @@ puts -11.to_s + ' ' + 0x11.to_s  + ' ' + 1.1.to_s + ' ' + ?a.to_s + ' ' + 1.x
 
 # Ranges
 11..11, 0x11..0x11, 01..07, ?a..?f, 1.1..2.2 # range incl. the last value
-11...11, 0x11...0x11, 01...07, ?a...?f, 1.1...2.2 # range excl. the last value
+11...11, 0x11...0x11, 01...07, ?x40...?\101, 1.1...2.2 # range excl. the last value
 11....111, 0x11......0x11, 1.1.....1.2 # 4 (and more) dots are not a valid range
+
+# String literals
+str = ?\x41 + ?\101 # == 'AA'
+puts ?\M-\C-x


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