diff options
author | wsfulton <devnull@localhost> | 2013-02-10 01:55:15 +0000 |
---|---|---|
committer | wsfulton <devnull@localhost> | 2013-02-10 01:55:15 +0000 |
commit | 0fcd1fd766562bd0499a3b3662877e592c8b454c (patch) | |
tree | 22324ba81a9d292ab5ad89ba4194ea2131e3aa63 | |
parent | 054c464c70c115f476608a51bb0b4a931d1fa400 (diff) | |
download | pygments-0fcd1fd766562bd0499a3b3662877e592c8b454c.tar.gz |
Add support for SWIG - http://www.swig.org. SWIG is an extension to C++ hence the implementation is derived from CppLexer with additions to identify SWIG's special variables, such as _type, and the SWIG directives which begin with %.
-rw-r--r-- | pygments/lexers/_mapping.py | 1 | ||||
-rw-r--r-- | pygments/lexers/compiled.py | 23 |
2 files changed, 23 insertions, 1 deletions
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index 53e09176..093bf7b2 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -269,6 +269,7 @@ LEXERS = { 'SquidConfLexer': ('pygments.lexers.text', 'SquidConf', ('squidconf', 'squid.conf', 'squid'), ('squid.conf',), ('text/x-squidconf',)), 'SspLexer': ('pygments.lexers.templates', 'Scalate Server Page', ('ssp',), ('*.ssp',), ('application/x-ssp',)), 'StanLexer': ('pygments.lexers.math', 'Stan', ('stan',), ('*.stan',), ()), + 'SwigLexer': ('pygments.lexers.compiled', 'SWIG', ('swig',), ('*.swg', '*.i'), ('text/x-c++hdr', 'text/x-c++src')), 'SystemVerilogLexer': ('pygments.lexers.hdl', 'systemverilog', ('systemverilog', 'sv'), ('*.sv', '*.svh'), ('text/x-systemverilog',)), 'TclLexer': ('pygments.lexers.agile', 'Tcl', ('tcl',), ('*.tcl',), ('text/x-tcl', 'text/x-script.tcl', 'application/x-tcl')), 'TcshLexer': ('pygments.lexers.shell', 'Tcsh', ('tcsh', 'csh'), ('*.tcsh', '*.csh'), ('application/x-csh',)), diff --git a/pygments/lexers/compiled.py b/pygments/lexers/compiled.py index 7513a4e1..14b2f7c7 100644 --- a/pygments/lexers/compiled.py +++ b/pygments/lexers/compiled.py @@ -29,7 +29,7 @@ __all__ = ['CLexer', 'CppLexer', 'DLexer', 'DelphiLexer', 'ECLexer', 'DylanLexer 'FelixLexer', 'AdaLexer', 'Modula2Lexer', 'BlitzMaxLexer', 'NimrodLexer', 'FantomLexer', 'RustLexer', 'CudaLexer', 'MonkeyLexer', 'DylanLidLexer', 'DylanConsoleLexer', 'CobolLexer', - 'CobolFreeformatLexer', 'LogosLexer'] + 'SwigLexer', 'CobolFreeformatLexer', 'LogosLexer'] class CFamilyLexer(RegexLexer): @@ -231,6 +231,27 @@ class CppLexer(CFamilyLexer): return 0.1 +class SwigLexer(CppLexer): + """ + For `SWIG <http://www.swig.org/>`_ source code. + """ + name = 'SWIG' + aliases = ['swig'] + filenames = ['*.swg', '*.i'] + mimetypes = [] + priority = 0.1 + + tokens = { + 'statements': [ + (r'(%[a-z_]+)\b', Name.Tag), + ('[$][*]*[&]?[a-zA-Z0-9_]+', Name), + inherit, + ], + } + def analyse_text(text): + return 0.1 + + class ECLexer(CLexer): """ For eC source code with preprocessor directives. |