3 pygments.lexers.haskell |
3 pygments.lexers.haskell |
4 ~~~~~~~~~~~~~~~~~~~~~~~ |
4 ~~~~~~~~~~~~~~~~~~~~~~~ |
5 |
5 |
6 Lexers for Haskell and related languages. |
6 Lexers for Haskell and related languages. |
7 |
7 |
8 :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. |
8 :copyright: Copyright 2006-2020 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 |
325 (r'\{!', Comment.Directive, 'hole'), |
325 (r'\{!', Comment.Directive, 'hole'), |
326 # Lexemes: |
326 # Lexemes: |
327 # Identifiers |
327 # Identifiers |
328 (r'\b(%s)(?!\')\b' % '|'.join(reserved), Keyword.Reserved), |
328 (r'\b(%s)(?!\')\b' % '|'.join(reserved), Keyword.Reserved), |
329 (r'(import|module)(\s+)', bygroups(Keyword.Reserved, Text), 'module'), |
329 (r'(import|module)(\s+)', bygroups(Keyword.Reserved, Text), 'module'), |
330 (u'\\b(Set|Prop)[\u2080-\u2089]*\\b', Keyword.Type), |
330 (r'\b(Set|Prop)[\u2080-\u2089]*\b', Keyword.Type), |
331 # Special Symbols |
331 # Special Symbols |
332 (r'(\(|\)|\{|\})', Operator), |
332 (r'(\(|\)|\{|\})', Operator), |
333 (u'(\\.{1,3}|\\||\u03BB|\u2200|\u2192|:|=|->)', Operator.Word), |
333 (r'(\.{1,3}|\||\u03BB|\u2200|\u2192|:|=|->)', Operator.Word), |
334 # Numbers |
334 # Numbers |
335 (r'\d+[eE][+-]?\d+', Number.Float), |
335 (r'\d+[eE][+-]?\d+', Number.Float), |
336 (r'\d+\.\d+([eE][+-]?\d+)?', Number.Float), |
336 (r'\d+\.\d+([eE][+-]?\d+)?', Number.Float), |
337 (r'0[xX][\da-fA-F]+', Number.Hex), |
337 (r'0[xX][\da-fA-F]+', Number.Hex), |
338 (r'\d+', Number.Integer), |
338 (r'\d+', Number.Integer), |
557 latex = '' |
557 latex = '' |
558 else: |
558 else: |
559 latex += line |
559 latex += line |
560 insertions.append((len(code), |
560 insertions.append((len(code), |
561 list(lxlexer.get_tokens_unprocessed(latex)))) |
561 list(lxlexer.get_tokens_unprocessed(latex)))) |
562 for item in do_insertions(insertions, self.baselexer.get_tokens_unprocessed(code)): |
562 yield from do_insertions(insertions, self.baselexer.get_tokens_unprocessed(code)) |
563 yield item |
|
564 |
563 |
565 |
564 |
566 class LiterateHaskellLexer(LiterateLexer): |
565 class LiterateHaskellLexer(LiterateLexer): |
567 """ |
566 """ |
568 For Literate Haskell (Bird-style or LaTeX) source. |
567 For Literate Haskell (Bird-style or LaTeX) source. |