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