summaryrefslogtreecommitdiff
path: root/pygments/lexers/compiled.py
diff options
context:
space:
mode:
authorTim Hatch <tim@timhatch.com>2014-06-07 23:49:52 -0700
committerTim Hatch <tim@timhatch.com>2014-06-07 23:49:52 -0700
commit2f1c724903db081f1d6941d366ca95070049e94b (patch)
tree3f43531b55424c456c977fb809f773aec36dace0 /pygments/lexers/compiled.py
parent712d327c39efd6109d6919657e21ae5cd1a15414 (diff)
parent68c8011b8980c91a74f4625a96fa0fa946fb7b67 (diff)
downloadpygments-2f1c724903db081f1d6941d366ca95070049e94b.tar.gz
Merged in megajoule/pygments-main (pull request #372)
Update ElixirLexer and ElixirConsoleLexer
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 46990510..25c7a4d8 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']
+ 'Inform6TemplateLexer', 'MqlLexer', 'SwiftLexer']
class CFamilyLexer(RegexLexer):
@@ -5149,3 +5149,44 @@ class MqlLexer(CppLexer):
inherit,
],
}
+
+class SwiftLexer(ObjectiveCLexer):
+ """
+ For `Swift <https://developer.apple.com/swift/>`_ source.
+ """
+ name = 'Swift'
+ filenames = ['*.swift']
+ aliases = ['swift']
+ mimetypes = ['text/x-swift']
+
+ keywords_decl = ['class', 'deinit', 'enum', 'extension', 'func', 'import',
+ 'init', 'let', 'protocol', 'static', 'struct', 'subscript',
+ 'typealias', 'var']
+ keywords_stmt = ['break', 'case', 'continue', 'default', 'do', 'else',
+ 'fallthrough', 'if', 'in', 'for', 'return', 'switch',
+ 'where', 'while']
+ keywords_type = ['as', 'dynamicType', 'is', 'new', 'super', 'self', 'Self',
+ 'Type', '__COLUMN__', '__FILE__', '__FUNCTION__',
+ '__LINE__']
+ keywords_resrv = ['associativity', 'didSet', 'get', 'infix', 'inout', 'left',
+ 'mutating', 'none', 'nonmutating', 'operator', 'override',
+ 'postfix', 'precedence', 'prefix', 'right', 'set',
+ 'unowned', 'unowned(safe)', 'unowned(unsafe)', 'weak',
+ 'willSet']
+ operators = ['->']
+
+ def get_tokens_unprocessed(self, text):
+ for index, token, value in \
+ ObjectiveCLexer.get_tokens_unprocessed(self, text):
+ if token is Name:
+ if value in self.keywords_decl:
+ token = Keyword
+ elif value in self.keywords_stmt:
+ token = Keyword
+ elif value in self.keywords_type:
+ token = Keyword.Type
+ elif value in self.keywords_resrv:
+ token = Keyword.Reserved
+ elif value in self.operators:
+ token = Operator
+ yield index, token, value