robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

zeertzjqvim-patch:f9ca139e3aa1 (#27554)9bb046d1be

master
5.5 KiB121 linesraw
1" Vim syntax file
2" Language:	Yacc
3" Former Maintainer: Charles E. Campbell
4" Last Change:	Mar 25, 2019
5" Version:	17
6"   2024 Feb 19 by Vim Project (announce adoption)
7" Former URL:	http://www.drchip.org/astronaut/vim/index.html#SYNTAX_YACC
8"
9" Options: {{{1
10"   g:yacc_uses_cpp : if this variable exists, then C++ is loaded rather than C
11
12" ---------------------------------------------------------------------
13" this version of syntax/yacc.vim requires 6.0 or later
14if exists("b:current_syntax")
15 syntax clear
16endif
17
18" ---------------------------------------------------------------------
19"  Folding Support {{{1
20if has("folding")
21 com! -nargs=+ SynFold	<args> fold
22else
23 com! -nargs=+ SynFold	<args>
24endif
25
26" ---------------------------------------------------------------------
27" Read the C syntax to start with {{{1
28" Read the C/C++ syntax to start with
29let 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   break
35  endif
36 endfor
37endif
38exe "syn include @yaccCode ".s:Cpath
39
40" ---------------------------------------------------------------------
41"  Yacc Clusters: {{{1
42syn cluster yaccInitCluster	contains=yaccKey,yaccKeyActn,yaccBrkt,yaccType,yaccString,yaccUnionStart,yaccHeader2,yaccComment,yaccDefines,yaccParseParam,yaccParseOption
43syn cluster yaccRulesCluster	contains=yaccNonterminal,yaccString
44
45" ---------------------------------------------------------------------
46"  Yacc Sections: {{{1
47SynFold 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 contained
48SynFold 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 skipempty
49SynFold syn	region	yaccHeader2	matchgroup=yaccSep	start="^\s*\zs%{"		end="^\s*%}"			contains=@yaccCode	nextgroup=yaccInit	skipwhite skipempty contained
50SynFold syn	region	yaccHeader	matchgroup=yaccSep	start="^\s*\zs%{"		end="^\s*%}"			contains=@yaccCode	nextgroup=yaccInit	skipwhite skipempty
51SynFold syn	region	yaccRules	matchgroup=yaccSectionSep	start='^%%\ze\(\s*/[*/].*\)\=$'	end='^%%\ze\(\s*/[*/].*\)\=$'me=e-2,re=e-2	contains=@yaccRulesCluster	nextgroup=yaccEndCode	skipwhite skipempty contained
52SynFold syn	region	yaccEndCode	matchgroup=yaccSectionSep	start='^%%\ze\(\s*/[*/].*\)\=$'	end='\%$'			contains=@yaccCode	contained
53
54" ---------------------------------------------------------------------
55" Yacc Commands: {{{1
56syn	match	yaccDefines	'^%define\s\+.*$'
57syn	match	yaccParseParam	'%\(parse\|lex\)-param\>'		skipwhite	nextgroup=yaccParseParamStr
58syn	match	yaccParseOption '%\%(api\.pure\|pure-parser\|locations\|error-verbose\)\>'
59syn	region	yaccParseParamStr	contained matchgroup=Delimiter	start='{'	end='}'	contains=cStructure
60
61syn	match	yaccDelim	"[:|]"	contained
62syn	match	yaccOper	"@\d\+"	contained
63
64syn	match	yaccKey	"^\s*%\(token\|type\|left\|right\|start\|ident\|nonassoc\)\>"	contained
65syn	match	yaccKey	"\s%\(prec\|expect\)\>"	contained
66syn	match	yaccKey	"\$\(<[a-zA-Z_][a-zA-Z_0-9]*>\)\=[\$0-9]\+"	contained
67syn	keyword	yaccKeyActn	yyerrok yyclearin	contained
68
69syn	match	yaccUnionStart	"^%union"	skipwhite skipnl nextgroup=yaccUnion	contained
70SynFold syn	region	yaccUnion	matchgroup=yaccCurly start="{" matchgroup=yaccCurly end="}" contains=@yaccCode	contained
71syn	match	yaccBrkt	"[<>]"	contained
72syn	match	yaccType	"<[a-zA-Z_][a-zA-Z0-9_]*>"	contains=yaccBrkt	contained
73
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	contained
75syn	region	yaccComment	start="/\*"	end="\*/"
76syn	region	yaccComment	start="//"	end="$"
77syn	match	yaccString	"'[^']*'"	contained
78
79
80" ---------------------------------------------------------------------
81" I'd really like to highlight just the outer {}.  Any suggestions??? {{{1
82syn	match	yaccCurlyError	"[{}]"
83SynFold syn	region	yaccAction	matchgroup=yaccCurly start="{" end="}" 	contains=@yaccCode,yaccVar		contained
84syn	match	yaccVar	'\$\d\+\|\$\$\|\$<\I\i*>\$\|\$<\I\i*>\d\+'	containedin=cParen,cPreProc,cMulti	contained
85
86" ---------------------------------------------------------------------
87" Yacc synchronization: {{{1
88syn sync fromstart
89
90" ---------------------------------------------------------------------
91" Define the default highlighting. {{{1
92if !exists("skip_yacc_syn_inits")
93  hi def link yaccBrkt	yaccStmt
94  hi def link yaccComment	Comment
95  hi def link yaccCurly	Delimiter
96  hi def link yaccCurlyError	Error
97  hi def link yaccDefines	cDefine
98  hi def link yaccDelim	Delimiter
99  hi def link yaccKeyActn	Special
100  hi def link yaccKey	yaccStmt
101  hi def link yaccNonterminal	Function
102  hi def link yaccOper	yaccStmt
103  hi def link yaccParseOption	cDefine
104  hi def link yaccParseParam	yaccParseOption
105  hi def link yaccSectionSep	Todo
106  hi def link yaccSep	Delimiter
107  hi def link yaccStmt	Statement
108  hi def link yaccString	String
109  hi def link yaccType	Type
110  hi def link yaccUnionStart	yaccKey
111  hi def link yaccVar	Special
112endif
113
114" ---------------------------------------------------------------------
115"  Cleanup: {{{1
116delcommand SynFold
117let b:current_syntax = "yacc"
118
119" ---------------------------------------------------------------------
120"  Modelines: {{{1
121" vim: ts=15 fdm=marker