home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / runtime / dos / syntax / yacc.vim < prev    next >
Encoding:
Text File  |  2012-05-31  |  5.2 KB  |  125 lines

  1. " Vim syntax file
  2. " Language:    Yacc
  3. " Maintainer:    Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz>
  4. " Last Change:    Aug 12, 2010
  5. " Version:    9
  6. " URL:    http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax
  7. "
  8. " Options: {{{1
  9. "   g:yacc_uses_cpp : if this variable exists, then C++ is loaded rather than C
  10.  
  11. " ---------------------------------------------------------------------
  12. " this version of syntax/yacc.vim requires 6.0 or later
  13. if version < 600
  14.  finish
  15. endif
  16. if exists("b:current_syntax")
  17.  syntax clear
  18. endif
  19.  
  20. " ---------------------------------------------------------------------
  21. "  Folding Support {{{1
  22. if has("folding")
  23.  com! -nargs=+ HiFold    <args> fold
  24. else
  25.  com! -nargs=+ HiFold    <args>
  26. endif
  27.  
  28. " ---------------------------------------------------------------------
  29. " Read the C syntax to start with {{{1
  30. if exists("g:yacc_uses_cpp")
  31.  syn include @yaccCode    <sfile>:p:h/cpp.vim
  32. else
  33.  syn include @yaccCode    <sfile>:p:h/c.vim
  34. endif
  35.  
  36. " ---------------------------------------------------------------------
  37. "  Yacc Clusters: {{{1
  38. syn cluster yaccInitCluster    contains=yaccKey,yaccKeyActn,yaccBrkt,yaccType,yaccString,yaccUnionStart,yaccHeader2,yaccComment,yaccDefines,yaccParseParam,yaccParseOption
  39. syn cluster yaccRulesCluster    contains=yaccNonterminal,yaccString
  40.  
  41. " ---------------------------------------------------------------------
  42. "  Yacc Sections: {{{1
  43. HiFold syn    region    yaccInit    start='.'ms=s-1,rs=s-1    matchgroup=yaccSectionSep    end='^%%$'me=e-2,re=e-2    contains=@yaccInitCluster    nextgroup=yaccRules    skipwhite skipempty contained
  44. HiFold syn    region    yaccInit2      start='\%^.'ms=s-1,rs=s-1    matchgroup=yaccSectionSep    end='^%%$'me=e-2,re=e-2    contains=@yaccInitCluster    nextgroup=yaccRules    skipwhite skipempty
  45. HiFold syn    region    yaccHeader2    matchgroup=yaccSep    start="^\s*\zs%{"    end="^\s*%}"        contains=@yaccCode    nextgroup=yaccInit    skipwhite skipempty contained
  46. HiFold syn    region    yaccHeader    matchgroup=yaccSep    start="^\s*\zs%{"    end="^\s*%}"        contains=@yaccCode    nextgroup=yaccInit    skipwhite skipempty
  47. HiFold syn    region    yaccRules    matchgroup=yaccSectionSep    start='^%%$'        end='^%%$'me=e-2,re=e-2    contains=@yaccRulesCluster    nextgroup=yaccEndCode    skipwhite skipempty contained
  48. HiFold syn    region    yaccEndCode    matchgroup=yaccSectionSep    start='^%%$'        end='\%$'        contains=@yaccCode    contained
  49.  
  50. " ---------------------------------------------------------------------
  51. " Yacc Commands: {{{1
  52. syn    match    yaccDefines    '^%define\s\+.*$'
  53. syn    match    yaccParseParam    '%\(parse\|lex\)-param\>'        skipwhite    nextgroup=yaccParseParamStr
  54. syn    match    yaccParseOption '%\%(api\.pure\|pure-parser\|locations\|error-verbose\)\>'
  55. syn    region    yaccParseParamStr    contained matchgroup=Delimiter    start='{'    end='}'    contains=cStructure
  56.  
  57. syn    match    yaccDelim    "[:|]"    contained
  58. syn    match    yaccOper    "@\d\+"    contained
  59.  
  60. syn    match    yaccKey    "^\s*%\(token\|type\|left\|right\|start\|ident\|nonassoc\)\>"    contained
  61. syn    match    yaccKey    "\s%\(prec\|expect\)\>"    contained
  62. syn    match    yaccKey    "\$\(<[a-zA-Z_][a-zA-Z_0-9]*>\)\=[\$0-9]\+"    contained
  63. syn    keyword    yaccKeyActn    yyerrok yyclearin    contained
  64.  
  65. syn    match    yaccUnionStart    "^%union"    skipwhite skipnl nextgroup=yaccUnion    contained
  66. HiFold syn    region    yaccUnion    matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}" contains=@yaccCode    contained
  67. syn    match    yaccBrkt    "[<>]"    contained
  68. syn    match    yaccType    "<[a-zA-Z_][a-zA-Z0-9_]*>"    contains=yaccBrkt    contained
  69.  
  70. HiFold syn    region    yaccNonterminal    start="^\s*\a\w*\ze\_s*\(/\*\_.\{-}\*/\)\=\_s*:"    matchgroup=yaccDelim end=";"    matchgroup=yaccSectionSep end='^%%$'me=e-2,re=e-2 contains=yaccAction,yaccDelim,yaccString,yaccComment    contained
  71. syn    region    yaccComment    start="/\*"    end="\*/"
  72. syn    match    yaccString    "'[^']*'"    contained
  73.  
  74.  
  75. " ---------------------------------------------------------------------
  76. " I'd really like to highlight just the outer {}.  Any suggestions??? {{{1
  77. syn    match    yaccCurlyError    "[{}]"
  78. HiFold syn    region    yaccAction    matchgroup=yaccCurly start="{" end="}" contains=@yaccCode    contained
  79.  
  80. " ---------------------------------------------------------------------
  81. " Yacc synchronization: {{{1
  82. syn sync fromstart
  83.  
  84. " ---------------------------------------------------------------------
  85. " Define the default highlighting. {{{1
  86. if !exists("did_yacc_syn_inits")
  87.   command -nargs=+ HiLink hi def link <args>
  88.  
  89.   " Internal yacc highlighting links {{{2
  90.   HiLink yaccBrkt    yaccStmt
  91.   HiLink yaccKey    yaccStmt
  92.   HiLink yaccOper    yaccStmt
  93.   HiLink yaccUnionStart    yaccKey
  94.  
  95.   " External yacc highlighting links {{{2
  96.   HiLink yaccComment    Comment
  97.   HiLink yaccCurly    Delimiter
  98.   HiLink yaccCurlyError    Error
  99.   HiLink yaccDefines    cDefine
  100.   HiLink yaccParseParam    yaccParseOption
  101.   HiLink yaccParseOption    cDefine
  102.   HiLink yaccNonterminal    Function
  103.   HiLink yaccDelim    Delimiter
  104.   HiLink yaccKeyActn    Special
  105.   HiLink yaccSectionSep    Todo
  106.   HiLink yaccSep    Delimiter
  107.   HiLink yaccString    String
  108.   HiLink yaccStmt    Statement
  109.   HiLink yaccType    Type
  110.  
  111.   " since Bram doesn't like my Delimiter :| {{{2
  112.   HiLink Delimiter    Type
  113.  
  114.   delcommand HiLink
  115. endif
  116.  
  117. " ---------------------------------------------------------------------
  118. "  Cleanup: {{{1
  119. delcommand HiFold
  120. let b:current_syntax = "yacc"
  121.  
  122. " ---------------------------------------------------------------------
  123. "  Modelines: {{{1
  124. " vim: ts=15 fdm=marker
  125.