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