[gtksourceview] Fortran syntax highlighting improvement



commit 85787b25dfc418ef3d3572f17b74228793e99225
Author: Alexander Vogt <a vogt fulguritus com>
Date:   Thu May 15 16:08:08 2014 +0200

    Fortran syntax highlighting improvement
    
    * Added OpenMP directives to the Fortran language specs
    * Updated testfiles.sh with a Fortran 90/95 program
    
    https://bugzilla.gnome.org/show_bug.cgi?id=730130

 data/language-specs/fortran.lang |   10 +++++++++-
 tests/testfiles.sh               |   30 ++++++++++++++++++++++++------
 2 files changed, 33 insertions(+), 7 deletions(-)
---
diff --git a/data/language-specs/fortran.lang b/data/language-specs/fortran.lang
index cb369b2..927f971 100644
--- a/data/language-specs/fortran.lang
+++ b/data/language-specs/fortran.lang
@@ -39,6 +39,7 @@
     <style id="decimal" _name="Decimal" map-to="def:decimal"/>
     <style id="type" _name="Data Type" map-to="def:type"/>
     <style id="preprocessor" _name="Preprocessor" map-to="def:preprocessor"/>
+    <style id="openmp-directives" _name="OpenMP directives" map-to="def:preprocessor"/>
     <style id="included-file" _name="Included File" map-to="def:string"/>
     <style id="escaped-character" _name="Escaped Character" map-to="def:special-char"/>
   </styles>
@@ -92,6 +93,12 @@
       </start>
     </context>
 
+    <context id="openmp-directives" style-ref="openmp-directives" end-at-line-end="true">
+      <start extended="true">
+        ((^[Cc])|^\s*!)\$
+      </start>
+    </context>
+
     <!--
     <context id="string" style-ref="string" end-at-line-end="true" class="string" 
class-disabled="no-spell-check">
       <match>(L?'[^']*')|(L?"[^"]*")</match>
@@ -110,7 +117,7 @@
 
     <!-- Note: contains an hack to avoid considering ^COMMON or ^CHARACTER a comment -->
     <context id="line-comment" style-ref="comment" end-at-line-end="true" class="comment" 
class-disabled="no-spell-check">
-      <start>!|(^[Cc](\b|[^OoAaYyHh]))</start>
+      <start>(![^$])|(^[Cc](\s|[^$OoAaYyHh]))|(^[Cc]$)</start>
       <include>
         <context ref="def:escape"/>
         <context ref="def:in-line-comment"/>
@@ -576,6 +583,7 @@
         <context ref="if0-comment"/>
         <context ref="include"/>
         <context ref="preprocessor"/>
+        <context ref="openmp-directives"/>
       </include>
     </context>
 
diff --git a/tests/testfiles.sh b/tests/testfiles.sh
index 6d6eb69..37d4cb2 100755
--- a/tests/testfiles.sh
+++ b/tests/testfiles.sh
@@ -328,12 +328,30 @@ EOFEOF
 
 cat > $dir/file.f <<EOFEOF
 ! gtk-source-lang: fortran
-c comment
-if .TRUE.
-.FALSE.
-endif
-Numbers: 1234 o'10176' b'10101' z'23FF'
-12. .12 12.12 1.23e+09 1.23D+09
+program test95
+  ! Comment: This is a Fortran free-form program
+!$ use omp_lib
+  ! The previous line is not a comment, but an OpenMP directive
+  implicit none
+  character(len=9),parameter  :: t='Some text'
+  integer,parameter           :: a=1
+  real,parameter              :: r1=1.23e0, r2=.12, r3=12., r4=12.12, r5=1.d0
+!$  real*8                    :: t1, t2
+  integer                     :: i
+
+!$ t1 = omp_get_wtime()
+  if ( .true. ) then
+    print *, a, t
+    print *,size( (/ r1, r2, r3, r4, r5 /) )
+  endif
+  !$omp parallel do
+  do i=1,100
+    print *,i
+  enddo ! i
+  !$omp end parallel do
+!$ t2 = omp_get_wtime()
+!$ print *,'The loop took ',t2-t1,'seconds'
+end program
 EOFEOF
 
 cat > $dir/file.frt <<EOFEOF


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