7
|
1 " Vim syntax file
|
|
2 " Language: Lex
|
3920
|
3 " Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz>
|
|
4 " Last Change: Nov 14, 2012
|
|
5 " Version: 14
|
507
|
6 " URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax
|
7
|
7 "
|
|
8 " Option:
|
|
9 " lex_uses_cpp : if this variable exists, then C++ is loaded rather than C
|
|
10
|
|
11 " For version 5.x: Clear all syntax items
|
|
12 " For version 6.x: Quit when a syntax file was already loaded
|
|
13 if version < 600
|
|
14 syntax clear
|
|
15 elseif exists("b:current_syntax")
|
|
16 finish
|
|
17 endif
|
|
18
|
2034
|
19 " Read the C/C++ syntax to start with
|
3920
|
20 let s:Cpath= fnameescape(expand("<sfile>:p:h").(exists("g:lex_uses_cpp")? "/cpp.vim" : "/c.vim"))
|
|
21 if !filereadable(s:Cpath)
|
|
22 for s:Cpath in split(globpath(&rtp,(exists("g:lex_uses_cpp")? "syntax/cpp.vim" : "syntax/c.vim")),"\n")
|
|
23 if filereadable(fnameescape(s:Cpath))
|
|
24 let s:Cpath= fnameescape(s:Cpath)
|
|
25 break
|
7
|
26 endif
|
3920
|
27 endfor
|
7
|
28 endif
|
3920
|
29 exe "syn include @lexCcode ".s:Cpath
|
7
|
30
|
22
|
31 " --- ========= ---
|
7
|
32 " --- Lex stuff ---
|
22
|
33 " --- ========= ---
|
7
|
34
|
2662
|
35 " Options Section
|
|
36 syn match lexOptions '^%\s*option\>.*$' contains=lexPatString
|
|
37
|
7
|
38 " Abbreviations Section
|
2034
|
39 if has("folding")
|
|
40 syn region lexAbbrvBlock fold start="^\(\h\+\s\|%{\)" end="^\ze%%$" skipnl nextgroup=lexPatBlock contains=lexAbbrv,lexInclude,lexAbbrvComment,lexStartState
|
|
41 else
|
|
42 syn region lexAbbrvBlock start="^\(\h\+\s\|%{\)" end="^\ze%%$" skipnl nextgroup=lexPatBlock contains=lexAbbrv,lexInclude,lexAbbrvComment,lexStartState
|
|
43 endif
|
7
|
44 syn match lexAbbrv "^\I\i*\s"me=e-1 skipwhite contained nextgroup=lexAbbrvRegExp
|
|
45 syn match lexAbbrv "^%[sx]" contained
|
|
46 syn match lexAbbrvRegExp "\s\S.*$"lc=1 contained nextgroup=lexAbbrv,lexInclude
|
2034
|
47 if has("folding")
|
3920
|
48 syn region lexInclude fold matchgroup=lexSep start="^%{" end="%}" contained contains=@lexCcode
|
2034
|
49 syn region lexAbbrvComment fold start="^\s\+/\*" end="\*/" contains=@Spell
|
3920
|
50 syn region lexAbbrvComment fold start="\%^/\*" end="\*/" contains=@Spell
|
2034
|
51 syn region lexStartState fold matchgroup=lexAbbrv start="^%\a\+" end="$" contained
|
|
52 else
|
3920
|
53 syn region lexInclude matchgroup=lexSep start="^%{" end="%}" contained contains=@lexCcode
|
2034
|
54 syn region lexAbbrvComment start="^\s\+/\*" end="\*/" contains=@Spell
|
3920
|
55 syn region lexAbbrvComment start="\%^/\*" end="\*/" contains=@Spell
|
2034
|
56 syn region lexStartState matchgroup=lexAbbrv start="^%\a\+" end="$" contained
|
|
57 endif
|
7
|
58
|
|
59 "%% : Patterns {Actions}
|
2034
|
60 if has("folding")
|
3920
|
61 syn region lexPatBlock fold matchgroup=Todo start="^%%$" matchgroup=Todo end="^%\ze%$" skipnl skipwhite nextgroup=lexFinalCodeBlock contains=lexPatTag,lexPatTagZone,lexPatComment,lexPat,lexPatInclude
|
|
62 syn region lexPat fold start=+\S+ skip="\\\\\|\\." end="\s"me=e-1 skipwhite contained nextgroup=lexMorePat,lexPatSep,lexPattern contains=lexPatTag,lexPatString,lexSlashQuote,lexBrace
|
2662
|
63 syn region lexPatInclude fold matchgroup=lexSep start="^%{" end="%}" contained contains=lexPatCode
|
2034
|
64 syn region lexBrace fold start="\[" skip=+\\\\\|\\+ end="]" contained
|
|
65 syn region lexPatString fold matchgroup=String start=+"+ skip=+\\\\\|\\"+ matchgroup=String end=+"+ contained
|
|
66 else
|
3920
|
67 syn region lexPatBlock matchgroup=Todo start="^%%$" matchgroup=Todo end="^%%$" skipnl skipwhite nextgroup=lexFinalCodeBlock contains=lexPatTag,lexPatTagZone,lexPatComment,lexPat,lexPatInclude
|
|
68 syn region lexPat start=+\S+ skip="\\\\\|\\." end="\s"me=e-1 skipwhite contained nextgroup=lexMorePat,lexPatSep,lexPattern contains=lexPatTag,lexPatString,lexSlashQuote,lexBrace
|
2662
|
69 syn region lexPatInclude matchgroup=lexSep start="^%{" end="%}" contained contains=lexPatCode
|
2034
|
70 syn region lexBrace start="\[" skip=+\\\\\|\\+ end="]" contained
|
|
71 syn region lexPatString matchgroup=String start=+"+ skip=+\\\\\|\\"+ matchgroup=String end=+"+ contained
|
|
72 endif
|
|
73 syn match lexPatTag "^<\I\i*\(,\I\i*\)*>" contained nextgroup=lexPat,lexPatTag,lexMorePat,lexPatSep
|
3920
|
74 syn match lexPatTagZone "^<\I\i*\(,\I\i*\)*>\s\+\ze{" contained nextgroup=lexPatTagZoneStart
|
7
|
75 syn match lexPatTag +^<\I\i*\(,\I\i*\)*>*\(\\\\\)*\\"+ contained nextgroup=lexPat,lexPatTag,lexMorePat,lexPatSep
|
3920
|
76
|
|
77 " Lex Patterns
|
|
78 syn region lexPattern start='[^ \t{}]' end="$" contained contains=lexPatRange
|
|
79 syn region lexPatRange matchgroup=Delimiter start='\[' skip='\\\\\|\\.' end='\]' contains=lexEscape
|
|
80 syn match lexEscape '\%(\\\\\)*\\.' contained
|
|
81
|
2034
|
82 if has("folding")
|
3920
|
83 syn region lexPatTagZoneStart matchgroup=lexPatTag fold start='{' end='}' contained contains=lexPat,lexPatComment
|
2034
|
84 syn region lexPatComment start="\s\+/\*" end="\*/" fold skipnl contained contains=cTodo skipwhite nextgroup=lexPatComment,lexPat,@Spell
|
|
85 else
|
3920
|
86 syn region lexPatTagZoneStart matchgroup=lexPatTag start='{' end='}' contained contains=lexPat,lexPatComment
|
2034
|
87 syn region lexPatComment start="\s\+/\*" end="\*/" skipnl contained contains=cTodo skipwhite nextgroup=lexPatComment,lexPat,@Spell
|
|
88 endif
|
3920
|
89 syn match lexPatCodeLine "[^{\[].*" contained contains=@lexCcode
|
7
|
90 syn match lexMorePat "\s*|\s*$" skipnl contained nextgroup=lexPat,lexPatTag,lexPatComment
|
|
91 syn match lexPatSep "\s\+" contained nextgroup=lexMorePat,lexPatCode,lexPatCodeLine
|
|
92 syn match lexSlashQuote +\(\\\\\)*\\"+ contained
|
2034
|
93 if has("folding")
|
3920
|
94 syn region lexPatCode matchgroup=Delimiter start="{" end="}" fold skipnl contained contains=@lexCcode,lexCFunctions
|
2034
|
95 else
|
3920
|
96 syn region lexPatCode matchgroup=Delimiter start="{" end="}" skipnl contained contains=@lexCcode,lexCFunctions
|
2034
|
97 endif
|
7
|
98
|
3920
|
99 " Lex "functions" which may appear in C/C++ code blocks
|
7
|
100 syn keyword lexCFunctions BEGIN input unput woutput yyleng yylook yytext
|
|
101 syn keyword lexCFunctions ECHO output winput wunput yyless yymore yywrap
|
|
102
|
3920
|
103 " %%
|
|
104 " lexAbbrevBlock
|
|
105 " %%
|
|
106 " lexPatBlock
|
|
107 " %%
|
|
108 " lexFinalCodeBlock
|
|
109 syn region lexFinalCodeBlock matchgroup=Todo start="%$"me=e-1 end="\%$" contained contains=@lexCcode
|
|
110
|
7
|
111 " <c.vim> includes several ALLBUTs; these have to be treated so as to exclude lex* groups
|
|
112 syn cluster cParenGroup add=lex.*
|
|
113 syn cluster cDefineGroup add=lex.*
|
|
114 syn cluster cPreProcGroup add=lex.*
|
|
115 syn cluster cMultiGroup add=lex.*
|
|
116
|
|
117 " Synchronization
|
|
118 syn sync clear
|
3920
|
119 syn sync minlines=500
|
7
|
120 syn sync match lexSyncPat grouphere lexPatBlock "^%[a-zA-Z]"
|
|
121 syn sync match lexSyncPat groupthere lexPatBlock "^<$"
|
|
122 syn sync match lexSyncPat groupthere lexPatBlock "^%%$"
|
|
123
|
|
124 " The default highlighting.
|
2034
|
125 hi def link lexAbbrvComment lexPatComment
|
22
|
126 hi def link lexAbbrvRegExp Macro
|
7
|
127 hi def link lexAbbrv SpecialChar
|
3920
|
128 hi def link lexBrace lexPat
|
7
|
129 hi def link lexCFunctions Function
|
3920
|
130 hi def link lexCstruct cStructure
|
7
|
131 hi def link lexMorePat SpecialChar
|
2662
|
132 hi def link lexOptions PreProc
|
22
|
133 hi def link lexPatComment Comment
|
7
|
134 hi def link lexPat Function
|
|
135 hi def link lexPatString Function
|
|
136 hi def link lexPatTag Special
|
3920
|
137 hi def link lexPatTagZone lexPatTag
|
7
|
138 hi def link lexSep Delimiter
|
3920
|
139 hi def link lexSlashQuote lexPat
|
22
|
140 hi def link lexStartState Statement
|
7
|
141
|
|
142 let b:current_syntax = "lex"
|
|
143
|
|
144 " vim:ts=10
|