blob: 834cec7baaeb40f8144e9b3a44e4f3975070cb2c [file] [log] [blame]
Bram Moolenaar5837f1f2015-03-21 18:06:14 +01001" Vim syntax file
2" Language: Motorola S-Record
3" Maintainer: Markus Heidelberg <markus.heidelberg@web.de>
4" Last Change: 2015 Feb 24
5
6" Each record (line) is built as follows:
7"
8" field digits states
9"
10" +----------+
11" | start | 1 ('S') srecRecStart
12" +----------+
13" | type | 1 srecRecType, (srecRecTypeUnknown)
14" +----------+
15" | count | 2 srecByteCount
16" +----------+
17" | address | 4/6/8 srecNoAddress, srecDataAddress, srecRecCount, srecStartAddress, (srecAddressFieldUnknown)
18" +----------+
19" | data | 0..504/502/500 srecDataOdd, srecDataEven, (srecDataUnexpected)
20" +----------+
21" | checksum | 2 srecChecksum
22" +----------+
23"
24" States in parentheses in the upper format description indicate that they
25" should not appear in a valid file.
26
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020027" quit when a syntax file was already loaded
28if exists("b:current_syntax")
Bram Moolenaar5837f1f2015-03-21 18:06:14 +010029 finish
30endif
31
32syn match srecRecStart "^S"
33
34syn match srecRecTypeUnknown "^S." contains=srecRecStart
35syn match srecRecType "^S[0-35-9]" contains=srecRecStart
36
37syn match srecByteCount "^S.[0-9a-fA-F]\{2}" contains=srecRecTypeUnknown nextgroup=srecAddressFieldUnknown,srecChecksum
38syn match srecByteCount "^S[0-35-9][0-9a-fA-F]\{2}" contains=srecRecType
39
40syn match srecAddressFieldUnknown "[0-9a-fA-F]\{2}" contained nextgroup=srecAddressFieldUnknown,srecChecksum
41
42syn match srecNoAddress "^S0[0-9a-fA-F]\{6}" contains=srecByteCount nextgroup=srecDataOdd,srecChecksum
43syn match srecDataAddress "^S1[0-9a-fA-F]\{6}" contains=srecByteCount nextgroup=srecDataOdd,srecChecksum
44syn match srecDataAddress "^S2[0-9a-fA-F]\{8}" contains=srecByteCount nextgroup=srecDataOdd,srecChecksum
45syn match srecDataAddress "^S3[0-9a-fA-F]\{10}" contains=srecByteCount nextgroup=srecDataOdd,srecChecksum
46syn match srecRecCount "^S5[0-9a-fA-F]\{6}" contains=srecByteCount nextgroup=srecDataUnexpected,srecChecksum
47syn match srecRecCount "^S6[0-9a-fA-F]\{8}" contains=srecByteCount nextgroup=srecDataUnexpected,srecChecksum
48syn match srecStartAddress "^S7[0-9a-fA-F]\{10}" contains=srecByteCount nextgroup=srecDataUnexpected,srecChecksum
49syn match srecStartAddress "^S8[0-9a-fA-F]\{8}" contains=srecByteCount nextgroup=srecDataUnexpected,srecChecksum
50syn match srecStartAddress "^S9[0-9a-fA-F]\{6}" contains=srecByteCount nextgroup=srecDataUnexpected,srecChecksum
51
52" alternating highlight per byte for easier reading
53syn match srecDataOdd "[0-9a-fA-F]\{2}" contained nextgroup=srecDataEven,srecChecksum
54syn match srecDataEven "[0-9a-fA-F]\{2}" contained nextgroup=srecDataOdd,srecChecksum
55" data bytes which should not exist
56syn match srecDataUnexpected "[0-9a-fA-F]\{2}" contained nextgroup=srecDataUnexpected,srecChecksum
57" Data digit pair regex usage also results in only highlighting the checksum
58" if the number of data characters is even.
59
60syn match srecChecksum "[0-9a-fA-F]\{2}$" contained
61
62" Define the default highlighting.
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020063" Only when an item doesn't have highlighting yet
64command -nargs=+ HiLink hi def link <args>
Bram Moolenaar5837f1f2015-03-21 18:06:14 +010065
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020066" The default methods for highlighting. Can be overridden later
67HiLink srecRecStart srecRecType
68HiLink srecRecTypeUnknown srecRecType
69HiLink srecRecType WarningMsg
70HiLink srecByteCount Constant
71hi def srecAddressFieldUnknown term=italic cterm=italic gui=italic
72HiLink srecNoAddress DiffAdd
73HiLink srecDataAddress Comment
74HiLink srecRecCount srecNoAddress
75HiLink srecStartAddress srecDataAddress
76hi def srecDataOdd term=bold cterm=bold gui=bold
77hi def srecDataEven term=NONE cterm=NONE gui=NONE
78HiLink srecDataUnexpected Error
79HiLink srecChecksum DiffChange
Bram Moolenaar5837f1f2015-03-21 18:06:14 +010080
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020081delcommand HiLink
Bram Moolenaar5837f1f2015-03-21 18:06:14 +010082
83let b:current_syntax = "srec"
84
85" vim: ts=8