blob: 35edf08e9fa77547a9fc5c8bed78cd542553c1d6 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
Bram Moolenaar5837f1f2015-03-21 18:06:14 +01002" Language: Intel HEX
3" Maintainer: Markus Heidelberg <markus.heidelberg@web.de>
4" Previous version: Sams Ricahrd <sams@ping.at>
5" Last Change: 2015 Feb 24
6
7" Each record (line) is built as follows:
8"
9" field digits states
10"
11" +----------+
12" | start | 1 (':') hexRecStart
13" +----------+
14" | count | 2 hexDataByteCount
15" +----------+
16" | address | 4 hexNoAddress, hexDataAddress, (hexAddressFieldUnknown)
17" +----------+
18" | type | 2 hexRecType, (hexRecTypeUnknown)
19" +----------+
20" | data | 0..510 hexDataOdd, hexDataEven, hexExtendedAddress, hexStartAddress, (hexDataFieldUnknown, hexDataUnexpected)
21" +----------+
22" | checksum | 2 hexChecksum
23" +----------+
24"
25" States in parentheses in the upper format description indicate that they
26" should not appear in a valid file.
Bram Moolenaar071d4272004-06-13 20:20:40 +000027
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020028" quit when a syntax file was already loaded
29if exists("b:current_syntax")
Bram Moolenaar071d4272004-06-13 20:20:40 +000030 finish
31endif
32
Bram Moolenaar5837f1f2015-03-21 18:06:14 +010033syn match hexRecStart "^:"
Bram Moolenaar071d4272004-06-13 20:20:40 +000034
Bram Moolenaar5837f1f2015-03-21 18:06:14 +010035syn match hexDataByteCount "^:[0-9a-fA-F]\{2}" contains=hexRecStart nextgroup=hexAddress
Bram Moolenaar071d4272004-06-13 20:20:40 +000036
Bram Moolenaar5837f1f2015-03-21 18:06:14 +010037syn match hexAddress "[0-9a-fA-F]\{4}" transparent contained nextgroup=hexRecTypeUnknown,hexRecType
38" The address field groups include the record type field in the last 2
39" characters, the proper match for highlighting follows below.
40syn match hexAddressFieldUnknown "^:[0-9a-fA-F]\{8}" contains=hexDataByteCount nextgroup=hexDataFieldUnknown,hexChecksum
41syn match hexDataAddress "^:[0-9a-fA-F]\{6}00" contains=hexDataByteCount nextgroup=hexDataOdd,hexChecksum
42syn match hexNoAddress "^:[0-9a-fA-F]\{6}01" contains=hexDataByteCount nextgroup=hexDataUnexpected,hexChecksum
43syn match hexNoAddress "^:[0-9a-fA-F]\{6}0[24]" contains=hexDataByteCount nextgroup=hexExtendedAddress
44syn match hexNoAddress "^:[0-9a-fA-F]\{6}0[35]" contains=hexDataByteCount nextgroup=hexStartAddress
Bram Moolenaar071d4272004-06-13 20:20:40 +000045
Bram Moolenaar5837f1f2015-03-21 18:06:14 +010046syn match hexRecTypeUnknown "[0-9a-fA-F]\{2}" contained
47syn match hexRecType "0[0-5]" contained
48
49syn match hexDataFieldUnknown "[0-9a-fA-F]\{2}" contained nextgroup=hexDataFieldUnknown,hexChecksum
50" alternating highlight per byte for easier reading
51syn match hexDataOdd "[0-9a-fA-F]\{2}" contained nextgroup=hexDataEven,hexChecksum
52syn match hexDataEven "[0-9a-fA-F]\{2}" contained nextgroup=hexDataOdd,hexChecksum
53" data bytes which should not exist
54syn match hexDataUnexpected "[0-9a-fA-F]\{2}" contained nextgroup=hexDataUnexpected,hexChecksum
55" Data digit pair regex usage also results in only highlighting the checksum
56" if the number of data characters is even.
57
58" special data fields
59syn match hexExtendedAddress "[0-9a-fA-F]\{4}" contained nextgroup=hexDataUnexpected,hexChecksum
60syn match hexStartAddress "[0-9a-fA-F]\{8}" contained nextgroup=hexDataUnexpected,hexChecksum
61
62syn match hexChecksum "[0-9a-fA-F]\{2}$" contained
63
64" Folding Data Records below an Extended Segment/Linear Address Record
65syn region hexExtAdrBlock start="^:[0-9a-fA-F]\{7}[24]" skip="^:[0-9a-fA-F]\{7}0" end="^:"me=s-1 fold transparent
Bram Moolenaar071d4272004-06-13 20:20:40 +000066
67" Define the default highlighting.
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020068" Only when an item doesn't have highlighting yet
Bram Moolenaar071d4272004-06-13 20:20:40 +000069
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020070" The default methods for highlighting. Can be overridden later
Bram Moolenaarf37506f2016-08-31 22:22:10 +020071hi def link hexRecStart hexRecType
72hi def link hexDataByteCount Constant
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020073hi def hexAddressFieldUnknown term=italic cterm=italic gui=italic
Bram Moolenaarf37506f2016-08-31 22:22:10 +020074hi def link hexDataAddress Comment
75hi def link hexNoAddress DiffAdd
76hi def link hexRecTypeUnknown hexRecType
77hi def link hexRecType WarningMsg
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020078hi def hexDataFieldUnknown term=italic cterm=italic gui=italic
79hi def hexDataOdd term=bold cterm=bold gui=bold
80hi def hexDataEven term=NONE cterm=NONE gui=NONE
Bram Moolenaarf37506f2016-08-31 22:22:10 +020081hi def link hexDataUnexpected Error
82hi def link hexExtendedAddress hexDataAddress
83hi def link hexStartAddress hexDataAddress
84hi def link hexChecksum DiffChange
Bram Moolenaar071d4272004-06-13 20:20:40 +000085
Bram Moolenaar071d4272004-06-13 20:20:40 +000086
87let b:current_syntax = "hex"
88
89" vim: ts=8