0
0
mirror of https://github.com/vim/vim.git synced 2025-07-24 10:45:12 -04:00
vim/runtime/syntax/yacc.vim

121 lines
4.2 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>
" Last Change: Jan 09, 2008
" Version: 5
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
2008-06-24 22:58:06 +00:00
" g:yacc_minlines : see :help :he syn-sync-minlines -- default 50
" g:yacc_maxlines : see :help :he syn-sync-maxlines -- default 200
2004-06-13 20:20:40 +00:00
2008-06-24 22:58:06 +00:00
" ---------------------------------------------------------------------
" For version 5.x: Clear all syntax items {{{1
2004-06-13 20:20:40 +00:00
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
2008-06-24 22:58:06 +00:00
" ---------------------------------------------------------------------
" Read the C syntax to start with {{{1
2004-06-13 20:20:40 +00:00
if version >= 600
2006-02-23 21:32:16 +00:00
if exists("g:yacc_uses_cpp")
2004-06-13 20:20:40 +00:00
runtime! syntax/cpp.vim
else
runtime! syntax/c.vim
endif
2006-02-23 21:32:16 +00:00
elseif exists("g:yacc_uses_cpp")
2004-06-13 20:20:40 +00:00
so <sfile>:p:h/cpp.vim
else
so <sfile>:p:h/c.vim
endif
2008-06-24 22:58:06 +00:00
" ---------------------------------------------------------------------
" Clusters {{{1
2004-06-13 20:20:40 +00:00
syn cluster yaccActionGroup contains=yaccDelim,cInParen,cTodo,cIncluded,yaccDelim,yaccCurlyError,yaccUnionCurly,yaccUnion,cUserLabel,cOctalZero,cCppOut2,cCppSkip,cErrInBracket,cErrInParen,cOctalError,cCommentStartError,cParenError
syn cluster yaccUnionGroup contains=yaccKey,cComment,yaccCurly,cType,cStructure,cStorageClass,yaccUnionCurly
2008-06-24 22:58:06 +00:00
" ---------------------------------------------------------------------
" Yacc stuff {{{1
2004-06-13 20:20:40 +00:00
syn match yaccDelim "^\s*[:|;]"
syn match yaccOper "@\d\+"
syn match yaccKey "^\s*%\(token\|type\|left\|right\|start\|ident\|nonassoc\)\>"
syn match yaccKey "\s%\(prec\|expect\)\>"
syn match yaccKey "\$\(<[a-zA-Z_][a-zA-Z_0-9]*>\)\=[\$0-9]\+"
syn keyword yaccKeyActn yyerrok yyclearin
syn match yaccUnionStart "^%union" skipwhite skipnl nextgroup=yaccUnion
syn region yaccUnion contained matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}" contains=@yaccUnionGroup
syn region yaccUnionCurly contained matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}" contains=@yaccUnionGroup
syn match yaccBrkt contained "[<>]"
syn match yaccType "<[a-zA-Z_][a-zA-Z0-9_]*>" contains=yaccBrkt
2006-02-23 21:32:16 +00:00
syn match yaccDefinition "^[A-Za-z][A-Za-z0-9_]*\_s*:"
2004-06-13 20:20:40 +00:00
2008-06-24 22:58:06 +00:00
" ---------------------------------------------------------------------
" special Yacc separators {{{1
2004-06-13 20:20:40 +00:00
syn match yaccSectionSep "^[ \t]*%%"
syn match yaccSep "^[ \t]*%{"
syn match yaccSep "^[ \t]*%}"
2008-06-24 22:58:06 +00:00
" ---------------------------------------------------------------------
" I'd really like to highlight just the outer {}. Any suggestions??? {{{1
2004-06-13 20:20:40 +00:00
syn match yaccCurlyError "[{}]"
syn region yaccAction matchgroup=yaccCurly start="{" end="}" contains=ALLBUT,@yaccActionGroup
2008-06-24 22:58:06 +00:00
" ---------------------------------------------------------------------
" Yacc synchronization: {{{1
if exists("g:yacc_maxlines")
exe "syn sync maxlines=".g:yacc_maxlines
else
syn sync maxlines=200
endif
if exists("g:yacc_minlines")
exe "syn sync minlines=".g:yacc_minlines
else
syn sync minlines=50
endif
2004-06-13 20:20:40 +00:00
2008-06-24 22:58:06 +00:00
" ---------------------------------------------------------------------
" Define the default highlighting. {{{1
2004-06-13 20:20:40 +00:00
" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet
if version >= 508 || !exists("did_yacc_syn_inits")
if version < 508
let did_yacchdl_syn_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
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
2004-06-13 20:20:40 +00:00
HiLink yaccCurly Delimiter
HiLink yaccCurlyError Error
HiLink yaccDefinition Function
HiLink yaccDelim Function
HiLink yaccKeyActn Special
HiLink yaccSectionSep Todo
HiLink yaccSep Delimiter
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
let b:current_syntax = "yacc"
2008-06-24 22:58:06 +00:00
" ---------------------------------------------------------------------
" Modelines: {{{1
" vim: ts=15 fdm=marker