0
0
mirror of https://github.com/vim/vim.git synced 2025-07-04 23:07:33 -04:00
vim/runtime/syntax/yacc.vim

125 lines
5.1 KiB
VimL
Raw Normal View History

2004-06-13 20:20:40 +00:00
" Vim syntax file
" Language: Yacc
2008-06-24 22:58:06 +00:00
" Maintainer: Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz>
2010-12-10 20:35:50 +01:00
" Last Change: Aug 12, 2010
" Version: 9
2005-09-06 19:25:11 +00:00
" URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax
2004-06-13 20:20:40 +00:00
"
2008-06-24 22:58:06 +00:00
" Options: {{{1
2006-02-23 21:32:16 +00:00
" g:yacc_uses_cpp : if this variable exists, then C++ is loaded rather than C
2004-06-13 20:20:40 +00:00
2008-06-24 22:58:06 +00:00
" ---------------------------------------------------------------------
2010-01-06 20:54:52 +01:00
" this version of syntax/yacc.vim requires 6.0 or later
2004-06-13 20:20:40 +00:00
if version < 600
2010-01-06 20:54:52 +01:00
finish
endif
if exists("b:current_syntax")
syntax clear
endif
" ---------------------------------------------------------------------
" Folding Support {{{1
if has("folding")
com! -nargs=+ HiFold <args> fold
else
com! -nargs=+ HiFold <args>
2004-06-13 20:20:40 +00:00
endif
2008-06-24 22:58:06 +00:00
" ---------------------------------------------------------------------
" Read the C syntax to start with {{{1
2010-01-06 20:54:52 +01:00
if exists("g:yacc_uses_cpp")
syn include @yaccCode <sfile>:p:h/cpp.vim
2004-06-13 20:20:40 +00:00
else
2010-01-06 20:54:52 +01:00
syn include @yaccCode <sfile>:p:h/c.vim
2004-06-13 20:20:40 +00:00
endif
2008-06-24 22:58:06 +00:00
" ---------------------------------------------------------------------
2010-01-06 20:54:52 +01:00
" Yacc Clusters: {{{1
2010-12-10 20:35:50 +01:00
syn cluster yaccInitCluster contains=yaccKey,yaccKeyActn,yaccBrkt,yaccType,yaccString,yaccUnionStart,yaccHeader2,yaccComment,yaccDefines,yaccParseParam,yaccParseOption
2010-01-06 20:54:52 +01:00
syn cluster yaccRulesCluster contains=yaccNonterminal,yaccString
2004-06-13 20:20:40 +00:00
2008-06-24 22:58:06 +00:00
" ---------------------------------------------------------------------
2010-01-06 20:54:52 +01:00
" Yacc Sections: {{{1
HiFold 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
HiFold 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
HiFold syn region yaccHeader2 matchgroup=yaccSep start="^\s*\zs%{" end="^\s*%}" contains=@yaccCode nextgroup=yaccInit skipwhite skipempty contained
HiFold syn region yaccHeader matchgroup=yaccSep start="^\s*\zs%{" end="^\s*%}" contains=@yaccCode nextgroup=yaccInit skipwhite skipempty
HiFold syn region yaccRules matchgroup=yaccSectionSep start='^%%$' end='^%%$'me=e-2,re=e-2 contains=@yaccRulesCluster nextgroup=yaccEndCode skipwhite skipempty contained
HiFold syn region yaccEndCode matchgroup=yaccSectionSep start='^%%$' end='\%$' contains=@yaccCode contained
2004-06-13 20:20:40 +00:00
2008-06-24 22:58:06 +00:00
" ---------------------------------------------------------------------
2010-01-06 20:54:52 +01:00
" Yacc Commands: {{{1
syn match yaccDefines '^%define\s\+.*$'
2010-12-10 20:35:50 +01:00
syn match yaccParseParam '%\(parse\|lex\)-param\>' skipwhite nextgroup=yaccParseParamStr
syn match yaccParseOption '%\%(api\.pure\|pure-parser\|locations\|error-verbose\)\>'
syn region yaccParseParamStr contained matchgroup=Delimiter start='{' end='}' contains=cStructure
2010-01-06 20:54:52 +01:00
syn match yaccDelim "[:|]" contained
syn match yaccOper "@\d\+" contained
syn match yaccKey "^\s*%\(token\|type\|left\|right\|start\|ident\|nonassoc\)\>" contained
syn match yaccKey "\s%\(prec\|expect\)\>" contained
syn match yaccKey "\$\(<[a-zA-Z_][a-zA-Z_0-9]*>\)\=[\$0-9]\+" contained
syn keyword yaccKeyActn yyerrok yyclearin contained
syn match yaccUnionStart "^%union" skipwhite skipnl nextgroup=yaccUnion contained
HiFold syn region yaccUnion matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}" contains=@yaccCode contained
syn match yaccBrkt "[<>]" contained
syn match yaccType "<[a-zA-Z_][a-zA-Z0-9_]*>" contains=yaccBrkt contained
HiFold 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
syn region yaccComment start="/\*" end="\*/"
syn match yaccString "'[^']*'" contained
2004-06-13 20:20:40 +00:00
2008-06-24 22:58:06 +00:00
" ---------------------------------------------------------------------
" I'd really like to highlight just the outer {}. Any suggestions??? {{{1
2010-01-06 20:54:52 +01:00
syn match yaccCurlyError "[{}]"
HiFold syn region yaccAction matchgroup=yaccCurly start="{" end="}" contains=@yaccCode contained
2004-06-13 20:20:40 +00:00
2008-06-24 22:58:06 +00:00
" ---------------------------------------------------------------------
" Yacc synchronization: {{{1
2010-01-06 20:54:52 +01:00
syn sync fromstart
2004-06-13 20:20:40 +00:00
2008-06-24 22:58:06 +00:00
" ---------------------------------------------------------------------
" Define the default highlighting. {{{1
2010-01-06 20:54:52 +01:00
if !exists("did_yacc_syn_inits")
command -nargs=+ HiLink hi def link <args>
2004-06-13 20:20:40 +00:00
2008-06-24 22:58:06 +00:00
" Internal yacc highlighting links {{{2
2004-06-13 20:20:40 +00:00
HiLink yaccBrkt yaccStmt
HiLink yaccKey yaccStmt
HiLink yaccOper yaccStmt
HiLink yaccUnionStart yaccKey
2008-06-24 22:58:06 +00:00
" External yacc highlighting links {{{2
2010-01-06 20:54:52 +01:00
HiLink yaccComment Comment
2004-06-13 20:20:40 +00:00
HiLink yaccCurly Delimiter
HiLink yaccCurlyError Error
HiLink yaccDefines cDefine
2010-12-10 20:35:50 +01:00
HiLink yaccParseParam yaccParseOption
HiLink yaccParseOption cDefine
2010-01-06 20:54:52 +01:00
HiLink yaccNonterminal Function
HiLink yaccDelim Delimiter
2004-06-13 20:20:40 +00:00
HiLink yaccKeyActn Special
HiLink yaccSectionSep Todo
HiLink yaccSep Delimiter
2010-01-06 20:54:52 +01:00
HiLink yaccString String
2004-06-13 20:20:40 +00:00
HiLink yaccStmt Statement
HiLink yaccType Type
2008-06-24 22:58:06 +00:00
" since Bram doesn't like my Delimiter :| {{{2
2004-06-13 20:20:40 +00:00
HiLink Delimiter Type
delcommand HiLink
endif
2010-01-06 20:54:52 +01:00
" ---------------------------------------------------------------------
" Cleanup: {{{1
delcommand HiFold
2004-06-13 20:20:40 +00:00
let b:current_syntax = "yacc"
2008-06-24 22:58:06 +00:00
" ---------------------------------------------------------------------
" Modelines: {{{1
" vim: ts=15 fdm=marker