codekingpro/portable-devtools
114k
1" Vim syntax file2" Language: Yacc3" Former Maintainer: Charles E. Campbell4" Last Change: Mar 25, 20195" Version: 176" 2024 Feb 19 by Vim Project (announce adoption)7" Former URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_YACC8"9" Options: {{{110" g:yacc_uses_cpp : if this variable exists, then C++ is loaded rather than C11 12" ---------------------------------------------------------------------13" this version of syntax/yacc.vim requires 6.0 or later14if exists("b:current_syntax")15 syntax clear16endif17 18" ---------------------------------------------------------------------19" Folding Support {{{120if has("folding")21 com! -nargs=+ SynFold <args> fold22else23 com! -nargs=+ SynFold <args>24endif25 26" ---------------------------------------------------------------------27" Read the C syntax to start with {{{128" Read the C/C++ syntax to start with29let s:Cpath= fnameescape(expand("<sfile>:p:h").(exists("g:yacc_uses_cpp")? "/cpp.vim" : "/c.vim"))30if !filereadable(s:Cpath)31 for s:Cpath in split(globpath(&rtp,(exists("g:yacc_uses_cpp")? "syntax/cpp.vim" : "syntax/c.vim")),"\n")32 if filereadable(fnameescape(s:Cpath))33 let s:Cpath= fnameescape(s:Cpath)34 break35 endif36 endfor37endif38exe "syn include @yaccCode ".s:Cpath39 40" ---------------------------------------------------------------------41" Yacc Clusters: {{{142syn cluster yaccInitCluster contains=yaccKey,yaccKeyActn,yaccBrkt,yaccType,yaccString,yaccUnionStart,yaccHeader2,yaccComment,yaccDefines,yaccParseParam,yaccParseOption43syn cluster yaccRulesCluster contains=yaccNonterminal,yaccString,yaccComment44 45" ---------------------------------------------------------------------46" Yacc Sections: {{{147SynFold syn region yaccInit start='.'ms=s-1,rs=s-1 matchgroup=yaccSectionSep end='^%%\ze\(\s*/[*/].*\)\=$'me=e-2,re=e-2 contains=@yaccInitCluster nextgroup=yaccRules skipwhite skipempty contained48SynFold syn region yaccInit2 start='\%^.'ms=s-1,rs=s-1 matchgroup=yaccSectionSep end='^%%\ze\(\s*/[*/].*\)\=$'me=e-2,re=e-2 contains=@yaccInitCluster nextgroup=yaccRules skipwhite skipempty49SynFold syn region yaccHeader2 matchgroup=yaccSep start="^\s*\zs%{" end="^\s*%}" contains=@yaccCode nextgroup=yaccInit skipwhite skipempty contained50SynFold syn region yaccHeader matchgroup=yaccSep start="^\s*\zs%{" end="^\s*%}" contains=@yaccCode nextgroup=yaccInit skipwhite skipempty51SynFold syn region yaccRules matchgroup=yaccSectionSep start='^%%\ze\(\s*/[*/].*\)\=$' end='^%%\ze\(\s*/[*/].*\)\=$'me=e-2,re=e-2 contains=@yaccRulesCluster nextgroup=yaccEndCode skipwhite skipempty contained52SynFold syn region yaccEndCode matchgroup=yaccSectionSep start='^%%\ze\(\s*/[*/].*\)\=$' end='\%$' contains=@yaccCode contained53 54" ---------------------------------------------------------------------55" Yacc Commands: {{{156syn match yaccDefines '^%define\s\+.*$'57syn match yaccParseParam '%\(parse\|lex\)-param\>' skipwhite nextgroup=yaccParseParamStr58syn match yaccParseOption '%\%(api\.pure\|pure-parser\|locations\|error-verbose\)\>'59syn region yaccParseParamStr contained matchgroup=Delimiter start='{' end='}' contains=cStructure60 61syn match yaccDelim "[:|]" contained62syn match yaccOper "@\d\+" contained63 64syn match yaccKey "^\s*%\(token\|type\|left\|right\|start\|ident\|nonassoc\)\>" contained65syn match yaccKey "\s%\(prec\|expect\)\>" contained66syn match yaccKey "\$\(<[a-zA-Z_][a-zA-Z_0-9]*>\)\=[\$0-9]\+" contained67syn keyword yaccKeyActn yyerrok yyclearin contained68 69syn match yaccUnionStart "^%union" skipwhite skipnl nextgroup=yaccUnion contained70SynFold syn region yaccUnion matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}" contains=@yaccCode contained71syn match yaccBrkt "[<>]" contained72syn match yaccType "<[a-zA-Z_][a-zA-Z0-9_]*>" contains=yaccBrkt contained73 74SynFold 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 contained75syn region yaccComment start="/\*" end="\*/"76syn region yaccComment start="//" end="$"77syn match yaccString "'[^']*'" contained78 79 80" ---------------------------------------------------------------------81" I'd really like to highlight just the outer {}. Any suggestions??? {{{182syn match yaccCurlyError "[{}]"83SynFold syn region yaccAction matchgroup=yaccCurly start="{" end="}" contains=@yaccCode,yaccVar contained84syn match yaccVar '\$\d\+\|\$\$\|\$<\I\i*>\$\|\$<\I\i*>\d\+' containedin=cParen,cPreProc,cMulti contained85 86" ---------------------------------------------------------------------87" Yacc synchronization: {{{188syn sync fromstart89 90" ---------------------------------------------------------------------91" Define the default highlighting. {{{192if !exists("skip_yacc_syn_inits")93 hi def link yaccBrkt yaccStmt94 hi def link yaccComment Comment95 hi def link yaccCurly Delimiter96 hi def link yaccCurlyError Error97 hi def link yaccDefines cDefine98 hi def link yaccDelim Delimiter99 hi def link yaccKeyActn Special100 hi def link yaccKey yaccStmt101 hi def link yaccNonterminal Function102 hi def link yaccOper yaccStmt103 hi def link yaccParseOption cDefine104 hi def link yaccParseParam yaccParseOption105 hi def link yaccSectionSep Todo106 hi def link yaccSep Delimiter107 hi def link yaccStmt Statement108 hi def link yaccString String109 hi def link yaccType Type110 hi def link yaccUnionStart yaccKey111 hi def link yaccVar Special112endif113 114" ---------------------------------------------------------------------115" Cleanup: {{{1116delcommand SynFold117let b:current_syntax = "yacc"118 119" ---------------------------------------------------------------------120" Modelines: {{{1121" vim: ts=15 fdm=marker122 