1" Vim syntax file
2" Language:	DataScript
3" Maintainer:	Dominique Pelle <[email protected]>
4" Last Change:	2015 Jul 30
5"
6" DataScript is a formal language for modelling binary datatypes,
7" bitstreams or file formats. For more information, see:
8"
9" http://dstools.sourceforge.net/DataScriptLanguageOverview.html
10
11if version < 600
12  syntax clear
13elseif exists("b:current_syntax")
14  finish
15endif
16let s:keepcpo= &cpo
17set cpo&vim
18
19syn keyword dsPackage      import package
20syn keyword dsType         bit bool string
21syn keyword dsType         int int8 int16 int32 int64
22syn keyword dsType         uint8 uint16 uint32 uint64
23syn keyword dsType         varint16 varint32 varint64
24syn keyword dsType         varuint16 varuint32 varuint64
25syn keyword dsType         leint16 leint32 leint64
26syn keyword dsType         leuint16 leuint32 leuint64
27syn keyword dsEndian       little big
28syn keyword dsAlign        align
29syn keyword dsLabel        case default
30syn keyword dsConditional  if condition
31syn keyword dsBoolean      true false
32syn keyword dsCompound     union choice on enum bitmask subtype explicit
33syn keyword dsKeyword      function return
34syn keyword dsOperator     sizeof bitsizeof lengthof is sum forall in
35syn keyword dsStorageClass const
36syn keyword dsTodo         contained TODO FIXME XXX
37syn keyword dsSql          sql sql_table sql_database sql_pragma sql_index
38syn keyword dsSql          sql_integer sql_metadata sql_key sql_virtual
39syn keyword dsSql          using reference_key foreign_key to
40
41" dsCommentGroup allows adding matches for special things in comments.
42syn cluster dsCommentGroup  contains=dsTodo
43
44syn match   dsOffset        display "^\s*[a-zA-Z_:\.][a-zA-Z0-9_:\.]*\s*:"
45
46syn match   dsNumber        display "\<\d\+\>"
47syn match   dsNumberHex     display "\<0[xX]\x\+\>"
48syn match   dsNumberBin     display "\<[01]\+[bB]\>" contains=dsBinaryB
49syn match   dsBinaryB       display contained "[bB]\>"
50syn match   dsOctal         display "\<0\o\+\>" contains=dsOctalZero
51syn match   dsOctalZero     display contained "\<0"
52
53syn match   dsOctalError    display "\<0\o*[89]\d*\>"
54
55syn match   dsCommentError      display "\*/"
56syn match   dsCommentStartError display "/\*"me=e-1 contained
57
58syn region   dsCommentL
59  \ start="//" skip="\\$" end="$" keepend
60  \ contains=@dsCommentGroup,@Spell
61syn region   dsComment
62  \ matchgroup=dsCommentStart start="/\*" end="\*/"
63  \ contains=@dsCommentGroup,dsCommentStartError,@Spell extend
64
65syn region  dsString
66  \ start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=@Spell
67
68syn sync ccomment dsComment
69
70" Define the default highlighting.
71hi def link dsType              Type
72hi def link dsEndian            StorageClass
73hi def link dsStorageClass      StorageClass
74hi def link dsAlign             Label
75hi def link dsLabel             Label
76hi def link dsOffset            Label
77hi def link dsSql               PreProc
78hi def link dsCompound          Structure
79hi def link dsConditional       Conditional
80hi def link dsBoolean           Boolean
81hi def link dsKeyword           Statement
82hi def link dsString            String
83hi def link dsNumber            Number
84hi def link dsNumberBin         Number
85hi def link dsBinaryB           Special
86hi def link dsOctal             Number
87hi def link dsOctalZero         Special
88hi def link dsOctalError        Error
89hi def link dsNumberHex         Number
90hi def link dsTodo              Todo
91hi def link dsOperator          Operator
92hi def link dsPackage           Include
93hi def link dsCommentError      Error
94hi def link dsCommentStartError Error
95hi def link dsCommentStart      dsComment
96hi def link dsCommentL          dsComment
97hi def link cCommentL           dsComment
98hi def link dsComment           Comment
99
100let b:current_syntax = "datascript"
101
102let &cpo = s:keepcpo
103unlet s:keepcpo
104