Advertisement
Guest User

Working Vim syntax file for 2-tiered recursion syntax

a guest
Apr 8th, 2020
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 1.69 KB | None | 0 0
  1. if !exists('main_syntax')
  2.   if exists('b:current_syntax')
  3.     finish
  4.   endif
  5.   let main_syntax='mytest'
  6. endif
  7. syn case match
  8. setlocal iskeyword=.,-,48-58,A-Z,a-z
  9. setlocal isident=.,-,48-58,A-Z,a-z,_
  10. syn sync fromstart
  11. let s:save_cpo = &cpoptions
  12. set cpoptions-=C
  13. hi link xyz_AML_Nested_Semicolon Operator
  14. hi link xyz_Semicolon Todo
  15. hi link xyz_Number    Special
  16. hi link xyz_ACLIdent  Include
  17. hi link xyz_Keywords  Statement
  18. hi link xyz_AML  Error
  19.  
  20. syn match xyz_Semicolon contained /;/
  21.  
  22. syn match xyz_AML_Nested_Semicolon contained /;/ skipwhite skipempty
  23. \ nextgroup=
  24. \    xyz_AML_Placeholder
  25.  
  26. syn match xyz_Number "\<\d\{1,10}\>" skipwhite skipempty
  27. \ nextgroup=
  28. \    xyz_AML_Nested_Semicolon
  29.  
  30. syn region xyz_AML_Placeholder contained start=+{+ end=+}+ keepend extend
  31. \ contains=
  32. \    xyz_Number,
  33. \    xyz_AML_Nested_Semicolon
  34. \ nextgroup=
  35. \    xyz_AML_Nested_Semicolon
  36.  
  37. " acl <acl_name> { ... } ;
  38. syn region xyz_AML contained start=+{+ end=+}+  skipwhite skipempty
  39. \ contains=
  40. \    xyz_Number,
  41. \    xyz_AML_Nested_Semicolon
  42. \ nextgroup=
  43. \    xyz_Semicolon
  44.  
  45. " acl <acl_name> { ... }
  46. syn match xyz_ACLIdent contained /\<[0-9a-zA-Z\-_]\{1,63}\>/ skipwhite skipempty
  47. \ nextgroup=
  48. \    xyz_AML
  49.  
  50. " acl <acl_name> ...
  51. syn match xyz_Keywords /acl/ skipwhite skipempty
  52. \ nextgroup=xyz_ACLIdent
  53.  
  54. syn match xyz_Keywords /test/ skipwhite skipempty
  55. \ nextgroup=xyz_Number
  56.  
  57. let &cpoptions = s:save_cpo
  58. unlet s:save_cpo
  59. let b:current_syntax = 'mytest'
  60. if main_syntax ==# 'mytest'
  61.   unlet main_syntax
  62. endif
  63. " Note: AML == address_match_list
  64. "
  65. " AML = ( <number> | <AML> ) ; ...
  66. " acl <acl_name> { <AML> ; ... } ;
  67. " Google Vimscript style guide
  68. " vim: ts=2 sts=2 ts=80
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement