diff options
author | raichoo <raichoo@googlemail.com> | 2013-06-15 02:16:01 +0200 |
---|---|---|
committer | raichoo <raichoo@googlemail.com> | 2013-06-15 02:16:01 +0200 |
commit | d84d7e46cd2723fff1d8b41c28c5f5845b1491d2 (patch) | |
tree | 031bf02f50d3e9baefd29f541fc06242d3411926 | |
parent | 5a0f3745fc46db4bee8b6113167ef625708f1c42 (diff) | |
download | pygments-d84d7e46cd2723fff1d8b41c28c5f5845b1491d2.tar.gz |
Idris lexer: added lexer for literate Idris
-rw-r--r-- | pygments/lexers/_mapping.py | 1 | ||||
-rw-r--r-- | pygments/lexers/functional.py | 30 |
2 files changed, 29 insertions, 2 deletions
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index 481ec1d4..1cb87726 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -167,6 +167,7 @@ LEXERS = { 'LighttpdConfLexer': ('pygments.lexers.text', 'Lighttpd configuration file', ('lighty', 'lighttpd'), (), ('text/x-lighttpd-conf',)), 'LiterateAgdaLexer': ('pygments.lexers.functional', 'Literate Agda', ('lagda', 'literate-agda'), ('*.lagda',), ('text/x-literate-agda',)), 'LiterateHaskellLexer': ('pygments.lexers.functional', 'Literate Haskell', ('lhs', 'literate-haskell', 'lhaskell'), ('*.lhs',), ('text/x-literate-haskell',)), + 'LiterateIdrisLexer': ('pygments.lexers.functional', 'Literate Idris', ('lidr', 'literate-idris', 'lidris'), ('*.lidr',), ('text/x-literate-idris',)), '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',)), diff --git a/pygments/lexers/functional.py b/pygments/lexers/functional.py index ca791a74..eea3e883 100644 --- a/pygments/lexers/functional.py +++ b/pygments/lexers/functional.py @@ -19,7 +19,8 @@ __all__ = ['RacketLexer', 'SchemeLexer', 'CommonLispLexer', 'HaskellLexer', 'AgdaLexer', 'LiterateHaskellLexer', 'LiterateAgdaLexer', 'SMLLexer', 'OcamlLexer', 'ErlangLexer', 'ErlangShellLexer', 'OpaLexer', 'CoqLexer', 'NewLispLexer', 'ElixirLexer', - 'ElixirConsoleLexer', 'KokaLexer', 'IdrisLexer'] + 'ElixirConsoleLexer', 'KokaLexer', 'IdrisLexer', + 'LiterateIdrisLexer'] line_re = re.compile('.*?\n') @@ -1016,6 +1017,7 @@ class HaskellLexer(RegexLexer): ], } + class IdrisLexer(RegexLexer): """ A lexer for the dependently typed programming language Idris. @@ -1120,10 +1122,11 @@ class IdrisLexer(RegexLexer): (r'o[0-7]+', String.Escape, '#pop'), (r'x[\da-fA-F]+', String.Escape, '#pop'), (r'\d+', String.Escape, '#pop'), - (r'\s+\\', String.Escape, '#pop'), + (r'\s+\\', String.Escape, '#pop') ], } + class AgdaLexer(RegexLexer): """ For the `Agda <http://wiki.portal.chalmers.se/agda/pmwiki.php>`_ @@ -1280,6 +1283,29 @@ class LiterateHaskellLexer(LiterateLexer): LiterateLexer.__init__(self, hslexer, **options) +class LiterateIdrisLexer(LiterateLexer): + """ + For Literate Idris (Bird-style or LaTeX) source. + + Additional options accepted: + + `litstyle` + If given, must be ``"bird"`` or ``"latex"``. If not given, the style + is autodetected: if the first non-whitespace character in the source + is a backslash or percent character, LaTeX is assumed, else Bird. + + *New in Pygments 1.6.* + """ + name = 'Literate Idris' + aliases = ['lidr', 'literate-idris', 'lidris'] + filenames = ['*.lidr'] + mimetypes = ['text/x-literate-idris'] + + def __init__(self, **options): + hslexer = IdrisLexer(**options) + LiterateLexer.__init__(self, hslexer, **options) + + class LiterateAgdaLexer(LiterateLexer): """ For Literate Agda source. |