1. Georg Brandl
  2. pygments-main

Commits

Gaurav Jain  committed 1be52aa

Add support for kind paramter for integer and real types

Integers and reals can have an optional kind parameter specified with an underscore. This could have the format of any variable name. Additionally added example file to demonstrate usage.

  • Participants
  • Parent commits 33931e7
  • Branches default

Comments (0)

Files changed (2)

File pygments/lexers/compiled.py

View file
         ],
 
         'nums': [
-            (r'\d+(?![.Ee])', Number.Integer),
-            (r'[+-]?\d*\.\d+([eE][-+]?\d+)?', Number.Float),
-            (r'[+-]?\d+\.\d*([eE][-+]?\d+)?', Number.Float),
+            (r'\d+(?![.Ee])(_[a-z][a-z0-9_]+)?', Number.Integer),
+            (r'[+-]?\d*\.\d+([eE][-+]?\d+)?(_[a-z][a-z0-9_]+)?', Number.Float),
+            (r'[+-]?\d+\.\d*([eE][-+]?\d+)?(_[a-z][a-z0-9_]+)?', Number.Float),
         ],
     }
 

File tests/examplefiles/example.f90

View file
+program main
+  integer, parameter :: mykind = selected_real_kind()
+  print *, 1
+  print *, 1_mykind
+  print *, 1.
+  print *, 1._mykind
+  print *, (1., 1._mykind)
+end program main