7
|
1 " Vim syntax file
|
|
2 " Language: Yacc
|
1624
|
3 " Maintainer: Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz>
|
|
4 " Last Change: Jan 09, 2008
|
|
5 " Version: 5
|
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
|
1624
|
10 " g:yacc_minlines : see :help :he syn-sync-minlines -- default 50
|
|
11 " g:yacc_maxlines : see :help :he syn-sync-maxlines -- default 200
|
7
|
12
|
1624
|
13 " ---------------------------------------------------------------------
|
|
14 " For version 5.x: Clear all syntax items {{{1
|
7
|
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
|
|
21
|
1624
|
22 " ---------------------------------------------------------------------
|
|
23 " Read the C syntax to start with {{{1
|
7
|
24 if version >= 600
|
683
|
25 if exists("g:yacc_uses_cpp")
|
7
|
26 runtime! syntax/cpp.vim
|
|
27 else
|
|
28 runtime! syntax/c.vim
|
|
29 endif
|
683
|
30 elseif exists("g:yacc_uses_cpp")
|
7
|
31 so <sfile>:p:h/cpp.vim
|
|
32 else
|
|
33 so <sfile>:p:h/c.vim
|
|
34 endif
|
|
35
|
1624
|
36 " ---------------------------------------------------------------------
|
|
37 " Clusters {{{1
|
7
|
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
|
|
40
|
1624
|
41 " ---------------------------------------------------------------------
|
|
42 " Yacc stuff {{{1
|
7
|
43 syn match yaccDelim "^\s*[:|;]"
|
|
44 syn match yaccOper "@\d\+"
|
|
45
|
|
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
|
|
50
|
|
51 syn match yaccUnionStart "^%union" skipwhite skipnl nextgroup=yaccUnion
|
|
52 syn region yaccUnion contained matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}" contains=@yaccUnionGroup
|
|
53 syn region yaccUnionCurly contained matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}" contains=@yaccUnionGroup
|
|
54 syn match yaccBrkt contained "[<>]"
|
|
55 syn match yaccType "<[a-zA-Z_][a-zA-Z0-9_]*>" contains=yaccBrkt
|
683
|
56 syn match yaccDefinition "^[A-Za-z][A-Za-z0-9_]*\_s*:"
|
7
|
57
|
1624
|
58 " ---------------------------------------------------------------------
|
|
59 " special Yacc separators {{{1
|
7
|
60 syn match yaccSectionSep "^[ \t]*%%"
|
|
61 syn match yaccSep "^[ \t]*%{"
|
|
62 syn match yaccSep "^[ \t]*%}"
|
|
63
|
1624
|
64 " ---------------------------------------------------------------------
|
|
65 " I'd really like to highlight just the outer {}. Any suggestions??? {{{1
|
7
|
66 syn match yaccCurlyError "[{}]"
|
|
67 syn region yaccAction matchgroup=yaccCurly start="{" end="}" contains=ALLBUT,@yaccActionGroup
|
|
68
|
1624
|
69 " ---------------------------------------------------------------------
|
|
70 " Yacc synchronization: {{{1
|
|
71 if exists("g:yacc_maxlines")
|
|
72 exe "syn sync maxlines=".g:yacc_maxlines
|
|
73 else
|
|
74 syn sync maxlines=200
|
|
75 endif
|
|
76 if exists("g:yacc_minlines")
|
|
77 exe "syn sync minlines=".g:yacc_minlines
|
|
78 else
|
|
79 syn sync minlines=50
|
|
80 endif
|
7
|
81
|
1624
|
82 " ---------------------------------------------------------------------
|
|
83 " Define the default highlighting. {{{1
|
7
|
84 " For version 5.7 and earlier: only when not done already
|
|
85 " For version 5.8 and later: only when an item doesn't have highlighting yet
|
|
86 if version >= 508 || !exists("did_yacc_syn_inits")
|
|
87 if version < 508
|
|
88 let did_yacchdl_syn_inits = 1
|
|
89 command -nargs=+ HiLink hi link <args>
|
|
90 else
|
|
91 command -nargs=+ HiLink hi def link <args>
|
|
92 endif
|
|
93
|
1624
|
94 " Internal yacc highlighting links {{{2
|
7
|
95 HiLink yaccBrkt yaccStmt
|
|
96 HiLink yaccKey yaccStmt
|
|
97 HiLink yaccOper yaccStmt
|
|
98 HiLink yaccUnionStart yaccKey
|
|
99
|
1624
|
100 " External yacc highlighting links {{{2
|
7
|
101 HiLink yaccCurly Delimiter
|
|
102 HiLink yaccCurlyError Error
|
|
103 HiLink yaccDefinition Function
|
|
104 HiLink yaccDelim Function
|
|
105 HiLink yaccKeyActn Special
|
|
106 HiLink yaccSectionSep Todo
|
|
107 HiLink yaccSep Delimiter
|
|
108 HiLink yaccStmt Statement
|
|
109 HiLink yaccType Type
|
|
110
|
1624
|
111 " since Bram doesn't like my Delimiter :| {{{2
|
7
|
112 HiLink Delimiter Type
|
|
113
|
|
114 delcommand HiLink
|
|
115 endif
|
|
116 let b:current_syntax = "yacc"
|
|
117
|
1624
|
118 " ---------------------------------------------------------------------
|
|
119 " Modelines: {{{1
|
|
120 " vim: ts=15 fdm=marker
|