blob: 6ac22d90622e9bbe7dab6e09941fa141fd58e893 [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
Bram Moolenaar5837f1f2015-03-21 18:06:14 +010064
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020065" The default methods for highlighting. Can be overridden later
Bram Moolenaarf37506f2016-08-31 22:22:10 +020066hi def link srecRecStart srecRecType
67hi def link srecRecTypeUnknown srecRecType
68hi def link srecRecType WarningMsg
69hi def link srecByteCount Constant
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020070hi def srecAddressFieldUnknown term=italic cterm=italic gui=italic
Bram Moolenaarf37506f2016-08-31 22:22:10 +020071hi def link srecNoAddress DiffAdd
72hi def link srecDataAddress Comment
73hi def link srecRecCount srecNoAddress
74hi def link srecStartAddress srecDataAddress
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020075hi def srecDataOdd term=bold cterm=bold gui=bold
76hi def srecDataEven term=NONE cterm=NONE gui=NONE
Bram Moolenaarf37506f2016-08-31 22:22:10 +020077hi def link srecDataUnexpected Error
78hi def link srecChecksum DiffChange
Bram Moolenaar5837f1f2015-03-21 18:06:14 +010079
Bram Moolenaar5837f1f2015-03-21 18:06:14 +010080
81let b:current_syntax = "srec"
82
83" vim: ts=8