syntax/bird.vim
branchvim-stuff
changeset 29 a0e6ddfadf82
parent 28 2b198f0a86fe
equal deleted inserted replaced
28:2b198f0a86fe 29:a0e6ddfadf82
     1 "----------------------------------------------------------------------
       
     2 " Vim syntax file
       
     3 " Language:     Configuration for the Bird Internet Routing Daemon
       
     4 " Bird Site:    http://bird.network.cz/
       
     5 " Maintainer:   Mahlon E. Smith <mahlon@martini.nu>
       
     6 " Version:      $Id$
       
     7 "----------------------------------------------------------------------
       
     8 
       
     9 if has( "folding" )
       
    10 	setlocal foldmethod=syntax
       
    11 endif
       
    12 
       
    13 setlocal iskeyword+=;
       
    14 
       
    15 syntax region  birdInlineComment start=/#/ end=/$/
       
    16 syntax region  birdBlockComment  start=/^#/ end=/^\([^#]\|$\)/me=e-1 fold
       
    17 highlight link birdInlineComment Comment
       
    18 highlight link birdBlockComment  Comment
       
    19 
       
    20 syntax region  birdString start=/"/ skip=/\\"/ end=/"/
       
    21 highlight link birdString String
       
    22 
       
    23 syntax match   birdNetworkAddressIP4 /\d\+\.\d\+\.\d\+\.\d\+\(\/\d\+\)\?/
       
    24 highlight link birdNetworkAddressIP4 Character
       
    25 
       
    26 syntax match   birdNumber / \d\+\(;\|\s\|$\)/
       
    27 highlight link birdNumber Number
       
    28 
       
    29 syntax match   birdOperator /\(+\|-\|*\|\/\|(\|)\|=\|<\|>\|!\|&&\|||\|\~\)/
       
    30 highlight link birdOperator Operator
       
    31 
       
    32 syntax region  birdFunctionArguments start=/(/ end=/)/ oneline
       
    33 syntax region  birdFunction matchgroup=birdFunctionArguments start=/\S\+(/ end=/)/ oneline transparent
       
    34 highlight link birdFunctionArguments Function
       
    35 
       
    36 syntax cluster birdCommon contains=birdInlineComment,birdString,birdNetworkAddressIP4,birdNumber,birdOperator,birdFunction
       
    37 
       
    38 syntax keyword birdGlobals define table eval
       
    39 syntax match   birdGlobals /\(router id\|listen bgp\) /
       
    40 highlight link birdGlobals PreProc
       
    41 
       
    42 syntax region  birdLog start=/^log / end=/$/ keepend contains=@birdCommon,birdLogOptions,birdLogDirective,birdLogLevels
       
    43 syntax keyword birdLogOptions syslog stderr contained
       
    44 syntax keyword birdLogLevels all all; info warning error fatal trace remote auth bug contained
       
    45 syntax keyword birdLogDirective log contained
       
    46 highlight link birdLogOptions   Identifier
       
    47 highlight link birdLogDirective PreProc
       
    48 highlight link birdLogLevels    Special
       
    49 highlight link birdLog          Normal
       
    50 
       
    51 syntax region  birdDebug start=/debug / end=/$/ keepend contains=@birdCommon,birdDebugOptions,birdDebugDirective,birdDebugTypes
       
    52 syntax keyword birdDebugOptions protocols commands contained
       
    53 syntax keyword birdDebugTypes all all; off off; states routes filters interfaces events packets messages contained
       
    54 syntax keyword birdDebugDirective debug contained
       
    55 highlight link birdDebugOptions   Identifier
       
    56 highlight link birdDebugDirective PreProc
       
    57 highlight link birdDebugTypes     Special
       
    58 highlight link birdDebug          Normal
       
    59 
       
    60 syntax region  birdMrt start=/mrtdump / end=/$/ keepend contains=@birdCommon,birdMrtOptions,birdMrtDirective,birdMrtTypes
       
    61 syntax keyword birdMrtOptions protocols contained
       
    62 syntax keyword birdMrtTypes all all; off off; states messages contained
       
    63 syntax keyword birdMrtDirective mrtdump contained
       
    64 highlight link birdMrtOptions   Identifier
       
    65 highlight link birdMrtDirective PreProc
       
    66 highlight link birdMrtTypes     Special
       
    67 highlight link birdMrt          Normal
       
    68 
       
    69 syntax cluster birdProtoShared contains=birdGlobals,birdDebug,birdMrt
       
    70 
       
    71 syntax region  birdTimeFormat start=/^timeformat / end=/$/ keepend contains=@birdCommon,birdTimeFormatDirective,birdTimeFormatTypes
       
    72 syntax keyword birdTimeFormatTypes route protocol base log contained
       
    73 syntax keyword birdTimeFormatDirective timeformat contained
       
    74 highlight link birdTimeFormatDirective PreProc
       
    75 highlight link birdTimeFormatTypes     Identifier
       
    76 highlight link birdTimeFormat          Normal
       
    77 
       
    78 syntax region  birdImportExport start=/\(import\|export\) / end=/$/  contains=@birdCommon,birdImportExportDirective,birdImportExportTypes,birdFilter,birdFilterProtoConstants,birdFilterAttributes
       
    79 syntax keyword birdImportExportDirective import export contained
       
    80 syntax keyword birdImportExportTypes all all; none none; where contained
       
    81 highlight link birdImportExportDirective Type
       
    82 highlight link birdImportExportTypes     Special
       
    83 highlight link birdImportExport          Normal
       
    84 
       
    85 syntax region  birdProtocol start=/^protocol / end=/^}/ contains=@birdCommon,@birdProtoShared,birdProtocolDirective,birdProtocolTypes,birdProtocolMisc,birdProtocolGlobals,birdImportExport,birdProtocolDisabled,birdProtocolBools,birdProtocolDate,birdFilter,birdProtocolAttributes fold
       
    86 syntax keyword birdProtocolDirective protocol area interface networks stubnet neighbors contained
       
    87 syntax match   birdProtocolDirective /virtual link / contained
       
    88 syntax keyword birdProtocolTypes bgp device direct kernel ospf pipe rip static contained
       
    89 syntax keyword birdProtocolMisc as via self self; drop drop; ignore ignore; normal; large; broadcast; nonbroadcast nonbroadcast; pointopoint; none; simple; plain; md5; cryptographic; eligible; opaque; transparent; always; never; neighbor; multicast; reject; prohibit; contained
       
    90 syntax keyword birdProtocolGlobals preference description id password type local neighbor multihop passive passive; persist persist; learn learn; primary rfc1583compat rfc1583compat; tick hidden hidden; summary summary; cost stub stub; hello poll retransmit priority wait authentication strict honor port infinity period mode route contained
       
    91 syntax match   birdProtocolGlobals /generate from\|generate to\|accept from\|accept to\|next hop\|missing lladdr\|source address\|rr client\|rr cluster id\|rs client\|enable route refresh\|interpret communities\|enable as4\|capabilities\|advertise ipv4\|route limit\|disable after error\|\(startup \)\?hold time\|\(scan\|keepalive\|timeout\|garbage\|connect retry\|start delay\|error \(wait\|forget\)\) time\|path metric\|prefer older\|default bgp_med\|default bgp_local_pref\|device routes\|\(kernel\|peer\) table\|stub cost\|dead\( count\)\?\|rx buffer/ contained
       
    92 syntax match   birdProtocolDate /\d\{2\}-\d\{2\}-\d\{4\} \d\{2\}:\d\{2\}:\d\{2\}/ contained
       
    93 syntax keyword birdProtocolDisabled disabled disabled; contained
       
    94 syntax keyword birdProtocolBools yes yes; no no; contained
       
    95 syntax match   birdProtocolAttributes /bgp_path\|bgp_local_pref\|bgp_med\|bgp_origin\|bgp_next_hop\|bgp_atomic_aggr\|bgp_community\|bgp_originator_id\|bgp_cluster_list\|ospf_metric1\|ospf_metric2\|ospf_tag\|rip_metric\|rip_tag/ contained
       
    96 highlight link birdProtocolDirective  PreProc
       
    97 highlight link birdProtocolTypes      Function
       
    98 highlight link birdProtocolMisc       String
       
    99 highlight link birdProtocolGlobals    Constant
       
   100 highlight link birdProtocolDisabled   Error
       
   101 highlight link birdProtocolBools      Boolean
       
   102 highlight link birdProtocolDate		  Number
       
   103 highlight link birdProtocolAttributes Identifier
       
   104 highlight link birdProtocol           Normal
       
   105 
       
   106 syntax keyword birdInternalFunctions accept accept; reject reject; print printn return quitbird defined contained
       
   107 syntax keyword birdInternalControls if then else case contained
       
   108 syntax keyword birdInternalTypes bool int pair quad string ip prefix enum bgppath bgpmask clist contained
       
   109 highlight link birdInternalFunctions Keyword
       
   110 highlight link birdInternalControls  Conditional
       
   111 highlight link birdInternalTypes     Type
       
   112 
       
   113 " inline, named filters
       
   114 syntax match   birdFilter /filter.\+$/ contains=@birdCommon,birdFilterDirective
       
   115 " filter definitions
       
   116 syntax region  birdFilter start=/^filter\(\s\+\S\+\)\?\s\+/ end=/^}$/ fold contains=@birdCommon,birdFilterDirective,birdFilterProtoConstants,birdInternalFunctions,birdFilterAttributes,birdInternalControls,birdInternalTypes,birdProtocolAttributes
       
   117 " inline complex filters
       
   118 syntax region  birdFilter start=/filter\s\+{/ end=/};/ fold contains=@birdCommon,birdFilterDirective,birdFilterProtoConstants,birdInternalFunctions,birdFilterAttributes,birdInternalControls,birdInternalTypes,birdProtocolAttributes
       
   119 syntax match   birdFilterDirective /filter/ nextgroup=birdFilterName skipwhite contained
       
   120 syntax match   birdFilterName /[^{;]\+/ skipwhite contained
       
   121 syntax match   birdFilterProtoConstants /\(RTS_DUMMY\|RTS_STATIC\|RTS_INHERIT\|RTS_DEVICE\|RTS_STATIC_DEVICE\|RTS_REDIRECT\|RTS_RIP\|RTS_OSPF\|RTS_OSPF_IA\|RTS_OSPF_EXT1\|RTS_OSPF_EXT2\|RTS_BGP\|RTS_PIPE\)/ contained
       
   122 syntax keyword birdFilterAttributes net scope preference from gw proto source cast dest contained
       
   123 highlight link birdFilterDirective      PreProc
       
   124 highlight link birdFilterName           Function
       
   125 highlight link birdFilterProtoConstants Underlined
       
   126 highlight link birdFilterAttributes     Identifier
       
   127 highlight link birdFilter               Normal
       
   128 
       
   129 syntax region  birdFunctionDef start=/^function\(\s\+\S\+\)\?\s\+/ end=/^}$/ fold contains=@birdCommon,birdFunctionDirective,birdInternalFunctions,birdInternalControls,birdInternalTypes
       
   130 syntax match   birdFunctionDirective /function / nextgroup=birdFunctionName skipwhite contained
       
   131 syntax match   birdFunctionName /[^(]\+/ skipwhite contained
       
   132 highlight link birdFunctionDirective PreProc
       
   133 highlight link birdFunctionName      Function
       
   134 highlight link birdFunctionDef       Normal
       
   135 
       
   136 let b:current_syntax = "bird"
       
   137