Mercurial > vim
annotate runtime/syntax/yacc.vim @ 2603:ac0458d9b9dd v7.3.026
updated for version 7.3.026
Problem: CTRL-] in a help file doesn't always work. (Tony Mechelynck)
Solution: Don't escape special characters. (Carlo Teubner)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 13 Oct 2010 18:06:47 +0200 |
parents | d55e70cabe2c |
children | 916c90b37ea9 |
rev | line source |
---|---|
7 | 1 " Vim syntax file |
2 " Language: Yacc | |
1624 | 3 " Maintainer: Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz> |
2473
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
4 " Last Change: Aug 2, 2010 |
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
5 " Version: 8 |
507 | 6 " URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax |
7 | 7 " |
1624 | 8 " Options: {{{1 |
683 | 9 " g:yacc_uses_cpp : if this variable exists, then C++ is loaded rather than C |
7 | 10 |
1624 | 11 " --------------------------------------------------------------------- |
2034 | 12 " this version of syntax/yacc.vim requires 6.0 or later |
7 | 13 if version < 600 |
2034 | 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> | |
7 | 26 endif |
27 | |
1624 | 28 " --------------------------------------------------------------------- |
29 " Read the C syntax to start with {{{1 | |
2034 | 30 if exists("g:yacc_uses_cpp") |
31 syn include @yaccCode <sfile>:p:h/cpp.vim | |
7 | 32 else |
2034 | 33 syn include @yaccCode <sfile>:p:h/c.vim |
7 | 34 endif |
35 | |
1624 | 36 " --------------------------------------------------------------------- |
2034 | 37 " Yacc Clusters: {{{1 |
2473
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
38 syn cluster yaccInitCluster contains=yaccKey,yaccKeyActn,yaccBrkt,yaccType,yaccString,yaccUnionStart,yaccHeader2,yaccComment,yaccDefines,yaccParseParam |
2034 | 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 | |
7 | 49 |
1624 | 50 " --------------------------------------------------------------------- |
2034 | 51 " Yacc Commands: {{{1 |
2473
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
52 syn match yaccDefines '^%define\s\+.*$' |
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
53 syn match yaccParseParam '%parse-param\>' skipwhite nextgroup=yaccParseParamStr |
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
54 syn region yaccParseParamStr contained matchgroup=Delimiter start='{' end='}' contains=cStructure |
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
55 |
2034 | 56 syn match yaccDelim "[:|]" contained |
57 syn match yaccOper "@\d\+" contained | |
7 | 58 |
2034 | 59 syn match yaccKey "^\s*%\(token\|type\|left\|right\|start\|ident\|nonassoc\)\>" contained |
60 syn match yaccKey "\s%\(prec\|expect\)\>" contained | |
61 syn match yaccKey "\$\(<[a-zA-Z_][a-zA-Z_0-9]*>\)\=[\$0-9]\+" contained | |
62 syn keyword yaccKeyActn yyerrok yyclearin contained | |
7 | 63 |
2034 | 64 syn match yaccUnionStart "^%union" skipwhite skipnl nextgroup=yaccUnion contained |
65 HiFold syn region yaccUnion matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}" contains=@yaccCode contained | |
66 syn match yaccBrkt "[<>]" contained | |
67 syn match yaccType "<[a-zA-Z_][a-zA-Z0-9_]*>" contains=yaccBrkt contained | |
7 | 68 |
2034 | 69 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 |
70 syn region yaccComment start="/\*" end="\*/" | |
71 syn match yaccString "'[^']*'" contained | |
72 | |
7 | 73 |
1624 | 74 " --------------------------------------------------------------------- |
75 " I'd really like to highlight just the outer {}. Any suggestions??? {{{1 | |
2034 | 76 syn match yaccCurlyError "[{}]" |
77 HiFold syn region yaccAction matchgroup=yaccCurly start="{" end="}" contains=@yaccCode contained | |
7 | 78 |
1624 | 79 " --------------------------------------------------------------------- |
80 " Yacc synchronization: {{{1 | |
2034 | 81 syn sync fromstart |
7 | 82 |
1624 | 83 " --------------------------------------------------------------------- |
84 " Define the default highlighting. {{{1 | |
2034 | 85 if !exists("did_yacc_syn_inits") |
86 command -nargs=+ HiLink hi def link <args> | |
7 | 87 |
1624 | 88 " Internal yacc highlighting links {{{2 |
7 | 89 HiLink yaccBrkt yaccStmt |
90 HiLink yaccKey yaccStmt | |
91 HiLink yaccOper yaccStmt | |
92 HiLink yaccUnionStart yaccKey | |
93 | |
1624 | 94 " External yacc highlighting links {{{2 |
2034 | 95 HiLink yaccComment Comment |
7 | 96 HiLink yaccCurly Delimiter |
97 HiLink yaccCurlyError Error | |
2473
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
98 HiLink yaccDefines cDefine |
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
99 HiLink yaccParseParam cDefine |
2034 | 100 HiLink yaccNonterminal Function |
101 HiLink yaccDelim Delimiter | |
7 | 102 HiLink yaccKeyActn Special |
103 HiLink yaccSectionSep Todo | |
104 HiLink yaccSep Delimiter | |
2034 | 105 HiLink yaccString String |
7 | 106 HiLink yaccStmt Statement |
107 HiLink yaccType Type | |
108 | |
1624 | 109 " since Bram doesn't like my Delimiter :| {{{2 |
7 | 110 HiLink Delimiter Type |
111 | |
112 delcommand HiLink | |
113 endif | |
2034 | 114 |
115 " --------------------------------------------------------------------- | |
116 " Cleanup: {{{1 | |
117 delcommand HiFold | |
7 | 118 let b:current_syntax = "yacc" |
119 | |
1624 | 120 " --------------------------------------------------------------------- |
121 " Modelines: {{{1 | |
122 " vim: ts=15 fdm=marker |