3 " Maintainer: Dr. Charles E. Campbell, Jr. <Charles.E.Campbell.1@gsfc.nasa.gov>
4 " Last Change: March 1, 2001
6 " yacc_uses_cpp : if this variable exists, then C++ is loaded rather than C
8 " For version 5.x: Clear all syntax items
9 " For version 6.x: Quit when a syntax file was already loaded
12 elseif exists("b:current_syntax")
16 " Read the C syntax to start with
18 if exists("yacc_uses_cpp")
19 runtime! syntax/cpp.vim
23 elseif exists("yacc_uses_cpp")
24 so <sfile>:p:h/cpp.vim
30 syn cluster yaccActionGroup contains=yaccDelim,cInParen,cTodo,cIncluded,yaccDelim,yaccCurlyError,yaccUnionCurly,yaccUnion,cUserLabel,cOctalZero,cCppOut2,cCppSkip,cErrInBracket,cErrInParen,cOctalError,cCommentStartError,cParenError
31 syn cluster yaccUnionGroup contains=yaccKey,cComment,yaccCurly,cType,cStructure,cStorageClass,yaccUnionCurly
34 syn match yaccDelim "^\s*[:|;]"
35 syn match yaccOper "@\d\+"
37 syn match yaccKey "^\s*%\(token\|type\|left\|right\|start\|ident\|nonassoc\)\>"
38 syn match yaccKey "\s%\(prec\|expect\)\>"
39 syn match yaccKey "\$\(<[a-zA-Z_][a-zA-Z_0-9]*>\)\=[\$0-9]\+"
40 syn keyword yaccKeyActn yyerrok yyclearin
42 syn match yaccUnionStart "^%union" skipwhite skipnl nextgroup=yaccUnion
43 syn region yaccUnion contained matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}" contains=@yaccUnionGroup
44 syn region yaccUnionCurly contained matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}" contains=@yaccUnionGroup
45 syn match yaccBrkt contained "[<>]"
46 syn match yaccType "<[a-zA-Z_][a-zA-Z0-9_]*>" contains=yaccBrkt
47 syn match yaccDefinition "^[A-Za-z][A-Za-z0-9_]*[ \t]*:"
49 " special Yacc separators
50 syn match yaccSectionSep "^[ \t]*%%"
51 syn match yaccSep "^[ \t]*%{"
52 syn match yaccSep "^[ \t]*%}"
54 " I'd really like to highlight just the outer {}. Any suggestions???
55 syn match yaccCurlyError "[{}]"
56 syn region yaccAction matchgroup=yaccCurly start="{" end="}" contains=ALLBUT,@yaccActionGroup
59 " Define the default highlighting.
60 " For version 5.7 and earlier: only when not done already
61 " For version 5.8 and later: only when an item doesn't have highlighting yet
62 if version >= 508 || !exists("did_yacc_syn_inits")
64 let did_yacchdl_syn_inits = 1
65 command -nargs=+ HiLink hi link <args>
67 command -nargs=+ HiLink hi def link <args>
70 " Internal yacc highlighting links
71 HiLink yaccBrkt yaccStmt
72 HiLink yaccKey yaccStmt
73 HiLink yaccOper yaccStmt
74 HiLink yaccUnionStart yaccKey
76 " External yacc highlighting links
77 HiLink yaccCurly Delimiter
78 HiLink yaccCurlyError Error
79 HiLink yaccDefinition Function
80 HiLink yaccDelim Function
81 HiLink yaccKeyActn Special
82 HiLink yaccSectionSep Todo
83 HiLink yaccSep Delimiter
84 HiLink yaccStmt Statement
87 " since Bram doesn't like my Delimiter :|
93 let b:current_syntax = "yacc"