Guest User

Untitled

a guest
Feb 21st, 2018
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. class PBLexer(RegexLexer):
  2. """
  3. A simple Protocol Buffer lexer useful for parsing .proto files.
  4. Contributed by Nick Gerakines <nick@gerakines.net>.
  5. """
  6. name = 'ProtocolBuffers'
  7. aliases = ['pb']
  8. filenames = ['*.proto']
  9. mimetypes = ['text/pb']
  10.  
  11. tokens = {
  12. 'root': [
  13. (r'(message)(\s+)(\w+)', bygroups(Keyword.Reserved, Text.Whitespace, Name.Class)),
  14. (r'(required|optional|repeated)', Keyword.Reserved),
  15. (r'(string|int32)', Keyword.Type),
  16. (r'({|})', Punctuation),
  17. (r'([^ ]*)(\s+)(=)(\s+)(\d+);', bygroups(Name.Label, Text.Whitespace, Punctuation, Text.Whitespace, Number.Integer)),
  18. (r'=', Operator),
  19. (r';', Operator),
  20. (r'//.*?$', Comment),
  21. (r'[0-9]+', Number.Integer),
  22. (r'\s+', Text.Whitespace),
  23. ],
  24. }
Add Comment
Please, Sign In to add comment