Mercurial > vim
comparison runtime/syntax/yacc.vim @ 3920:c53344bacabf
Updated runtime files.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Thu, 15 Nov 2012 21:28:22 +0100 |
parents | 887d6d91882e |
children | 657ade71d395 |
comparison
equal
deleted
inserted
replaced
3919:23fc3dc4317e | 3920:c53344bacabf |
---|---|
1 " Vim syntax file | 1 " Vim syntax file |
2 " Language: Yacc | 2 " Language: Yacc |
3 " Maintainer: Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz> | 3 " Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz> |
4 " Last Change: Aug 12, 2010 | 4 " Last Change: Nov 14, 2012 |
5 " Version: 9 | 5 " Version: 10 |
6 " URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax | 6 " URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax |
7 " | 7 " |
8 " Options: {{{1 | 8 " Options: {{{1 |
9 " g:yacc_uses_cpp : if this variable exists, then C++ is loaded rather than C | 9 " g:yacc_uses_cpp : if this variable exists, then C++ is loaded rather than C |
10 | 10 |
18 endif | 18 endif |
19 | 19 |
20 " --------------------------------------------------------------------- | 20 " --------------------------------------------------------------------- |
21 " Folding Support {{{1 | 21 " Folding Support {{{1 |
22 if has("folding") | 22 if has("folding") |
23 com! -nargs=+ HiFold <args> fold | 23 com! -nargs=+ SynFold <args> fold |
24 else | 24 else |
25 com! -nargs=+ HiFold <args> | 25 com! -nargs=+ SynFold <args> |
26 endif | 26 endif |
27 | 27 |
28 " --------------------------------------------------------------------- | 28 " --------------------------------------------------------------------- |
29 " Read the C syntax to start with {{{1 | 29 " Read the C syntax to start with {{{1 |
30 if exists("g:yacc_uses_cpp") | 30 " Read the C/C++ syntax to start with |
31 syn include @yaccCode <sfile>:p:h/cpp.vim | 31 let s:Cpath= fnameescape(expand("<sfile>:p:h").(exists("g:yacc_uses_cpp")? "/cpp.vim" : "/c.vim")) |
32 else | 32 if !filereadable(s:Cpath) |
33 syn include @yaccCode <sfile>:p:h/c.vim | 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 | |
34 endif | 39 endif |
40 exe "syn include @yaccCode ".s:Cpath | |
35 | 41 |
36 " --------------------------------------------------------------------- | 42 " --------------------------------------------------------------------- |
37 " Yacc Clusters: {{{1 | 43 " Yacc Clusters: {{{1 |
38 syn cluster yaccInitCluster contains=yaccKey,yaccKeyActn,yaccBrkt,yaccType,yaccString,yaccUnionStart,yaccHeader2,yaccComment,yaccDefines,yaccParseParam,yaccParseOption | 44 syn cluster yaccInitCluster contains=yaccKey,yaccKeyActn,yaccBrkt,yaccType,yaccString,yaccUnionStart,yaccHeader2,yaccComment,yaccDefines,yaccParseParam,yaccParseOption |
39 syn cluster yaccRulesCluster contains=yaccNonterminal,yaccString | 45 syn cluster yaccRulesCluster contains=yaccNonterminal,yaccString |
40 | 46 |
41 " --------------------------------------------------------------------- | 47 " --------------------------------------------------------------------- |
42 " Yacc Sections: {{{1 | 48 " 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 | 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 |
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 | 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 |
45 HiFold syn region yaccHeader2 matchgroup=yaccSep start="^\s*\zs%{" end="^\s*%}" contains=@yaccCode nextgroup=yaccInit skipwhite skipempty contained | 51 SynFold 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 | 52 SynFold 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 | 53 SynFold 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 | 54 SynFold syn region yaccEndCode matchgroup=yaccSectionSep start='^%%$' end='\%$' contains=@yaccCode contained |
49 | 55 |
50 " --------------------------------------------------------------------- | 56 " --------------------------------------------------------------------- |
51 " Yacc Commands: {{{1 | 57 " Yacc Commands: {{{1 |
52 syn match yaccDefines '^%define\s\+.*$' | 58 syn match yaccDefines '^%define\s\+.*$' |
53 syn match yaccParseParam '%\(parse\|lex\)-param\>' skipwhite nextgroup=yaccParseParamStr | 59 syn match yaccParseParam '%\(parse\|lex\)-param\>' skipwhite nextgroup=yaccParseParamStr |
61 syn match yaccKey "\s%\(prec\|expect\)\>" contained | 67 syn match yaccKey "\s%\(prec\|expect\)\>" contained |
62 syn match yaccKey "\$\(<[a-zA-Z_][a-zA-Z_0-9]*>\)\=[\$0-9]\+" contained | 68 syn match yaccKey "\$\(<[a-zA-Z_][a-zA-Z_0-9]*>\)\=[\$0-9]\+" contained |
63 syn keyword yaccKeyActn yyerrok yyclearin contained | 69 syn keyword yaccKeyActn yyerrok yyclearin contained |
64 | 70 |
65 syn match yaccUnionStart "^%union" skipwhite skipnl nextgroup=yaccUnion contained | 71 syn match yaccUnionStart "^%union" skipwhite skipnl nextgroup=yaccUnion contained |
66 HiFold syn region yaccUnion matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}" contains=@yaccCode contained | 72 SynFold syn region yaccUnion matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}" contains=@yaccCode contained |
67 syn match yaccBrkt "[<>]" contained | 73 syn match yaccBrkt "[<>]" contained |
68 syn match yaccType "<[a-zA-Z_][a-zA-Z0-9_]*>" contains=yaccBrkt contained | 74 syn match yaccType "<[a-zA-Z_][a-zA-Z0-9_]*>" contains=yaccBrkt contained |
69 | 75 |
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 | 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 |
71 syn region yaccComment start="/\*" end="\*/" | 77 syn region yaccComment start="/\*" end="\*/" |
72 syn match yaccString "'[^']*'" contained | 78 syn match yaccString "'[^']*'" contained |
73 | 79 |
74 | 80 |
75 " --------------------------------------------------------------------- | 81 " --------------------------------------------------------------------- |
76 " I'd really like to highlight just the outer {}. Any suggestions??? {{{1 | 82 " I'd really like to highlight just the outer {}. Any suggestions??? {{{1 |
77 syn match yaccCurlyError "[{}]" | 83 syn match yaccCurlyError "[{}]" |
78 HiFold syn region yaccAction matchgroup=yaccCurly start="{" end="}" contains=@yaccCode contained | 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 | |
79 | 86 |
80 " --------------------------------------------------------------------- | 87 " --------------------------------------------------------------------- |
81 " Yacc synchronization: {{{1 | 88 " Yacc synchronization: {{{1 |
82 syn sync fromstart | 89 syn sync fromstart |
83 | 90 |
84 " --------------------------------------------------------------------- | 91 " --------------------------------------------------------------------- |
85 " Define the default highlighting. {{{1 | 92 " Define the default highlighting. {{{1 |
86 if !exists("did_yacc_syn_inits") | 93 if !exists("did_yacc_syn_inits") |
87 command -nargs=+ HiLink hi def link <args> | 94 hi def link yaccBrkt yaccStmt |
88 | 95 hi def link yaccComment Comment |
89 " Internal yacc highlighting links {{{2 | 96 hi def link yaccCurly Delimiter |
90 HiLink yaccBrkt yaccStmt | 97 hi def link yaccCurlyError Error |
91 HiLink yaccKey yaccStmt | 98 hi def link yaccDefines cDefine |
92 HiLink yaccOper yaccStmt | 99 hi def link yaccDelim Delimiter |
93 HiLink yaccUnionStart yaccKey | 100 hi def link yaccKeyActn Special |
94 | 101 hi def link yaccKey yaccStmt |
95 " External yacc highlighting links {{{2 | 102 hi def link yaccNonterminal Function |
96 HiLink yaccComment Comment | 103 hi def link yaccOper yaccStmt |
97 HiLink yaccCurly Delimiter | 104 hi def link yaccParseOption cDefine |
98 HiLink yaccCurlyError Error | 105 hi def link yaccParseParam yaccParseOption |
99 HiLink yaccDefines cDefine | 106 hi def link yaccSectionSep Todo |
100 HiLink yaccParseParam yaccParseOption | 107 hi def link yaccSep Delimiter |
101 HiLink yaccParseOption cDefine | 108 hi def link yaccStmt Statement |
102 HiLink yaccNonterminal Function | 109 hi def link yaccString String |
103 HiLink yaccDelim Delimiter | 110 hi def link yaccType Type |
104 HiLink yaccKeyActn Special | 111 hi def link yaccUnionStart yaccKey |
105 HiLink yaccSectionSep Todo | 112 hi def link yaccVar Special |
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 | 113 endif |
116 | 114 |
117 " --------------------------------------------------------------------- | 115 " --------------------------------------------------------------------- |
118 " Cleanup: {{{1 | 116 " Cleanup: {{{1 |
119 delcommand HiFold | 117 delcommand SynFold |
120 let b:current_syntax = "yacc" | 118 let b:current_syntax = "yacc" |
121 | 119 |
122 " --------------------------------------------------------------------- | 120 " --------------------------------------------------------------------- |
123 " Modelines: {{{1 | 121 " Modelines: {{{1 |
124 " vim: ts=15 fdm=marker | 122 " vim: ts=15 fdm=marker |