2 " Language: BIND zone files (RFC1035)
3 " Maintainer: Julian Mehnle <julian@mehnle.net>
4 " URL: http://www.mehnle.net/source/odds+ends/vim/syntax/
5 " Last Change: Thu 2006-04-20 12:30:45 UTC
7 " Based on an earlier version by Вячеслав Горбанев (Slava Gorbanev), with
10 " $Id: bindzone.vim,v 1.2 2006/04/20 22:06:21 vimboss Exp $
12 " For version 5.x: Clear all syntax items
13 " For version 6.x: Quit when a syntax file was already loaded
16 elseif exists("b:current_syntax")
23 syn region zoneRRecord start=/^/ end=/$/ contains=zoneOwnerName,zoneSpecial,zoneTTL,zoneClass,zoneRRType,zoneComment,zoneUnknown
25 syn match zoneDirective /^\$ORIGIN\s\+/ nextgroup=zoneOrigin,zoneUnknown
26 syn match zoneDirective /^\$TTL\s\+/ nextgroup=zoneNumber,zoneUnknown
27 syn match zoneDirective /^\$INCLUDE\s\+/ nextgroup=zoneText,zoneUnknown
28 syn match zoneDirective /^\$GENERATE\s/
30 syn match zoneUnknown contained /\S\+/
32 syn match zoneOwnerName contained /^[^[:space:]!"#$%&'()*+,\/:;<=>?@[\]\^`{|}~]\+\(\s\|;\)\@=/ nextgroup=zoneTTL,zoneClass,zoneRRType skipwhite
33 syn match zoneOrigin contained /[^[:space:]!"#$%&'()*+,\/:;<=>?@[\]\^`{|}~]\+\(\s\|;\|$\)\@=/
34 syn match zoneDomain contained /[^[:space:]!"#$%&'()*+,\/:;<=>?@[\]\^`{|}~]\+\(\s\|;\|$\)\@=/
36 syn match zoneSpecial contained /^[@*.]\s/
37 syn match zoneTTL contained /\<\d[0-9HhWwDd]*\>/ nextgroup=zoneClass,zoneRRType skipwhite
38 syn keyword zoneClass contained IN CHAOS nextgroup=zoneRRType,zoneTTL skipwhite
39 syn keyword zoneRRType contained A AAAA CNAME HINFO MX NS PTR SOA SRV TXT nextgroup=zoneRData skipwhite
40 syn match zoneRData contained /[^;]*/ contains=zoneDomain,zoneIPAddr,zoneIP6Addr,zoneText,zoneNumber,zoneParen,zoneUnknown
42 syn match zoneIPAddr contained /\<[0-9]\{1,3}\(\.[0-9]\{1,3}\)\{,3}\>/
44 " Plain IPv6 address IPv6-embedded-IPv4 address
45 " 1111:2:3:4:5:6:7:8 1111:2:3:4:5:6:127.0.0.1
46 syn match zoneIP6Addr contained /\<\(\x\{1,4}:\)\{6}\(\x\{1,4}:\x\{1,4}\|\([0-2]\?\d\{1,2}\.\)\{3}[0-2]\?\d\{1,2}\)\>/
47 " ::[...:]8 ::[...:]127.0.0.1
48 syn match zoneIP6Addr contained /\s\@<=::\(\(\x\{1,4}:\)\{,6}\x\{1,4}\|\(\x\{1,4}:\)\{,5}\([0-2]\?\d\{1,2}\.\)\{3}[0-2]\?\d\{1,2}\)\>/
49 " 1111::[...:]8 1111::[...:]127.0.0.1
50 syn match zoneIP6Addr contained /\<\(\x\{1,4}:\)\{1}:\(\(\x\{1,4}:\)\{,5}\x\{1,4}\|\(\x\{1,4}:\)\{,4}\([0-2]\?\d\{1,2}\.\)\{3}[0-2]\?\d\{1,2}\)\>/
51 " 1111:2::[...:]8 1111:2::[...:]127.0.0.1
52 syn match zoneIP6Addr contained /\<\(\x\{1,4}:\)\{2}:\(\(\x\{1,4}:\)\{,4}\x\{1,4}\|\(\x\{1,4}:\)\{,3}\([0-2]\?\d\{1,2}\.\)\{3}[0-2]\?\d\{1,2}\)\>/
53 " 1111:2:3::[...:]8 1111:2:3::[...:]127.0.0.1
54 syn match zoneIP6Addr contained /\<\(\x\{1,4}:\)\{3}:\(\(\x\{1,4}:\)\{,3}\x\{1,4}\|\(\x\{1,4}:\)\{,2}\([0-2]\?\d\{1,2}\.\)\{3}[0-2]\?\d\{1,2}\)\>/
55 " 1111:2:3:4::[...:]8 1111:2:3:4::[...:]127.0.0.1
56 syn match zoneIP6Addr contained /\<\(\x\{1,4}:\)\{4}:\(\(\x\{1,4}:\)\{,2}\x\{1,4}\|\(\x\{1,4}:\)\{,1}\([0-2]\?\d\{1,2}\.\)\{3}[0-2]\?\d\{1,2}\)\>/
57 " 1111:2:3:4:5::[...:]8 1111:2:3:4:5::127.0.0.1
58 syn match zoneIP6Addr contained /\<\(\x\{1,4}:\)\{5}:\(\(\x\{1,4}:\)\{,1}\x\{1,4}\|\([0-2]\?\d\{1,2}\.\)\{3}[0-2]\?\d\{1,2}\)\>/
60 syn match zoneIP6Addr contained /\<\(\x\{1,4}:\)\{6}:\x\{1,4}\>/
62 syn match zoneIP6Addr contained /\<\(\x\{1,4}:\)\{1,7}:\(\s\|;\|$\)\@=/
64 syn match zoneText contained /"\([^"\\]\|\\.\)*"\(\s\|;\|$\)\@=/
65 syn match zoneNumber contained /\<[0-9]\+\(\s\|;\|$\)\@=/
66 syn match zoneSerial contained /\<[0-9]\{9,10}\(\s\|;\|$\)\@=/
68 syn match zoneErrParen /)/
69 syn region zoneParen contained start="(" end=")" contains=zoneSerial,zoneNumber,zoneComment
70 syn match zoneComment /;.*/
72 " Define the default highlighting.
73 " For version 5.7 and earlier: only when not done already
74 " For version 5.8 and later: only when an item doesn't have highlighting yet
75 if version >= 508 || !exists("did_bind_zone_syn_inits")
77 let did_bind_zone_syn_inits = 1
78 command -nargs=+ HiLink hi link <args>
80 command -nargs=+ HiLink hi def link <args>
83 HiLink zoneDirective Macro
85 HiLink zoneUnknown Error
87 HiLink zoneOrigin Statement
88 HiLink zoneOwnerName Statement
89 HiLink zoneDomain Identifier
91 HiLink zoneSpecial Special
92 HiLink zoneTTL Constant
93 HiLink zoneClass Include
94 HiLink zoneRRType Type
96 HiLink zoneIPAddr Number
97 HiLink zoneIP6Addr Number
98 HiLink zoneText String
99 HiLink zoneNumber Number
100 HiLink zoneSerial Special
102 HiLink zoneErrParen Error
103 HiLink zoneComment Comment
108 let b:current_syntax = "bindzone"