summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pygments/lexers/_mapping.py1
-rw-r--r--pygments/lexers/other.py58
2 files changed, 57 insertions, 2 deletions
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py
index b288c60f..9e922f13 100644
--- a/pygments/lexers/_mapping.py
+++ b/pygments/lexers/_mapping.py
@@ -156,6 +156,7 @@ LEXERS = {
'PovrayLexer': ('pygments.lexers.other', 'POVRay', ('pov',), ('*.pov', '*.inc'), ('text/x-povray',)),
'PrologLexer': ('pygments.lexers.compiled', 'Prolog', ('prolog',), ('*.prolog', '*.pro', '*.pl'), ('text/x-prolog',)),
'PropertiesLexer': ('pygments.lexers.text', 'Properties', ('properties',), ('*.properties',), ('text/x-java-properties',)),
+ 'ProtoBufLexer': ('pygments.lexers.other', 'Protocol Buffer', ('protobuf',), ('*.proto',), ()),
'Python3Lexer': ('pygments.lexers.agile', 'Python 3', ('python3', 'py3'), (), ('text/x-python3', 'application/x-python3')),
'Python3TracebackLexer': ('pygments.lexers.agile', 'Python 3.0 Traceback', ('py3tb',), ('*.py3tb',), ('text/x-python3-traceback',)),
'PythonConsoleLexer': ('pygments.lexers.agile', 'Python console session', ('pycon',), (), ('text/x-python-doctest',)),
diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py
index e8aa793a..ab355447 100644
--- a/pygments/lexers/other.py
+++ b/pygments/lexers/other.py
@@ -26,7 +26,7 @@ __all__ = ['SqlLexer', 'MySqlLexer', 'SqliteConsoleLexer', 'BrainfuckLexer',
'BashSessionLexer', 'ModelicaLexer', 'RebolLexer', 'ABAPLexer',
'NewspeakLexer', 'GherkinLexer', 'AsymptoteLexer',
'PostScriptLexer', 'AutohotkeyLexer', 'GoodDataCLLexer',
- 'MaqlLexer']
+ 'MaqlLexer', 'ProtoBufLexer']
line_re = re.compile('.*?\n')
@@ -2663,9 +2663,10 @@ class MaqlLexer(RegexLexer):
(r'\\[tnrfbae"\\]', String.Escape),
(r'"', Literal.String, '#pop'),
(r'[^\\"]+', Literal.String)
- ]
+ ],
}
+
class GoodDataCLLexer(RegexLexer):
"""
Lexer for `GoodData-CL <http://github.com/gooddata/GoodData-CL/raw/master/cli/src/main/resources/com/gooddata/processor/COMMANDS.txt>`_
@@ -2709,3 +2710,56 @@ class GoodDataCLLexer(RegexLexer):
(r'[^\\"]+', Literal.String)
]
}
+
+
+class ProtoBufLexer(RegexLexer):
+ """
+ Lexer for `Protocol Buffer <http://code.google.com/p/protobuf/>`_
+ definition files.
+
+ *New in Pygments 1.4.*
+ """
+
+ name = 'Protocol Buffer'
+ aliases = ['protobuf']
+ filenames = ['*.proto']
+
+ tokens = {
+ 'root': [
+ (r'[ \t]+', Text),
+ (r'[,;{}\[\]\(\)]', Punctuation),
+ (r'/(\\\n)?/(\n|(.|\n)*?[^\\]\n)', Comment.Single),
+ (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
+ (r'\b(import|option|optional|required|repeated|default|packed|'
+ r'ctype|extensions|to|max|rpc|returns)\b', Keyword),
+ (r'(int32|int64|uint32|uint64|sint32|sint64|'
+ r'fixed32|fixed64|sfixed32|sfixed64|'
+ r'float|double|bool|string|bytes)\b', Keyword.Type),
+ (r'(true|false)\b', Keyword.Constant),
+ (r'(package)(\s+)', bygroups(Keyword.Namespace, Text), 'package'),
+ (r'(message|extend)(\s+)',
+ bygroups(Keyword.Declaration, Text), 'message'),
+ (r'(enum|group|service)(\s+)',
+ bygroups(Keyword.Declaration, Text), 'type'),
+ (r'\".*\"', String),
+ (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*', Number.Float),
+ (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
+ (r'(\-?(inf|nan))', Number.Float),
+ (r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex),
+ (r'0[0-7]+[LlUu]*', Number.Oct),
+ (r'\d+[LlUu]*', Number.Integer),
+ (r'[+-=]', Operator),
+ (r'([a-zA-Z_][a-zA-Z0-9_\.]*)([ \t]*)(=)',
+ bygroups(Name.Attribute, Text, Operator)),
+ ('[a-zA-Z_][a-zA-Z0-9_\.]*', Name),
+ ],
+ 'package': [
+ (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Namespace, '#pop')
+ ],
+ 'message': [
+ (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
+ ],
+ 'type': [
+ (r'[a-zA-Z_][a-zA-Z0-9_]*', Name, '#pop')
+ ],
+ }