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