diff options
author | Georg Brandl <georg@python.org> | 2013-01-10 22:06:46 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2013-01-10 22:06:46 +0100 |
commit | 77ba79b75a2660af2cfd8ae9a072b9d56ccd961d (patch) | |
tree | f0fb41a6fed23122ad5c9693b201e22c35cba3ab | |
parent | 00ebe18996d37459f6ea40c6966bbe0f09841ccc (diff) | |
parent | dab1c1d46465274ecd127c45591151bfdae142c6 (diff) | |
download | pygments-77ba79b75a2660af2cfd8ae9a072b9d56ccd961d.tar.gz |
merge heads
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | CHANGES | 9 | ||||
-rw-r--r-- | pygments/lexers/_mapping.py | 3 | ||||
-rw-r--r-- | pygments/lexers/compiled.py | 66 | ||||
-rw-r--r-- | tests/examplefiles/logos_example.xm | 28 |
5 files changed, 105 insertions, 2 deletions
@@ -53,6 +53,7 @@ Other contributors, listed alphabetically, are: * Varun Hiremath -- Debian control lexer * Doug Hogan -- Mscgen lexer * Ben Hollis -- Mason lexer +* Dustin Howett -- Logos lexer * Alastair Houghton -- Lexer inheritance facility * Tim Howard -- BlitzMax lexer * Ivan Inozemtsev -- Fantom lexer @@ -6,6 +6,15 @@ Issue numbers refer to the tracker at pull request numbers to the requests at <http://bitbucket.org/birkenfeld/pygments-main/pull-requests/merged>. +Version 1.6 +----------- +(in development) + +- Lexers added: + + * Logos (PR#150) + + Version 1.6rc1 -------------- (released Jan 9, 2013) diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index ec8ee818..f3b711f4 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -161,6 +161,7 @@ LEXERS = { 'LiterateHaskellLexer': ('pygments.lexers.functional', 'Literate Haskell', ('lhs', 'literate-haskell'), ('*.lhs',), ('text/x-literate-haskell',)), 'LiveScriptLexer': ('pygments.lexers.web', 'LiveScript', ('live-script', 'livescript'), ('*.ls',), ('text/livescript',)), 'LlvmLexer': ('pygments.lexers.asm', 'LLVM', ('llvm',), ('*.ll',), ('text/x-llvm',)), + 'LogosLexer': ('pygments.lexers.compiled', 'Logos', ('logos',), ('*.x', '*.xi', '*.xm', '*.xmi'), ('text/x-logos',)), 'LogtalkLexer': ('pygments.lexers.other', 'Logtalk', ('logtalk',), ('*.lgt',), ('text/x-logtalk',)), 'LuaLexer': ('pygments.lexers.agile', 'Lua', ('lua',), ('*.lua', '*.wlua'), ('text/x-lua', 'application/x-lua')), 'MOOCodeLexer': ('pygments.lexers.other', 'MOOCode', ('moocode',), ('*.moo',), ('text/x-moocode',)), @@ -207,7 +208,7 @@ LEXERS = { 'OpaLexer': ('pygments.lexers.functional', 'Opa', ('opa',), ('*.opa',), ('text/x-opa',)), 'OpenEdgeLexer': ('pygments.lexers.other', 'OpenEdge ABL', ('openedge', 'abl', 'progress'), ('*.p', '*.cls'), ('text/x-openedge', 'application/x-openedge')), 'PerlLexer': ('pygments.lexers.agile', 'Perl', ('perl', 'pl'), ('*.pl', '*.pm'), ('text/x-perl', 'application/x-perl')), - 'PhpLexer': ('pygments.lexers.web', 'PHP', ('php', 'php3', 'php4', 'php5'), ('*.php', '*.php[345]'), ('text/x-php',)), + 'PhpLexer': ('pygments.lexers.web', 'PHP', ('php', 'php3', 'php4', 'php5'), ('*.php', '*.php[345]', '*.inc'), ('text/x-php',)), 'PlPgsqlLexer': ('pygments.lexers.sql', 'PL/pgSQL', ('plpgsql',), (), ('text/x-plpgsql',)), 'PostScriptLexer': ('pygments.lexers.other', 'PostScript', ('postscript',), ('*.ps', '*.eps'), ('application/postscript',)), 'PostgresConsoleLexer': ('pygments.lexers.sql', 'PostgreSQL console (psql)', ('psql', 'postgresql-console', 'postgres-console'), (), ('text/x-postgresql-psql',)), diff --git a/pygments/lexers/compiled.py b/pygments/lexers/compiled.py index ef6a8551..0336b7e0 100644 --- a/pygments/lexers/compiled.py +++ b/pygments/lexers/compiled.py @@ -28,7 +28,7 @@ __all__ = ['CLexer', 'CppLexer', 'DLexer', 'DelphiLexer', 'ECLexer', 'DylanLexer 'PrologLexer', 'CythonLexer', 'ValaLexer', 'OocLexer', 'GoLexer', 'FelixLexer', 'AdaLexer', 'Modula2Lexer', 'BlitzMaxLexer', 'NimrodLexer', 'FantomLexer', 'RustLexer', 'CudaLexer', 'MonkeyLexer', - 'DylanLidLexer', 'CobolLexer', 'CobolFreeformatLexer'] + 'DylanLidLexer', 'CobolLexer', 'CobolFreeformatLexer', 'LogosLexer'] class CFamilyLexer(RegexLexer): @@ -3370,3 +3370,67 @@ class CobolFreeformatLexer(CobolLexer): (r'(\*>.*\n|^\w*\*.*$)', Comment), ], } + + +class LogosLexer(ObjectiveCppLexer): + """ + For Logos + Objective-C source code with preprocessor directives. + + *New in Pygments 1.6.* + """ + + name = 'Logos' + aliases = ['logos'] + filenames = ['*.x', '*.xi', '*.xm', '*.xmi'] + mimetypes = ['text/x-logos'] + priority = 0.25 + + tokens = { + 'statements': [ + (r'(%orig|%log)\b', Keyword), + (r'(%c)\b(\()(\s*)([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*)(\))', + bygroups(Keyword, Punctuation, Text, Name.Class, Text, Punctuation)), + (r'(%init)\b(\()', + bygroups(Keyword, Punctuation), 'logos_init_directive'), + (r'(%init)(?=\s*;)', bygroups(Keyword)), + (r'(%hook|%group)(\s+)([a-zA-Z$_][a-zA-Z0-9$_]+)', + bygroups(Keyword, Text, Name.Class), '#pop'), + (r'(%subclass)(\s+)', bygroups(Keyword, Text), + ('#pop', 'logos_classname')), + inherit, + ], + 'logos_init_directive' : [ + ('\s+', Text), + (',', Punctuation, ('logos_init_directive', '#pop')), + ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*)(=)(\s*)([^);]*)', + bygroups(Name.Class, Text, Punctuation, Text, Text)), + ('([a-zA-Z$_][a-zA-Z0-9$_]*)', Name.Class), + ('\)', Punctuation, '#pop'), + ], + 'logos_classname' : [ + ('([a-zA-Z$_][a-zA-Z0-9$_]*)(\s*:\s*)([a-zA-Z$_][a-zA-Z0-9$_]*)?', + bygroups(Name.Class, Text, Name.Class), '#pop'), + ('([a-zA-Z$_][a-zA-Z0-9$_]*)', Name.Class, '#pop') + ], + 'root': [ + (r'(%subclass)(\s+)', bygroups(Keyword, Text), + 'logos_classname'), + (r'(%hook|%group)(\s+)([a-zA-Z$_][a-zA-Z0-9$_]+)', + bygroups(Keyword, Text, Name.Class)), + (r'(%config)(\s*\(\s*)(\w+)(\s*=\s*)(.*?)(\s*\)\s*)', + bygroups(Keyword, Text, Name.Variable, Text, String, Text)), + (r'(%ctor)(\s*)({)', bygroups(Keyword, Text, Punctuation), + 'function'), + (r'(%new)(\s*)(\()(\s*.*?\s*)(\))', + bygroups(Keyword, Text, Keyword, String, Keyword)), + (r'(\s*)(%end)(\s*)', bygroups(Text, Keyword, Text)), + inherit, + ], + } + + _logos_keywords = re.compile(r'%(?:hook|ctor|init|c\()') + + def analyse_text(text): + if LogosLexer._logos_keywords.search(text): + return 1.0 + return 0 diff --git a/tests/examplefiles/logos_example.xm b/tests/examplefiles/logos_example.xm new file mode 100644 index 00000000..39753e23 --- /dev/null +++ b/tests/examplefiles/logos_example.xm @@ -0,0 +1,28 @@ +%hook ABC +- (id)a:(B)b { + %log; + return %orig(nil); +} +%end + +%subclass DEF: NSObject +- (id)init { + [%c(RuntimeAccessibleClass) alloc]; + return nil; +} +%end + +%group OptionalHooks +%hook ABC +- (void)release { + [self retain]; + %orig; +} +%end +%end + +%ctor { + %init; + if(OptionalCondition) + %init(OptionalHooks); +} |