Mercurial > vim
annotate runtime/syntax/yacc.vim @ 7147:c590de398af9
commit https://github.com/vim/vim/commit/ca63501fbcd1cf9c8aa9ff12c093c95b62a89ed7
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Sep 25 20:34:21 2015 +0200
Update various runtime files.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 25 Sep 2015 20:45:09 +0200 |
parents | dff4e29c6905 |
children | 43efa4f5a8ea |
rev | line source |
---|---|
7 | 1 " Vim syntax file |
2 " Language: Yacc | |
3920 | 3 " Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz> |
6744 | 4 " Last Change: Apr 02, 2015 |
5 " Version: 13 | |
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") | |
3920 | 23 com! -nargs=+ SynFold <args> fold |
2034 | 24 else |
3920 | 25 com! -nargs=+ SynFold <args> |
7 | 26 endif |
27 | |
1624 | 28 " --------------------------------------------------------------------- |
29 " Read the C syntax to start with {{{1 | |
3920 | 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 | |
7 | 39 endif |
3920 | 40 exe "syn include @yaccCode ".s:Cpath |
7 | 41 |
1624 | 42 " --------------------------------------------------------------------- |
2034 | 43 " Yacc Clusters: {{{1 |
2662 | 44 syn cluster yaccInitCluster contains=yaccKey,yaccKeyActn,yaccBrkt,yaccType,yaccString,yaccUnionStart,yaccHeader2,yaccComment,yaccDefines,yaccParseParam,yaccParseOption |
6484 | 45 syn cluster yaccRulesCluster contains=yaccNonterminal,yaccString,yaccComment |
2034 | 46 |
47 " --------------------------------------------------------------------- | |
48 " Yacc Sections: {{{1 | |
3920 | 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 | |
7 | 55 |
1624 | 56 " --------------------------------------------------------------------- |
2034 | 57 " Yacc Commands: {{{1 |
2473
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
58 syn match yaccDefines '^%define\s\+.*$' |
2662 | 59 syn match yaccParseParam '%\(parse\|lex\)-param\>' skipwhite nextgroup=yaccParseParamStr |
60 syn match yaccParseOption '%\%(api\.pure\|pure-parser\|locations\|error-verbose\)\>' | |
2473
d55e70cabe2c
Syntax file updates. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
61 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
|
62 |
2034 | 63 syn match yaccDelim "[:|]" contained |
64 syn match yaccOper "@\d\+" contained | |
7 | 65 |
2034 | 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 | |
7 | 70 |
2034 | 71 syn match yaccUnionStart "^%union" skipwhite skipnl nextgroup=yaccUnion contained |
3920 | 72 SynFold syn region yaccUnion matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}" contains=@yaccCode contained |
2034 | 73 syn match yaccBrkt "[<>]" contained |
74 syn match yaccType "<[a-zA-Z_][a-zA-Z0-9_]*>" contains=yaccBrkt contained | |
7 | 75 |
3920 | 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 |
2034 | 77 syn region yaccComment start="/\*" end="\*/" |
78 syn match yaccString "'[^']*'" contained | |
79 | |
7 | 80 |
1624 | 81 " --------------------------------------------------------------------- |
82 " I'd really like to highlight just the outer {}. Any suggestions??? {{{1 | |
2034 | 83 syn match yaccCurlyError "[{}]" |
3920 | 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 | |
7 | 86 |
1624 | 87 " --------------------------------------------------------------------- |
88 " Yacc synchronization: {{{1 | |
2034 | 89 syn sync fromstart |
7 | 90 |
1624 | 91 " --------------------------------------------------------------------- |
92 " Define the default highlighting. {{{1 | |
2034 | 93 if !exists("did_yacc_syn_inits") |
3920 | 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 | |
7 | 113 endif |
2034 | 114 |
115 " --------------------------------------------------------------------- | |
116 " Cleanup: {{{1 | |
3920 | 117 delcommand SynFold |
7 | 118 let b:current_syntax = "yacc" |
119 | |
1624 | 120 " --------------------------------------------------------------------- |
121 " Modelines: {{{1 | |
122 " vim: ts=15 fdm=marker |