Update runtime files
[MacVim.git] / runtime / syntax / yacc.vim
blob673bee34eac57dded14a289bbdf51ba4a9d5065c
1 " Vim syntax file
2 " Language:     Yacc
3 " Maintainer:   Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz>
4 " Last Change:  Sep 04, 2008
5 " Version:      6
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 if has("folding")
53  syn region     yaccUnion       fold contained  matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}"     contains=@yaccUnionGroup
54  syn region     yaccUnionCurly  fold contained matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}" contains=@yaccUnionGroup
55 else
56  syn region     yaccUnion       contained       matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}"     contains=@yaccUnionGroup
57  syn region     yaccUnionCurly  contained matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}" contains=@yaccUnionGroup
58 endif
59 syn match       yaccBrkt        contained "[<>]"
60 syn match       yaccType        "<[a-zA-Z_][a-zA-Z0-9_]*>"      contains=yaccBrkt
61 syn match       yaccDefinition  "^[A-Za-z][A-Za-z0-9_]*\_s*:"
63 " ---------------------------------------------------------------------
64 " special Yacc separators {{{1
65 syn match       yaccSectionSep  "^[ \t]*%%"
66 syn match       yaccSep "^[ \t]*%{"
67 syn match       yaccSep "^[ \t]*%}"
69 " ---------------------------------------------------------------------
70 " I'd really like to highlight just the outer {}.  Any suggestions??? {{{1
71 syn match       yaccCurlyError  "[{}]"
72 if has("folding")
73  syn region     yaccAction      fold    matchgroup=yaccCurly start="{" end="}" contains=ALLBUT,@yaccActionGroup
74 else
75  syn region     yaccAction              matchgroup=yaccCurly start="{" end="}" contains=ALLBUT,@yaccActionGroup
76 endif
78 " ---------------------------------------------------------------------
79 " Yacc synchronization: {{{1
80 if exists("g:yacc_maxlines")
81  exe "syn sync maxlines=".g:yacc_maxlines
82 else
83  syn sync maxlines=200
84 endif
85 if exists("g:yacc_minlines")
86  exe "syn sync minlines=".g:yacc_minlines
87 else
88  syn sync minlines=50
89 endif
91 " ---------------------------------------------------------------------
92 " Define the default highlighting. {{{1
93 " For version 5.7 and earlier: only when not done already
94 " For version 5.8 and later: only when an item doesn't have highlighting yet
95 if version >= 508 || !exists("did_yacc_syn_inits")
96   if version < 508
97     let did_yacchdl_syn_inits = 1
98     command -nargs=+ HiLink hi link <args>
99   else
100     command -nargs=+ HiLink hi def link <args>
101   endif
103   " Internal yacc highlighting links {{{2
104   HiLink yaccBrkt       yaccStmt
105   HiLink yaccKey        yaccStmt
106   HiLink yaccOper       yaccStmt
107   HiLink yaccUnionStart yaccKey
109   " External yacc highlighting links {{{2
110   HiLink yaccCurly      Delimiter
111   HiLink yaccCurlyError Error
112   HiLink yaccDefinition Function
113   HiLink yaccDelim      Function
114   HiLink yaccKeyActn    Special
115   HiLink yaccSectionSep Todo
116   HiLink yaccSep        Delimiter
117   HiLink yaccStmt       Statement
118   HiLink yaccType       Type
120   " since Bram doesn't like my Delimiter :| {{{2
121   HiLink Delimiter      Type
123   delcommand HiLink
124 endif
125 let b:current_syntax = "yacc"
127 " ---------------------------------------------------------------------
128 "  Modelines: {{{1
129 " vim: ts=15 fdm=marker