3 " Maintainer: Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz>
4 " Last Change: Jan 09, 2008
6 " URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax
9 " g:yacc_uses_cpp : if this variable exists, then C++ is loaded rather than C
10 " g:yacc_minlines : see :help :he syn-sync-minlines -- default 50
11 " g:yacc_maxlines : see :help :he syn-sync-maxlines -- default 200
13 " ---------------------------------------------------------------------
14 " For version 5.x: Clear all syntax items {{{1
15 " For version 6.x: Quit when a syntax file was already loaded
18 elseif exists("b:current_syntax")
22 " ---------------------------------------------------------------------
23 " Read the C syntax to start with {{{1
25 if exists("g:yacc_uses_cpp")
26 runtime! syntax/cpp.vim
30 elseif exists("g:yacc_uses_cpp")
31 so <sfile>:p:h/cpp.vim
36 " ---------------------------------------------------------------------
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
41 " ---------------------------------------------------------------------
43 syn match yaccDelim "^\s*[:|;]"
44 syn match yaccOper "@\d\+"
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
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
56 syn match yaccDefinition "^[A-Za-z][A-Za-z0-9_]*\_s*:"
58 " ---------------------------------------------------------------------
59 " special Yacc separators {{{1
60 syn match yaccSectionSep "^[ \t]*%%"
61 syn match yaccSep "^[ \t]*%{"
62 syn match yaccSep "^[ \t]*%}"
64 " ---------------------------------------------------------------------
65 " I'd really like to highlight just the outer {}. Any suggestions??? {{{1
66 syn match yaccCurlyError "[{}]"
67 syn region yaccAction matchgroup=yaccCurly start="{" end="}" contains=ALLBUT,@yaccActionGroup
69 " ---------------------------------------------------------------------
70 " Yacc synchronization: {{{1
71 if exists("g:yacc_maxlines")
72 exe "syn sync maxlines=".g:yacc_maxlines
76 if exists("g:yacc_minlines")
77 exe "syn sync minlines=".g:yacc_minlines
82 " ---------------------------------------------------------------------
83 " Define the default highlighting. {{{1
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")
88 let did_yacchdl_syn_inits = 1
89 command -nargs=+ HiLink hi link <args>
91 command -nargs=+ HiLink hi def link <args>
94 " Internal yacc highlighting links {{{2
95 HiLink yaccBrkt yaccStmt
96 HiLink yaccKey yaccStmt
97 HiLink yaccOper yaccStmt
98 HiLink yaccUnionStart yaccKey
100 " External yacc highlighting links {{{2
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
111 " since Bram doesn't like my Delimiter :| {{{2
112 HiLink Delimiter Type
116 let b:current_syntax = "yacc"
118 " ---------------------------------------------------------------------
120 " vim: ts=15 fdm=marker