ThirdParty/Pygments/pygments/lexers/haskell.py

changeset 5713
6762afd9f963
parent 4697
c2e9bf425554
child 6651
e8f3b5568b21
equal deleted inserted replaced
5712:f0d08bdeacf4 5713:6762afd9f963
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-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
37 mimetypes = ['text/x-haskell'] 37 mimetypes = ['text/x-haskell']
38 38
39 flags = re.MULTILINE | re.UNICODE 39 flags = re.MULTILINE | re.UNICODE
40 40
41 reserved = ('case', 'class', 'data', 'default', 'deriving', 'do', 'else', 41 reserved = ('case', 'class', 'data', 'default', 'deriving', 'do', 'else',
42 'if', 'in', 'infix[lr]?', 'instance', 42 'family', 'if', 'in', 'infix[lr]?', 'instance',
43 'let', 'newtype', 'of', 'then', 'type', 'where', '_') 43 'let', 'newtype', 'of', 'then', 'type', 'where', '_')
44 ascii = ('NUL', 'SOH', '[SE]TX', 'EOT', 'ENQ', 'ACK', 44 ascii = ('NUL', 'SOH', '[SE]TX', 'EOT', 'ENQ', 'ACK',
45 'BEL', 'BS', 'HT', 'LF', 'VT', 'FF', 'CR', 'S[OI]', 'DLE', 45 'BEL', 'BS', 'HT', 'LF', 'VT', 'FF', 'CR', 'S[OI]', 'DLE',
46 'DC[1-4]', 'NAK', 'SYN', 'ETB', 'CAN', 46 'DC[1-4]', 'NAK', 'SYN', 'ETB', 'CAN',
47 'EM', 'SUB', 'ESC', '[FGRU]S', 'SP', 'DEL') 47 'EM', 'SUB', 'ESC', '[FGRU]S', 'SP', 'DEL')
61 (r'\b(%s)(?!\')\b' % '|'.join(reserved), Keyword.Reserved), 61 (r'\b(%s)(?!\')\b' % '|'.join(reserved), Keyword.Reserved),
62 (r"'[^\\]'", String.Char), # this has to come before the TH quote 62 (r"'[^\\]'", String.Char), # this has to come before the TH quote
63 (r'^[_' + uni.Ll + r'][\w\']*', Name.Function), 63 (r'^[_' + uni.Ll + r'][\w\']*', Name.Function),
64 (r"'?[_" + uni.Ll + r"][\w']*", Name), 64 (r"'?[_" + uni.Ll + r"][\w']*", Name),
65 (r"('')?[" + uni.Lu + r"][\w\']*", Keyword.Type), 65 (r"('')?[" + uni.Lu + r"][\w\']*", Keyword.Type),
66 (r"(')[" + uni.Lu + r"][\w\']*", Keyword.Type),
67 (r"(')\[[^\]]*\]", Keyword.Type), # tuples and lists get special treatment in GHC
68 (r"(')\([^)]*\)", Keyword.Type), # ..
66 # Operators 69 # Operators
67 (r'\\(?![:!#$%&*+.\\/<=>?@^|~-]+)', Name.Function), # lambda operator 70 (r'\\(?![:!#$%&*+.\\/<=>?@^|~-]+)', Name.Function), # lambda operator
68 (r'(<-|::|->|=>|=)(?![:!#$%&*+.\\/<=>?@^|~-]+)', Operator.Word), # specials 71 (r'(<-|::|->|=>|=)(?![:!#$%&*+.\\/<=>?@^|~-]+)', Operator.Word), # specials
69 (r':[:!#$%&*+.\\/<=>?@^|~-]*', Keyword.Type), # Constructor operators 72 (r':[:!#$%&*+.\\/<=>?@^|~-]*', Keyword.Type), # Constructor operators
70 (r'[:!#$%&*+.\\/<=>?@^|~-]+', Operator), # Other operators 73 (r'[:!#$%&*+.\\/<=>?@^|~-]+', Operator), # Other operators
319 (r'[!{}]', Comment.Directive), 322 (r'[!{}]', Comment.Directive),
320 ], 323 ],
321 'module': [ 324 'module': [
322 (r'\{-', Comment.Multiline, 'comment'), 325 (r'\{-', Comment.Multiline, 'comment'),
323 (r'[a-zA-Z][\w.]*', Name, '#pop'), 326 (r'[a-zA-Z][\w.]*', Name, '#pop'),
324 (r'[^a-zA-Z]+', Text) 327 (r'[\W0-9_]+', Text)
325 ], 328 ],
326 'comment': HaskellLexer.tokens['comment'], 329 'comment': HaskellLexer.tokens['comment'],
327 'character': HaskellLexer.tokens['character'], 330 'character': HaskellLexer.tokens['character'],
328 'string': HaskellLexer.tokens['string'], 331 'string': HaskellLexer.tokens['string'],
329 'escape': HaskellLexer.tokens['escape'] 332 'escape': HaskellLexer.tokens['escape']

eric ide

mercurial