Bram Moolenaar | 5837f1f | 2015-03-21 18:06:14 +0100 | [diff] [blame] | 1 | " 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 | |
| 27 | " For version 5.x: Clear all syntax items |
| 28 | " For version 6.x: Quit when a syntax file was already loaded |
| 29 | if version < 600 |
| 30 | syntax clear |
| 31 | elseif exists("b:current_syntax") |
| 32 | finish |
| 33 | endif |
| 34 | |
| 35 | syn match srecRecStart "^S" |
| 36 | |
| 37 | syn match srecRecTypeUnknown "^S." contains=srecRecStart |
| 38 | syn match srecRecType "^S[0-35-9]" contains=srecRecStart |
| 39 | |
| 40 | syn match srecByteCount "^S.[0-9a-fA-F]\{2}" contains=srecRecTypeUnknown nextgroup=srecAddressFieldUnknown,srecChecksum |
| 41 | syn match srecByteCount "^S[0-35-9][0-9a-fA-F]\{2}" contains=srecRecType |
| 42 | |
| 43 | syn match srecAddressFieldUnknown "[0-9a-fA-F]\{2}" contained nextgroup=srecAddressFieldUnknown,srecChecksum |
| 44 | |
| 45 | syn match srecNoAddress "^S0[0-9a-fA-F]\{6}" contains=srecByteCount nextgroup=srecDataOdd,srecChecksum |
| 46 | syn match srecDataAddress "^S1[0-9a-fA-F]\{6}" contains=srecByteCount nextgroup=srecDataOdd,srecChecksum |
| 47 | syn match srecDataAddress "^S2[0-9a-fA-F]\{8}" contains=srecByteCount nextgroup=srecDataOdd,srecChecksum |
| 48 | syn match srecDataAddress "^S3[0-9a-fA-F]\{10}" contains=srecByteCount nextgroup=srecDataOdd,srecChecksum |
| 49 | syn match srecRecCount "^S5[0-9a-fA-F]\{6}" contains=srecByteCount nextgroup=srecDataUnexpected,srecChecksum |
| 50 | syn match srecRecCount "^S6[0-9a-fA-F]\{8}" contains=srecByteCount nextgroup=srecDataUnexpected,srecChecksum |
| 51 | syn match srecStartAddress "^S7[0-9a-fA-F]\{10}" contains=srecByteCount nextgroup=srecDataUnexpected,srecChecksum |
| 52 | syn match srecStartAddress "^S8[0-9a-fA-F]\{8}" contains=srecByteCount nextgroup=srecDataUnexpected,srecChecksum |
| 53 | syn match srecStartAddress "^S9[0-9a-fA-F]\{6}" contains=srecByteCount nextgroup=srecDataUnexpected,srecChecksum |
| 54 | |
| 55 | " alternating highlight per byte for easier reading |
| 56 | syn match srecDataOdd "[0-9a-fA-F]\{2}" contained nextgroup=srecDataEven,srecChecksum |
| 57 | syn match srecDataEven "[0-9a-fA-F]\{2}" contained nextgroup=srecDataOdd,srecChecksum |
| 58 | " data bytes which should not exist |
| 59 | syn match srecDataUnexpected "[0-9a-fA-F]\{2}" contained nextgroup=srecDataUnexpected,srecChecksum |
| 60 | " Data digit pair regex usage also results in only highlighting the checksum |
| 61 | " if the number of data characters is even. |
| 62 | |
| 63 | syn match srecChecksum "[0-9a-fA-F]\{2}$" contained |
| 64 | |
| 65 | " Define the default highlighting. |
| 66 | " For version 5.7 and earlier: only when not done already |
| 67 | " For version 5.8 and later: only when an item doesn't have highlighting yet |
| 68 | if version >= 508 || !exists("did_srec_syntax_inits") |
| 69 | if version < 508 |
| 70 | let did_srec_syntax_inits = 1 |
| 71 | command -nargs=+ HiLink hi link <args> |
| 72 | else |
| 73 | command -nargs=+ HiLink hi def link <args> |
| 74 | endif |
| 75 | |
| 76 | " The default methods for highlighting. Can be overridden later |
| 77 | HiLink srecRecStart srecRecType |
| 78 | HiLink srecRecTypeUnknown srecRecType |
| 79 | HiLink srecRecType WarningMsg |
| 80 | HiLink srecByteCount Constant |
| 81 | hi def srecAddressFieldUnknown term=italic cterm=italic gui=italic |
| 82 | HiLink srecNoAddress DiffAdd |
| 83 | HiLink srecDataAddress Comment |
| 84 | HiLink srecRecCount srecNoAddress |
| 85 | HiLink srecStartAddress srecDataAddress |
| 86 | hi def srecDataOdd term=bold cterm=bold gui=bold |
| 87 | hi def srecDataEven term=NONE cterm=NONE gui=NONE |
| 88 | HiLink srecDataUnexpected Error |
| 89 | HiLink srecChecksum DiffChange |
| 90 | |
| 91 | delcommand HiLink |
| 92 | endif |
| 93 | |
| 94 | let b:current_syntax = "srec" |
| 95 | |
| 96 | " vim: ts=8 |