7
|
1 " Vim syntax file
|
6697
|
2 " 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.
|
7
|
27
|
|
28 " For version 5.x: Clear all syntax items
|
|
29 " For version 6.x: Quit when a syntax file was already loaded
|
|
30 if version < 600
|
|
31 syntax clear
|
|
32 elseif exists("b:current_syntax")
|
|
33 finish
|
|
34 endif
|
|
35
|
6697
|
36 syn match hexRecStart "^:"
|
|
37
|
|
38 syn match hexDataByteCount "^:[0-9a-fA-F]\{2}" contains=hexRecStart nextgroup=hexAddress
|
7
|
39
|
6697
|
40 syn match hexAddress "[0-9a-fA-F]\{4}" transparent contained nextgroup=hexRecTypeUnknown,hexRecType
|
|
41 " The address field groups include the record type field in the last 2
|
|
42 " characters, the proper match for highlighting follows below.
|
|
43 syn match hexAddressFieldUnknown "^:[0-9a-fA-F]\{8}" contains=hexDataByteCount nextgroup=hexDataFieldUnknown,hexChecksum
|
|
44 syn match hexDataAddress "^:[0-9a-fA-F]\{6}00" contains=hexDataByteCount nextgroup=hexDataOdd,hexChecksum
|
|
45 syn match hexNoAddress "^:[0-9a-fA-F]\{6}01" contains=hexDataByteCount nextgroup=hexDataUnexpected,hexChecksum
|
|
46 syn match hexNoAddress "^:[0-9a-fA-F]\{6}0[24]" contains=hexDataByteCount nextgroup=hexExtendedAddress
|
|
47 syn match hexNoAddress "^:[0-9a-fA-F]\{6}0[35]" contains=hexDataByteCount nextgroup=hexStartAddress
|
|
48
|
|
49 syn match hexRecTypeUnknown "[0-9a-fA-F]\{2}" contained
|
|
50 syn match hexRecType "0[0-5]" contained
|
7
|
51
|
6697
|
52 syn match hexDataFieldUnknown "[0-9a-fA-F]\{2}" contained nextgroup=hexDataFieldUnknown,hexChecksum
|
|
53 " alternating highlight per byte for easier reading
|
|
54 syn match hexDataOdd "[0-9a-fA-F]\{2}" contained nextgroup=hexDataEven,hexChecksum
|
|
55 syn match hexDataEven "[0-9a-fA-F]\{2}" contained nextgroup=hexDataOdd,hexChecksum
|
|
56 " data bytes which should not exist
|
|
57 syn match hexDataUnexpected "[0-9a-fA-F]\{2}" contained nextgroup=hexDataUnexpected,hexChecksum
|
|
58 " Data digit pair regex usage also results in only highlighting the checksum
|
|
59 " if the number of data characters is even.
|
7
|
60
|
6697
|
61 " special data fields
|
|
62 syn match hexExtendedAddress "[0-9a-fA-F]\{4}" contained nextgroup=hexDataUnexpected,hexChecksum
|
|
63 syn match hexStartAddress "[0-9a-fA-F]\{8}" contained nextgroup=hexDataUnexpected,hexChecksum
|
|
64
|
|
65 syn match hexChecksum "[0-9a-fA-F]\{2}$" contained
|
|
66
|
|
67 " Folding Data Records below an Extended Segment/Linear Address Record
|
|
68 syn region hexExtAdrBlock start="^:[0-9a-fA-F]\{7}[24]" skip="^:[0-9a-fA-F]\{7}0" end="^:"me=s-1 fold transparent
|
7
|
69
|
|
70 " Define the default highlighting.
|
|
71 " For version 5.7 and earlier: only when not done already
|
|
72 " For version 5.8 and later: only when an item doesn't have highlighting yet
|
|
73 if version >= 508 || !exists("did_hex_syntax_inits")
|
|
74 if version < 508
|
|
75 let did_hex_syntax_inits = 1
|
|
76 command -nargs=+ HiLink hi link <args>
|
|
77 else
|
|
78 command -nargs=+ HiLink hi def link <args>
|
|
79 endif
|
|
80
|
6697
|
81 " The default methods for highlighting. Can be overridden later
|
|
82 HiLink hexRecStart hexRecType
|
|
83 HiLink hexDataByteCount Constant
|
|
84 hi def hexAddressFieldUnknown term=italic cterm=italic gui=italic
|
|
85 HiLink hexDataAddress Comment
|
|
86 HiLink hexNoAddress DiffAdd
|
|
87 HiLink hexRecTypeUnknown hexRecType
|
|
88 HiLink hexRecType WarningMsg
|
|
89 hi def hexDataFieldUnknown term=italic cterm=italic gui=italic
|
|
90 hi def hexDataOdd term=bold cterm=bold gui=bold
|
|
91 hi def hexDataEven term=NONE cterm=NONE gui=NONE
|
|
92 HiLink hexDataUnexpected Error
|
|
93 HiLink hexExtendedAddress hexDataAddress
|
|
94 HiLink hexStartAddress hexDataAddress
|
|
95 HiLink hexChecksum DiffChange
|
7
|
96
|
|
97 delcommand HiLink
|
|
98 endif
|
|
99
|
|
100 let b:current_syntax = "hex"
|
|
101
|
|
102 " vim: ts=8
|