3 pygments.lexers.fortran |
3 pygments.lexers.fortran |
4 ~~~~~~~~~~~~~~~~~~~~~~~ |
4 ~~~~~~~~~~~~~~~~~~~~~~~ |
5 |
5 |
6 Lexers for Fortran languages. |
6 Lexers for Fortran languages. |
7 |
7 |
8 :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS. |
8 :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS. |
9 :license: BSD, see LICENSE for details. |
9 :license: BSD, see LICENSE for details. |
10 """ |
10 """ |
11 |
11 |
12 import re |
12 import re |
13 |
13 |
14 from pygments.lexer import RegexLexer, bygroups, include, words, using |
14 from pygments.lexer import RegexLexer, bygroups, include, words, using, default |
15 from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ |
15 from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ |
16 Number, Punctuation, Generic |
16 Number, Punctuation, Generic |
17 |
17 |
18 __all__ = ['FortranLexer', 'FortranFixedLexer'] |
18 __all__ = ['FortranLexer', 'FortranFixedLexer'] |
19 |
19 |
154 (r"(?s)'(\\\\|\\[0-7]+|\\.|[^'\\])*'", String.Single), |
154 (r"(?s)'(\\\\|\\[0-7]+|\\.|[^'\\])*'", String.Single), |
155 ], |
155 ], |
156 |
156 |
157 'nums': [ |
157 'nums': [ |
158 (r'\d+(?![.e])(_[a-z]\w+)?', Number.Integer), |
158 (r'\d+(?![.e])(_[a-z]\w+)?', Number.Integer), |
159 (r'[+-]?\d*\.\d+(e[-+]?\d+)?(_[a-z]\w+)?', Number.Float), |
159 (r'[+-]?\d*\.\d+([ed][-+]?\d+)?(_[a-z]\w+)?', Number.Float), |
160 (r'[+-]?\d+\.\d*(e[-+]?\d+)?(_[a-z]\w+)?', Number.Float), |
160 (r'[+-]?\d+\.\d*([ed][-+]?\d+)?(_[a-z]\w+)?', Number.Float), |
161 ], |
161 ], |
162 } |
162 } |
163 |
163 |
164 |
164 |
165 class FortranFixedLexer(RegexLexer): |
165 class FortranFixedLexer(RegexLexer): |
189 (r'#.*\n', Comment.Preproc), |
189 (r'#.*\n', Comment.Preproc), |
190 (r' {0,4}!.*\n', Comment), |
190 (r' {0,4}!.*\n', Comment), |
191 (r'(.{5})', Name.Label, 'cont-char'), |
191 (r'(.{5})', Name.Label, 'cont-char'), |
192 (r'.*\n', using(FortranLexer)), |
192 (r'.*\n', using(FortranLexer)), |
193 ], |
193 ], |
194 |
|
195 'cont-char': [ |
194 'cont-char': [ |
196 (' ', Text, 'code'), |
195 (' ', Text, 'code'), |
197 ('0', Comment, 'code'), |
196 ('0', Comment, 'code'), |
198 ('.', Generic.Strong, 'code') |
197 ('.', Generic.Strong, 'code'), |
199 ], |
198 ], |
200 |
|
201 'code': [ |
199 'code': [ |
202 (r'(.{66})(.*)(\n)', |
200 (r'(.{66})(.*)(\n)', |
203 bygroups(_lex_fortran, Comment, Text), 'root'), |
201 bygroups(_lex_fortran, Comment, Text), 'root'), |
204 (r'(.*)(\n)', bygroups(_lex_fortran, Text), 'root'), |
202 (r'(.*)(\n)', bygroups(_lex_fortran, Text), 'root'), |
205 (r'', Text, 'root')] |
203 default('root'), |
|
204 ] |
206 } |
205 } |