-- cgit v1.2.1 From e9a803bbaf3fee217f64f7bf32a18278770dfe36 Mon Sep 17 00:00:00 2001 From: Josiah Schwab Date: Thu, 18 Aug 2016 18:44:44 -0700 Subject: Add exponent-letter D to Fortran lexer In the Fortran specification, the exponent-letter within a signed-real-literal-constant is E or D. Therefore, both 3.14159e0 and 3.14159d0 should be classified as a Number.Float. The current behavior is >>> print(highlight("3.14159d0", FortranLexer(), HtmlFormatter()))
3.14159d0
where the only the significand is classified as a Number.Float while the exponent-letter and exponent are classified as Name.Variable. After this patch the behavior is >>> print(highlight("3.14159d0", FortranLexer(), HtmlFormatter()))
3.14159d0
which is the expected behavior. --- pygments/lexers/fortran.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygments/lexers/fortran.py b/pygments/lexers/fortran.py index e2f95b11..6cc8f2c8 100644 --- a/pygments/lexers/fortran.py +++ b/pygments/lexers/fortran.py @@ -156,8 +156,8 @@ class FortranLexer(RegexLexer): 'nums': [ (r'\d+(?![.e])(_[a-z]\w+)?', Number.Integer), - (r'[+-]?\d*\.\d+(e[-+]?\d+)?(_[a-z]\w+)?', Number.Float), - (r'[+-]?\d+\.\d*(e[-+]?\d+)?(_[a-z]\w+)?', Number.Float), + (r'[+-]?\d*\.\d+([ed][-+]?\d+)?(_[a-z]\w+)?', Number.Float), + (r'[+-]?\d+\.\d*([ed][-+]?\d+)?(_[a-z]\w+)?', Number.Float), ], } -- cgit v1.2.1