3 pygments.lexers.elm |
3 pygments.lexers.elm |
4 ~~~~~~~~~~~~~~~~~~~ |
4 ~~~~~~~~~~~~~~~~~~~ |
5 |
5 |
6 Lexer for the Elm programming language. |
6 Lexer for the Elm programming language. |
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 from pygments.lexer import RegexLexer, words, include |
12 from pygments.lexer import RegexLexer, words, include |
13 from pygments.token import Comment, Keyword, Name, Number, Punctuation, String, Text |
13 from pygments.token import Comment, Keyword, Name, Number, Punctuation, String, Text |
38 ) |
38 ) |
39 |
39 |
40 reservedWords = words(( |
40 reservedWords = words(( |
41 'alias', 'as', 'case', 'else', 'if', 'import', 'in', |
41 'alias', 'as', 'case', 'else', 'if', 'import', 'in', |
42 'let', 'module', 'of', 'port', 'then', 'type', 'where', |
42 'let', 'module', 'of', 'port', 'then', 'type', 'where', |
43 ), suffix=r'\b') |
43 ), suffix=r'\b') |
44 |
44 |
45 tokens = { |
45 tokens = { |
46 'root': [ |
46 'root': [ |
47 |
47 |
48 # Comments |
48 # Comments |
66 |
66 |
67 # Keywords |
67 # Keywords |
68 (reservedWords, Keyword.Reserved), |
68 (reservedWords, Keyword.Reserved), |
69 |
69 |
70 # Types |
70 # Types |
71 (r'[A-Z]\w*', Keyword.Type), |
71 (r'[A-Z][a-zA-Z0-9_]*', Keyword.Type), |
72 |
72 |
73 # Main |
73 # Main |
74 (specialName, Keyword.Reserved), |
74 (specialName, Keyword.Reserved), |
75 |
75 |
76 # Prefix Operators |
76 # Prefix Operators |