Runtime files update
[MacVim.git] / runtime / syntax / yacc.vim
blobd4bd0196b8b8f4ecd8d4a7ea5acded5e0b57d1d6
1 " Vim syntax file
2 " Language:     Yacc
3 " Maintainer:   Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz>
4 " Last Change:  Jan 09, 2008
5 " Version:      5
6 " URL:  http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax
8 " Options: {{{1
9 "   g:yacc_uses_cpp : if this variable exists, then C++ is loaded rather than C
10 "   g:yacc_minlines : see :help :he syn-sync-minlines -- default 50
11 "   g:yacc_maxlines : see :help :he syn-sync-maxlines -- default 200
13 " ---------------------------------------------------------------------
14 " For version 5.x: Clear all syntax items {{{1
15 " For version 6.x: Quit when a syntax file was already loaded
16 if version < 600
17   syntax clear
18 elseif exists("b:current_syntax")
19   finish
20 endif
22 " ---------------------------------------------------------------------
23 " Read the C syntax to start with {{{1
24 if version >= 600
25   if exists("g:yacc_uses_cpp")
26     runtime! syntax/cpp.vim
27   else
28     runtime! syntax/c.vim
29   endif
30 elseif exists("g:yacc_uses_cpp")
31   so <sfile>:p:h/cpp.vim
32 else
33   so <sfile>:p:h/c.vim
34 endif
36 " ---------------------------------------------------------------------
37 " Clusters {{{1
38 syn cluster     yaccActionGroup contains=yaccDelim,cInParen,cTodo,cIncluded,yaccDelim,yaccCurlyError,yaccUnionCurly,yaccUnion,cUserLabel,cOctalZero,cCppOut2,cCppSkip,cErrInBracket,cErrInParen,cOctalError,cCommentStartError,cParenError
39 syn cluster     yaccUnionGroup  contains=yaccKey,cComment,yaccCurly,cType,cStructure,cStorageClass,yaccUnionCurly
41 " ---------------------------------------------------------------------
42 " Yacc stuff {{{1
43 syn match       yaccDelim       "^\s*[:|;]"
44 syn match       yaccOper        "@\d\+"
46 syn match       yaccKey "^\s*%\(token\|type\|left\|right\|start\|ident\|nonassoc\)\>"
47 syn match       yaccKey "\s%\(prec\|expect\)\>"
48 syn match       yaccKey "\$\(<[a-zA-Z_][a-zA-Z_0-9]*>\)\=[\$0-9]\+"
49 syn keyword     yaccKeyActn     yyerrok yyclearin
51 syn match       yaccUnionStart  "^%union"       skipwhite skipnl nextgroup=yaccUnion
52 syn region      yaccUnion       contained matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}"   contains=@yaccUnionGroup
53 syn region      yaccUnionCurly  contained matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}" contains=@yaccUnionGroup
54 syn match       yaccBrkt        contained "[<>]"
55 syn match       yaccType        "<[a-zA-Z_][a-zA-Z0-9_]*>"      contains=yaccBrkt
56 syn match       yaccDefinition  "^[A-Za-z][A-Za-z0-9_]*\_s*:"
58 " ---------------------------------------------------------------------
59 " special Yacc separators {{{1
60 syn match       yaccSectionSep  "^[ \t]*%%"
61 syn match       yaccSep "^[ \t]*%{"
62 syn match       yaccSep "^[ \t]*%}"
64 " ---------------------------------------------------------------------
65 " I'd really like to highlight just the outer {}.  Any suggestions??? {{{1
66 syn match       yaccCurlyError  "[{}]"
67 syn region      yaccAction      matchgroup=yaccCurly start="{" end="}" contains=ALLBUT,@yaccActionGroup
69 " ---------------------------------------------------------------------
70 " Yacc synchronization: {{{1
71 if exists("g:yacc_maxlines")
72  exe "syn sync maxlines=".g:yacc_maxlines
73 else
74  syn sync maxlines=200
75 endif
76 if exists("g:yacc_minlines")
77  exe "syn sync minlines=".g:yacc_minlines
78 else
79  syn sync minlines=50
80 endif
82 " ---------------------------------------------------------------------
83 " Define the default highlighting. {{{1
84 " For version 5.7 and earlier: only when not done already
85 " For version 5.8 and later: only when an item doesn't have highlighting yet
86 if version >= 508 || !exists("did_yacc_syn_inits")
87   if version < 508
88     let did_yacchdl_syn_inits = 1
89     command -nargs=+ HiLink hi link <args>
90   else
91     command -nargs=+ HiLink hi def link <args>
92   endif
94   " Internal yacc highlighting links {{{2
95   HiLink yaccBrkt       yaccStmt
96   HiLink yaccKey        yaccStmt
97   HiLink yaccOper       yaccStmt
98   HiLink yaccUnionStart yaccKey
100   " External yacc highlighting links {{{2
101   HiLink yaccCurly      Delimiter
102   HiLink yaccCurlyError Error
103   HiLink yaccDefinition Function
104   HiLink yaccDelim      Function
105   HiLink yaccKeyActn    Special
106   HiLink yaccSectionSep Todo
107   HiLink yaccSep        Delimiter
108   HiLink yaccStmt       Statement
109   HiLink yaccType       Type
111   " since Bram doesn't like my Delimiter :| {{{2
112   HiLink Delimiter      Type
114   delcommand HiLink
115 endif
116 let b:current_syntax = "yacc"
118 " ---------------------------------------------------------------------
119 "  Modelines: {{{1
120 " vim: ts=15 fdm=marker