ThirdParty/Pygments/pygments/lexers/nit.py

changeset 4172
4f20dba37ab6
child 4697
c2e9bf425554
equal deleted inserted replaced
4170:8bc578136279 4172:4f20dba37ab6
1 # -*- coding: utf-8 -*-
2 """
3 pygments.lexers.nit
4 ~~~~~~~~~~~~~~~~~~~
5
6 Lexer for the Nit language.
7
8 :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details.
10 """
11
12 from pygments.lexer import RegexLexer, words
13 from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
14 Number, Punctuation
15
16 __all__ = ['NitLexer']
17
18
19 class NitLexer(RegexLexer):
20 """
21 For `nit <http://nitlanguage.org>`_ source.
22
23 .. versionadded:: 2.0
24 """
25
26 name = 'Nit'
27 aliases = ['nit']
28 filenames = ['*.nit']
29 tokens = {
30 'root': [
31 (r'#.*?$', Comment.Single),
32 (words((
33 'package', 'module', 'import', 'class', 'abstract', 'interface',
34 'universal', 'enum', 'end', 'fun', 'type', 'init', 'redef',
35 'isa', 'do', 'readable', 'writable', 'var', 'intern', 'extern',
36 'public', 'protected', 'private', 'intrude', 'if', 'then',
37 'else', 'while', 'loop', 'for', 'in', 'and', 'or', 'not',
38 'implies', 'return', 'continue', 'break', 'abort', 'assert',
39 'new', 'is', 'once', 'super', 'self', 'true', 'false', 'nullable',
40 'null', 'as', 'isset', 'label', '__debug__'), suffix=r'(?=[\r\n\t( ])'),
41 Keyword),
42 (r'[A-Z]\w*', Name.Class),
43 (r'"""(([^\'\\]|\\.)|\\r|\\n)*((\{\{?)?(""?\{\{?)*""""*)', String), # Simple long string
44 (r'\'\'\'(((\\.|[^\'\\])|\\r|\\n)|\'((\\.|[^\'\\])|\\r|\\n)|'
45 r'\'\'((\\.|[^\'\\])|\\r|\\n))*\'\'\'', String), # Simple long string alt
46 (r'"""(([^\'\\]|\\.)|\\r|\\n)*((""?)?(\{\{?""?)*\{\{\{\{*)', String), # Start long string
47 (r'\}\}\}(((\\.|[^\'\\])|\\r|\\n))*(""?)?(\{\{?""?)*\{\{\{\{*', String), # Mid long string
48 (r'\}\}\}(((\\.|[^\'\\])|\\r|\\n))*(\{\{?)?(""?\{\{?)*""""*', String), # End long string
49 (r'"(\\.|([^"}{\\]))*"', String), # Simple String
50 (r'"(\\.|([^"}{\\]))*\{', String), # Start string
51 (r'\}(\\.|([^"}{\\]))*\{', String), # Mid String
52 (r'\}(\\.|([^"}{\\]))*"', String), # End String
53 (r'(\'[^\'\\]\')|(\'\\.\')', String.Char),
54 (r'[0-9]+', Number.Integer),
55 (r'[0-9]*.[0-9]+', Number.Float),
56 (r'0(x|X)[0-9A-Fa-f]+', Number.Hex),
57 (r'[a-z]\w*', Name),
58 (r'_\w+', Name.Variable.Instance),
59 (r'==|!=|<==>|>=|>>|>|<=|<<|<|\+|-|=|/|\*|%|\+=|-=|!|@', Operator),
60 (r'\(|\)|\[|\]|,|\.\.\.|\.\.|\.|::|:', Punctuation),
61 (r'`\{[^`]*`\}', Text), # Extern blocks won't be Lexed by Nit
62 (r'[\r\n\t ]+', Text),
63 ],
64 }

eric ide

mercurial