diff options
author | Hiroaki Itoh <xwhhsprings@gmail.com> | 2015-11-10 12:08:37 +0900 |
---|---|---|
committer | Hiroaki Itoh <xwhhsprings@gmail.com> | 2015-11-10 12:08:37 +0900 |
commit | 732ced856926f5413c461e5a03c13851839d4c4b (patch) | |
tree | 017ae53b2886096e72b1622e056a33b0a39c3a8f /pygments | |
parent | f3c27772939937acbce4fc5fd4fd589ebccfacbe (diff) | |
parent | d9fcb8e2e38d86a5bc4ebf056f34c423122e655e (diff) | |
download | pygments-732ced856926f5413c461e5a03c13851839d4c4b.tar.gz |
Merged default into add-abnf-lexer
Diffstat (limited to 'pygments')
-rw-r--r-- | pygments/lexers/_mapping.py | 2 | ||||
-rw-r--r-- | pygments/lexers/configs.py | 98 |
2 files changed, 98 insertions, 2 deletions
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index 2352ab10..4bcd3460 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -377,6 +377,8 @@ LEXERS = { 'TcshLexer': ('pygments.lexers.shell', 'Tcsh', ('tcsh', 'csh'), ('*.tcsh', '*.csh'), ('application/x-csh',)), 'TcshSessionLexer': ('pygments.lexers.shell', 'Tcsh Session', ('tcshcon',), (), ()), 'TeaTemplateLexer': ('pygments.lexers.templates', 'Tea', ('tea',), ('*.tea',), ('text/x-tea',)), + 'TermcapLexer': ('pygments.lexers.configs', 'Termcap', ('termcap',), ('termcap', 'termcap.src'), ()), + 'TerminfoLexer': ('pygments.lexers.configs', 'Terminfo', ('terminfo',), ('terminfo', 'terminfo.src'), ()), 'TerraformLexer': ('pygments.lexers.configs', 'Terraform', ('terraform', 'tf'), ('*.tf',), ('application/x-tf', 'application/x-terraform')), 'TexLexer': ('pygments.lexers.markup', 'TeX', ('tex', 'latex'), ('*.tex', '*.aux', '*.toc'), ('text/x-tex', 'text/x-latex')), 'TextLexer': ('pygments.lexers.special', 'Text only', ('text',), ('*.txt',), ('text/plain',)), diff --git a/pygments/lexers/configs.py b/pygments/lexers/configs.py index f5a67bc4..f6f280ee 100644 --- a/pygments/lexers/configs.py +++ b/pygments/lexers/configs.py @@ -13,13 +13,13 @@ import re from pygments.lexer import RegexLexer, default, words, bygroups, include, using from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ - Number, Punctuation, Whitespace + Number, Punctuation, Whitespace, Literal from pygments.lexers.shell import BashLexer __all__ = ['IniLexer', 'RegeditLexer', 'PropertiesLexer', 'KconfigLexer', 'Cfengine3Lexer', 'ApacheConfLexer', 'SquidConfLexer', 'NginxConfLexer', 'LighttpdConfLexer', 'DockerLexer', - 'TerraformLexer'] + 'TerraformLexer', 'TermcapLexer', 'TerminfoLexer'] class IniLexer(RegexLexer): @@ -617,3 +617,97 @@ class TerraformLexer(RegexLexer): (r'\\\n', Text), ], } + + +class TermcapLexer(RegexLexer): + """ + Lexer for termcap database source. + + This is very simple and minimal. + + .. versionadded:: 2.1 + """ + name = 'Termcap' + aliases = ['termcap',] + + filenames = ['termcap', 'termcap.src',] + mimetypes = [] + + # NOTE: + # * multiline with trailing backslash + # * separator is ':' + # * to embed colon as data, we must use \072 + # * space after separator is not allowed (mayve) + tokens = { + 'root': [ + (r'^#.*$', Comment), + (r'^[^\s#:\|]+', Name.Tag, 'names'), + ], + 'names': [ + (r'\n', Text, '#pop'), + (r':', Punctuation, 'defs'), + (r'\|', Punctuation), + (r'[^:\|]+', Name.Attribute), + ], + 'defs': [ + (r'\\\n[ \t]*', Text), + (r'\n[ \t]*', Text, '#pop:2'), + (r'(#)([0-9]+)', bygroups(Operator, Number)), + (r'=', Operator, 'data'), + (r':', Punctuation), + (r'[^\s:=#]+', Name.Class), + ], + 'data': [ + (r'\\072', Literal), + (r':', Punctuation, '#pop'), + (r'[^:\\]+', Literal), # for performance + (r'.', Literal), + ], + } + + +class TerminfoLexer(RegexLexer): + """ + Lexer for terminfo database source. + + This is very simple and minimal. + + .. versionadded:: 2.1 + """ + name = 'Terminfo' + aliases = ['terminfo',] + + filenames = ['terminfo', 'terminfo.src',] + mimetypes = [] + + # NOTE: + # * multiline with leading whitespace + # * separator is ',' + # * to embed comma as data, we can use \, + # * space after separator is allowed + tokens = { + 'root': [ + (r'^#.*$', Comment), + (r'^[^\s#,\|]+', Name.Tag, 'names'), + ], + 'names': [ + (r'\n', Text, '#pop'), + (r'(,)([ \t]*)', bygroups(Punctuation, Text), 'defs'), + (r'\|', Punctuation), + (r'[^,\|]+', Name.Attribute), + ], + 'defs': [ + (r'\n[ \t]+', Text), + (r'\n', Text, '#pop:2'), + (r'(#)([0-9]+)', bygroups(Operator, Number)), + (r'=', Operator, 'data'), + (r'(,)([ \t]*)', bygroups(Punctuation, Text)), + (r'[^\s,=#]+', Name.Class), + ], + 'data': [ + (r'\\[,\\]', Literal), + (r'(,)([ \t]*)', bygroups(Punctuation, Text), '#pop'), + (r'[^\\,]+', Literal), # for performance + (r'.', Literal), + ], + } |