[gtksourceview: 3/4] php.lang: Add support for flexible heredoc and nowdoc syntaxes



commit eaaae5fa3e1bd48490c9adc94ebf7495e2d37d30
Author: Jeffery To <jeffery to gmail com>
Date:   Tue Oct 29 00:10:16 2019 +0800

    php.lang: Add support for flexible heredoc and nowdoc syntaxes
    
    Supported since PHP 7.3.0[1].
    
    This also fixes the highlighting for the semicolon following heredoc
    closing identifiers.
    
    [1]: https://wiki.php.net/rfc/flexible_heredoc_nowdoc_syntaxes

 data/language-specs/php.lang       |  9 ++++++---
 tests/syntax-highlighting/file.php | 16 ++++++++++++++--
 2 files changed, 20 insertions(+), 5 deletions(-)
---
diff --git a/data/language-specs/php.lang b/data/language-specs/php.lang
index 17eed5f0..1608260c 100644
--- a/data/language-specs/php.lang
+++ b/data/language-specs/php.lang
@@ -150,10 +150,11 @@
 
     <context id="here-doc-string" style-ref="here-doc" extend-parent="true">
       <start>(&lt;&lt;&lt;)\s?(\%{identifier})</start>
-      <end>^(\%{2@start});?$</end>
+      <end>^\s*(\%{2@start})(;|\b)</end>
       <include>
         <context sub-pattern="0" where="start" style-ref="here-doc-bound"/>
         <context sub-pattern="1" where="end" style-ref="here-doc-bound"/>
+        <context sub-pattern="2" where="end" style-ref="operator"/>
         <context ref="escape"/>
         <context ref="string-var"/>
         <context ref="def:line-continue"/>
@@ -162,10 +163,11 @@
 
     <context id="here-doc-string-double-quotes" style-ref="here-doc" extend-parent="true">
       <start>(&lt;&lt;&lt;)\s?"(\%{identifier})"</start>
-      <end>^(\%{2@start});?$</end>
+      <end>^\s*(\%{2@start})(;|\b)</end>
       <include>
         <context sub-pattern="0" where="start" style-ref="here-doc-bound"/>
         <context sub-pattern="1" where="end" style-ref="here-doc-bound"/>
+        <context sub-pattern="2" where="end" style-ref="operator"/>
         <context ref="escape"/>
         <context ref="string-var"/>
         <context ref="def:line-continue"/>
@@ -174,10 +176,11 @@
 
     <context id="now-doc-string" style-ref="here-doc" extend-parent="true">
       <start>(&lt;&lt;&lt;)\s?'(\%{identifier})'</start>
-      <end>^(\%{2@start});?$</end>
+      <end>^\s*(\%{2@start})(;|\b)</end>
       <include>
         <context sub-pattern="0" where="start" style-ref="here-doc-bound"/>
         <context sub-pattern="1" where="end" style-ref="here-doc-bound"/>
+        <context sub-pattern="2" where="end" style-ref="operator"/>
         <context style-ref="def:special-char">
           <match>\\['\\]</match>
         </context>
diff --git a/tests/syntax-highlighting/file.php b/tests/syntax-highlighting/file.php
index fe4b0f71..992375b8 100644
--- a/tests/syntax-highlighting/file.php
+++ b/tests/syntax-highlighting/file.php
@@ -8,7 +8,19 @@ text
 extrémité
 
 echo <<<"END"
+      a
+     b
+    c
+    END;
+
+stringManipulator(<<<'END'
+   a
+  b
+ c
+END);
+
+$values = [<<<END
 a
 b
-c
-END;
+ENDING
+END, 'd e f'];


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