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