Created
December 23, 2008 20:26
-
-
Save ngerakines/39440 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PBLexer(RegexLexer): | |
""" | |
A simple Protocol Buffer lexer useful for parsing .proto files. | |
Contributed by Nick Gerakines <[email protected]>. | |
""" | |
name = 'ProtocolBuffers' | |
aliases = ['pb'] | |
filenames = ['*.proto'] | |
mimetypes = ['text/pb'] | |
tokens = { | |
'root': [ | |
(r'(message)(\s+)(\w+)', bygroups(Keyword.Reserved, Text.Whitespace, Name.Class)), | |
(r'(required|optional|repeated)', Keyword.Reserved), | |
(r'(string|int32)', Keyword.Type), | |
(r'({|})', Punctuation), | |
(r'([^ ]*)(\s+)(=)(\s+)(\d+);', bygroups(Name.Label, Text.Whitespace, Punctuation, Text.Whitespace, Number.Integer)), | |
(r'=', Operator), | |
(r';', Operator), | |
(r'//.*?$', Comment), | |
(r'[0-9]+', Number.Integer), | |
(r'\s+', Text.Whitespace), | |
], | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment