Install vim74
[msysgit.git] / share / vim / vim74 / syntax / yacc.vim
blob3da7ffc9f9043e0718ffaa59f1d170f4f5dad5ec
1 " Vim syntax file
2 " Language:     Yacc
3 " Maintainer:   Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz>
4 " Last Change:  Nov 14, 2012
5 " Version:      10
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
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
20 " ---------------------------------------------------------------------
21 "  Folding Support {{{1
22 if has("folding")
23  com! -nargs=+ SynFold  <args> fold
24 else
25  com! -nargs=+ SynFold  <args>
26 endif
28 " ---------------------------------------------------------------------
29 " Read the C syntax to start with {{{1
30 " Read the C/C++ syntax to start with
31 let s:Cpath= fnameescape(expand("<sfile>:p:h").(exists("g:yacc_uses_cpp")? "/cpp.vim" : "/c.vim"))
32 if !filereadable(s:Cpath)
33  for s:Cpath in split(globpath(&rtp,(exists("g:yacc_uses_cpp")? "syntax/cpp.vim" : "syntax/c.vim")),"\n")
34   if filereadable(fnameescape(s:Cpath))
35    let s:Cpath= fnameescape(s:Cpath)
36    break
37   endif
38  endfor
39 endif
40 exe "syn include @yaccCode ".s:Cpath
42 " ---------------------------------------------------------------------
43 "  Yacc Clusters: {{{1
44 syn cluster yaccInitCluster     contains=yaccKey,yaccKeyActn,yaccBrkt,yaccType,yaccString,yaccUnionStart,yaccHeader2,yaccComment,yaccDefines,yaccParseParam,yaccParseOption
45 syn cluster yaccRulesCluster    contains=yaccNonterminal,yaccString
47 " ---------------------------------------------------------------------
48 "  Yacc Sections: {{{1
49 SynFold 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
50 SynFold 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
51 SynFold syn     region  yaccHeader2     matchgroup=yaccSep      start="^\s*\zs%{"       end="^\s*%}"            contains=@yaccCode      nextgroup=yaccInit      skipwhite skipempty contained
52 SynFold syn     region  yaccHeader      matchgroup=yaccSep      start="^\s*\zs%{"       end="^\s*%}"            contains=@yaccCode      nextgroup=yaccInit      skipwhite skipempty
53 SynFold syn     region  yaccRules       matchgroup=yaccSectionSep       start='^%%$'            end='^%%$'me=e-2,re=e-2 contains=@yaccRulesCluster      nextgroup=yaccEndCode   skipwhite skipempty contained
54 SynFold syn     region  yaccEndCode     matchgroup=yaccSectionSep       start='^%%$'            end='\%$'               contains=@yaccCode      contained
56 " ---------------------------------------------------------------------
57 " Yacc Commands: {{{1
58 syn     match   yaccDefines     '^%define\s\+.*$'
59 syn     match   yaccParseParam  '%\(parse\|lex\)-param\>'               skipwhite       nextgroup=yaccParseParamStr
60 syn     match   yaccParseOption '%\%(api\.pure\|pure-parser\|locations\|error-verbose\)\>'
61 syn     region  yaccParseParamStr       contained matchgroup=Delimiter  start='{'       end='}' contains=cStructure
63 syn     match   yaccDelim       "[:|]"  contained
64 syn     match   yaccOper        "@\d\+" contained
66 syn     match   yaccKey "^\s*%\(token\|type\|left\|right\|start\|ident\|nonassoc\)\>"   contained
67 syn     match   yaccKey "\s%\(prec\|expect\)\>" contained
68 syn     match   yaccKey "\$\(<[a-zA-Z_][a-zA-Z_0-9]*>\)\=[\$0-9]\+"     contained
69 syn     keyword yaccKeyActn     yyerrok yyclearin       contained
71 syn     match   yaccUnionStart  "^%union"       skipwhite skipnl nextgroup=yaccUnion    contained
72 SynFold syn     region  yaccUnion       matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}" contains=@yaccCode  contained
73 syn     match   yaccBrkt        "[<>]"  contained
74 syn     match   yaccType        "<[a-zA-Z_][a-zA-Z0-9_]*>"      contains=yaccBrkt       contained
76 SynFold 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
77 syn     region  yaccComment     start="/\*"     end="\*/"
78 syn     match   yaccString      "'[^']*'"       contained
81 " ---------------------------------------------------------------------
82 " I'd really like to highlight just the outer {}.  Any suggestions??? {{{1
83 syn     match   yaccCurlyError  "[{}]"
84 SynFold syn     region  yaccAction      matchgroup=yaccCurly start="{" end="}"  contains=@yaccCode,yaccVar              contained
85 syn     match   yaccVar '\$\d\+\|\$\$\|\$<\I\i*>\$\|\$<\I\i*>\d\+'      containedin=cParen,cPreProc,cMulti      contained
87 " ---------------------------------------------------------------------
88 " Yacc synchronization: {{{1
89 syn sync fromstart
91 " ---------------------------------------------------------------------
92 " Define the default highlighting. {{{1
93 if !exists("did_yacc_syn_inits")
94   hi def link yaccBrkt  yaccStmt
95   hi def link yaccComment       Comment
96   hi def link yaccCurly Delimiter
97   hi def link yaccCurlyError    Error
98   hi def link yaccDefines       cDefine
99   hi def link yaccDelim Delimiter
100   hi def link yaccKeyActn       Special
101   hi def link yaccKey   yaccStmt
102   hi def link yaccNonterminal   Function
103   hi def link yaccOper  yaccStmt
104   hi def link yaccParseOption   cDefine
105   hi def link yaccParseParam    yaccParseOption
106   hi def link yaccSectionSep    Todo
107   hi def link yaccSep   Delimiter
108   hi def link yaccStmt  Statement
109   hi def link yaccString        String
110   hi def link yaccType  Type
111   hi def link yaccUnionStart    yaccKey
112   hi def link yaccVar   Special
113 endif
115 " ---------------------------------------------------------------------
116 "  Cleanup: {{{1
117 delcommand SynFold
118 let b:current_syntax = "yacc"
120 " ---------------------------------------------------------------------
121 "  Modelines: {{{1
122 " vim: ts=15 fdm=marker