57 lines
1.9 KiB
YAML
57 lines
1.9 KiB
YAML
%YAML 1.2
|
|
---
|
|
# NotesCraft's own Protocol Buffers grammar. Original work written for this project; not copied
|
|
# from any other grammar. Regexes stay linear: no nested quantifiers, so nothing backtracks far.
|
|
# Strings end at their line unless the language allows multi-line ones.
|
|
name: Protocol Buffers
|
|
file_extensions: [proto, protobuf]
|
|
scope: source.proto
|
|
|
|
contexts:
|
|
main:
|
|
- match: '/\*'
|
|
scope: punctuation.definition.comment.begin
|
|
push: block0
|
|
- match: '//.*'
|
|
scope: comment.line
|
|
- match: '"'
|
|
scope: punctuation.definition.string.begin
|
|
push: str-dq
|
|
- match: ''''
|
|
scope: punctuation.definition.string.begin
|
|
push: str-sq
|
|
- match: '\b(?:syntax|edition|package|import|option|message|enum|service|rpc|returns|stream|repeated|optional|required|oneof|map|reserved|extend|extensions|to|max|public|weak)\b'
|
|
scope: keyword.control
|
|
- match: '\b(?:true|false)\b'
|
|
scope: constant.language
|
|
- match: '\b(?:double|float|int32|int64|uint32|uint64|sint32|sint64|fixed32|fixed64|sfixed32|sfixed64|bool|string|bytes)\b'
|
|
scope: support.type
|
|
- match: '\b(?:0[xX][0-9a-fA-F_]+|0[bB][01_]+|\d[\d_]*(?:\.\d[\d_]*)?(?:[eE][+-]?\d+)?)\b'
|
|
scope: constant.numeric
|
|
- match: '\b[A-Z][A-Za-z0-9_]*\b'
|
|
scope: entity.name.type
|
|
- match: '[-+*/%=<>!&|^~?:]+'
|
|
scope: keyword.operator
|
|
block0:
|
|
- meta_scope: comment.block
|
|
- match: '\*/'
|
|
pop: true
|
|
str-dq:
|
|
- meta_scope: string.quoted.double
|
|
- match: '\\.'
|
|
scope: constant.character.escape
|
|
- match: '"'
|
|
scope: punctuation.definition.string.end
|
|
pop: true
|
|
- match: '(?=\n)'
|
|
pop: true
|
|
str-sq:
|
|
- meta_scope: string.quoted.single
|
|
- match: '\\.'
|
|
scope: constant.character.escape
|
|
- match: ''''
|
|
scope: punctuation.definition.string.end
|
|
pop: true
|
|
- match: '(?=\n)'
|
|
pop: true
|