summaryrefslogtreecommitdiff
path: root/pygments/lexers/compiled.py
diff options
context:
space:
mode:
authorR4PaSs <devnull@localhost>2014-06-26 14:59:28 -0400
committerR4PaSs <devnull@localhost>2014-06-26 14:59:28 -0400
commit70394ab774f9e7d40c71d159aeeb04094c839773 (patch)
tree75ffd1b39c13354a30d5338c8d4da028f8643ef4 /pygments/lexers/compiled.py
parent2f1c724903db081f1d6941d366ca95070049e94b (diff)
downloadpygments-70394ab774f9e7d40c71d159aeeb04094c839773.tar.gz
Added Nit Lexer to Pygments
Diffstat (limited to 'pygments/lexers/compiled.py')
-rw-r--r--pygments/lexers/compiled.py43
1 files changed, 42 insertions, 1 deletions
diff --git a/pygments/lexers/compiled.py b/pygments/lexers/compiled.py
index 25c7a4d8..480e4a8f 100644
--- a/pygments/lexers/compiled.py
+++ b/pygments/lexers/compiled.py
@@ -32,7 +32,7 @@ __all__ = ['CLexer', 'CppLexer', 'DLexer', 'DelphiLexer', 'ECLexer',
'DylanLidLexer', 'DylanConsoleLexer', 'CobolLexer',
'CobolFreeformatLexer', 'LogosLexer', 'ClayLexer', 'PikeLexer',
'ChapelLexer', 'EiffelLexer', 'Inform6Lexer', 'Inform7Lexer',
- 'Inform6TemplateLexer', 'MqlLexer', 'SwiftLexer']
+ 'Inform6TemplateLexer', 'MqlLexer', 'SwiftLexer', 'NitLexer']
class CFamilyLexer(RegexLexer):
@@ -5190,3 +5190,44 @@ class SwiftLexer(ObjectiveCLexer):
elif value in self.operators:
token = Operator
yield index, token, value
+
+class NitLexer(RegexLexer):
+ """
+ For `nit <http://nitlanguage.org>`_ source.
+ """
+
+ name = 'Nit'
+ aliases = ['nit']
+ filenames = ['*.nit']
+ tokens = {
+ 'root': [
+ (r'#.*?$', Comment.Single),
+ (r'(package|module|import|class|abstract|interface|'
+ 'universal|enum|end|fun|type|init|redef|isa|do|'
+ 'readable|writable|var|intern|extern|public|protected|'
+ 'private|intrude|if|then|else|while|loop|for|in|and|'
+ 'or|not|implies|return|continue|break|abort|assert|'
+ 'new|is|once|super|self|true|false|nullable|null|as|'
+ 'isset|label|__debug__)(?=( |\n|\t|\r|\())', Keyword),
+ (r'[A-Z][A-Za-z0-9_]*', Name.Class),
+ (r'"""(([^\'\\]|\\.)|\\r|\\n)*(({{?)?(""?{{?)*""""*)', String), #Simple long string
+ (r'\'\'\'(((\\.|[^\'\\])|\\r|\\n)|\'((\\.|[^\'\\])|\\r|\\n)|\'\'((\\.|[^\'\\])|\\r|\\n))*\'\'\'', String), #Simple long string alt
+ (r'"""(([^\'\\]|\\.)|\\r|\\n)*((""?)?({{?""?)*{{{{*)', String), #Start long string
+ (r'}}}(((\\.|[^\'\\])|\\r|\\n))*(""?)?({{?""?)*{{{{*', String), #Mid long string
+ (r'}}}(((\\.|[^\'\\])|\\r|\\n))*({{?)?(""?{{?)*""""*', String), #End long string
+ (r'"(\\.|([^"}{\\]))*"', String), #Simple String
+ (r'"(\\.|([^"}{\\]))*{', String), #Start string
+ (r'}(\\.|([^"}{\\]))*{', String), #Mid String
+ (r'}(\\.|([^"}{\\]))*"', String), #End String
+ (r'(\'[^\'\\]\')|(\'\\.\')', String.Char),
+ (r'[0-9]+', Number.Integer),
+ (r'[0-9]*.[0-9]+', Number.Float),
+ (r'0(x|X)[0-9A-Fa-f]+', Number.Hex),
+ (r'[a-z][A-Za-z0-9_]*', Name),
+ (r'_[A-Za-z0-9_]+', Name.Variable.Instance),
+ (r'==|!=|<==>|>=|>>|>|<=|<<|<|\+|-|=|/|\*|%|\+=|-=|!|@', Operator),
+ (r'\(|\)|\[|\]|,|\.\.\.|\.\.|\.|::|:', Punctuation),
+ (r'`{[^`]*`}', Text), # Extern blocks won't be Lexed by Nit
+ ('(\r|\n| |\t)+', Text)]
+ }
+