blob: 5459915c01356488a94b7ea4f2b5e164de6f4989 [file] [log] [blame]
Dominique Pelléacb91d32023-09-01 23:10:26 +02001" Vim syntax file
2" Language: Zserio
3" Maintainer: Dominique Pellé <dominique.pelle@gmail.com>
4" Last Change: 2023 Jun 18
5"
6" Zserio is a serialization schema language for modeling binary
7" data types, bitstreams or file formats. Based on the zserio
8" language it is possible to automatically generate encoders and
9" decoders for a given schema in various target languages
10" (e.g. Java, C++, Python).
11"
12" Zserio is an evolution of the DataScript language.
13"
14" For more information, see:
15" - http://zserio.org/
16" - https://github.com/ndsev/zserio
17
18" quit when a syntax file was already loaded
19if exists("b:current_syntax")
20 finish
21endif
22
23let s:keepcpo= &cpo
24set cpo&vim
25
26syn case match
27
28syn keyword zserioPackage import package zserio_compatibility_version
29syn keyword zserioType bit bool string
30syn keyword zserioType int int8 int16 int32 int64
31syn keyword zserioType uint8 uint16 uint32 uint64
32syn keyword zserioType float16 float32 float64
33syn keyword zserioType varint varint16 varint32 varint64
34syn keyword zserioType varuint varsize varuint16 varuint32 varuint64
35syn keyword zserioAlign align
36syn keyword zserioLabel case default
37syn keyword zserioConditional if condition
38syn keyword zserioBoolean true false
39syn keyword zserioCompound struct union choice on enum bitmask subtype
40syn keyword zserioKeyword function return
41syn keyword zserioOperator lengthof valueof instanceof numbits isset
42syn keyword zserioRpc service pubsub topic publish subscribe
43syn keyword zserioRule rule_group rule
44syn keyword zserioStorageClass const implicit packed instantiate
45syn keyword zserioTodo contained TODO FIXME XXX
46syn keyword zserioSql sql sql_table sql_database sql_virtual sql_without_rowid
47syn keyword zserioSql explicit using
48
49" zserioCommentGroup allows adding matches for special things in comments.
50syn cluster zserioCommentGroup contains=zserioTodo
51
52syn match zserioOffset display "^\s*[a-zA-Z_:\.][a-zA-Z0-9_:\.]*\s*:"
53
54syn match zserioNumber display "\<\d\+\>"
55syn match zserioNumberHex display "\<0[xX]\x\+\>"
56syn match zserioNumberBin display "\<[01]\+[bB]\>" contains=zserioBinaryB
57syn match zserioBinaryB display contained "[bB]\>"
58syn match zserioOctal display "\<0\o\+\>" contains=zserioOctalZero
59syn match zserioOctalZero display contained "\<0"
60
61syn match zserioOctalError display "\<0\o*[89]\d*\>"
62
63syn match zserioCommentError display "\*/"
64syn match zserioCommentStartError display "/\*"me=e-1 contained
65
66syn region zserioCommentL
67 \ start="//" skip="\\$" end="$" keepend
68 \ contains=@zserioCommentGroup,@Spell
69syn region zserioComment
70 \ matchgroup=zserioCommentStart start="/\*" end="\*/"
71 \ contains=@zserioCommentGroup,zserioCommentStartError,@Spell extend
72
73syn region zserioString
74 \ start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=@Spell
75
76syn sync ccomment zserioComment
77
78" Define the default highlighting.
79hi def link zserioType Type
80hi def link zserioEndian StorageClass
81hi def link zserioStorageClass StorageClass
82hi def link zserioAlign Label
83hi def link zserioLabel Label
84hi def link zserioOffset Label
85hi def link zserioSql PreProc
86hi def link zserioCompound Structure
87hi def link zserioConditional Conditional
88hi def link zserioBoolean Boolean
89hi def link zserioKeyword Statement
90hi def link zserioRpc Keyword
91hi def link zserioRule Keyword
92hi def link zserioString String
93hi def link zserioNumber Number
94hi def link zserioNumberBin Number
95hi def link zserioBinaryB Special
96hi def link zserioOctal Number
97hi def link zserioOctalZero Special
98hi def link zserioOctalError Error
99hi def link zserioNumberHex Number
100hi def link zserioTodo Todo
101hi def link zserioOperator Operator
102hi def link zserioPackage Include
103hi def link zserioCommentError Error
104hi def link zserioCommentStartError Error
105hi def link zserioCommentStart zserioComment
106hi def link zserioCommentL zserioComment
107hi def link zserioComment Comment
108
109let b:current_syntax = "zserio"
110
111let &cpo = s:keepcpo
112unlet s:keepcpo