blob: 68ae63273599e04c67af57584c0a368ffec6761e [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: Lex
Bram Moolenaar5c736222010-01-06 20:54:52 +01003" Maintainer: Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz>
4" Last Change: Sep 11, 2009
5" Version: 10
Bram Moolenaarcafda4f2005-09-06 19:25:11 +00006" URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax
Bram Moolenaar071d4272004-06-13 20:20:40 +00007"
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
Bram Moolenaar5c736222010-01-06 20:54:52 +010019" Read the C/C++ syntax to start with
Bram Moolenaar071d4272004-06-13 20:20:40 +000020if version >= 600
21 if exists("lex_uses_cpp")
22 runtime! syntax/cpp.vim
23 else
24 runtime! syntax/c.vim
25 endif
26 unlet b:current_syntax
27else
28 if exists("lex_uses_cpp")
29 so <sfile>:p:h/cpp.vim
30 else
31 so <sfile>:p:h/c.vim
32 endif
33endif
34
Bram Moolenaard4755bb2004-09-02 19:12:26 +000035" --- ========= ---
Bram Moolenaar071d4272004-06-13 20:20:40 +000036" --- Lex stuff ---
Bram Moolenaard4755bb2004-09-02 19:12:26 +000037" --- ========= ---
Bram Moolenaar071d4272004-06-13 20:20:40 +000038
Bram Moolenaar5c736222010-01-06 20:54:52 +010039"I'd prefer to use lex.* , but vim doesn't handle forward definitions yet
Bram Moolenaar071d4272004-06-13 20:20:40 +000040syn cluster lexListGroup contains=lexAbbrvBlock,lexAbbrv,lexAbbrv,lexAbbrvRegExp,lexInclude,lexPatBlock,lexPat,lexBrace,lexPatString,lexPatTag,lexPatTag,lexPatComment,lexPatCodeLine,lexMorePat,lexPatSep,lexSlashQuote,lexPatCode,cInParen,cUserLabel,cOctalZero,cCppSkip,cErrInBracket,cErrInParen,cOctalError,cCppOut2,cCommentStartError,cParenError
Bram Moolenaar5c736222010-01-06 20:54:52 +010041syn cluster lexListPatCodeGroup contains=lexAbbrvBlock,lexAbbrv,lexAbbrv,lexAbbrvRegExp,lexInclude,lexPatBlock,lexPat,lexBrace,lexPatTag,lexPatTag,lexPatTagZoneStart,lexPatComment,lexPatCodeLine,lexMorePat,lexPatSep,lexSlashQuote,cInParen,cUserLabel,cOctalZero,cCppSkip,cErrInBracket,cErrInParen,cOctalError,cCppOut2,cCommentStartError,cParenError
Bram Moolenaar071d4272004-06-13 20:20:40 +000042
43" Abbreviations Section
Bram Moolenaar5c736222010-01-06 20:54:52 +010044if has("folding")
45 syn region lexAbbrvBlock fold start="^\(\h\+\s\|%{\)" end="^\ze%%$" skipnl nextgroup=lexPatBlock contains=lexAbbrv,lexInclude,lexAbbrvComment,lexStartState
46else
47 syn region lexAbbrvBlock start="^\(\h\+\s\|%{\)" end="^\ze%%$" skipnl nextgroup=lexPatBlock contains=lexAbbrv,lexInclude,lexAbbrvComment,lexStartState
48endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000049syn match lexAbbrv "^\I\i*\s"me=e-1 skipwhite contained nextgroup=lexAbbrvRegExp
50syn match lexAbbrv "^%[sx]" contained
51syn match lexAbbrvRegExp "\s\S.*$"lc=1 contained nextgroup=lexAbbrv,lexInclude
Bram Moolenaar5c736222010-01-06 20:54:52 +010052if has("folding")
53 syn region lexInclude fold matchgroup=lexSep start="^%{" end="%}" contained contains=ALLBUT,@lexListGroup
54 syn region lexAbbrvComment fold start="^\s\+/\*" end="\*/" contains=@Spell
55 syn region lexStartState fold matchgroup=lexAbbrv start="^%\a\+" end="$" contained
56else
57 syn region lexInclude matchgroup=lexSep start="^%{" end="%}" contained contains=ALLBUT,@lexListGroup
58 syn region lexAbbrvComment start="^\s\+/\*" end="\*/" contains=@Spell
59 syn region lexStartState matchgroup=lexAbbrv start="^%\a\+" end="$" contained
60endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000061
62"%% : Patterns {Actions}
Bram Moolenaar5c736222010-01-06 20:54:52 +010063if has("folding")
64 syn region lexPatBlock fold matchgroup=Todo start="^%%$" matchgroup=Todo end="^%%$" skipnl skipwhite contains=lexPatTag,lexPatTagZone,lexPatComment,lexPat
65 syn region lexPat fold start=+\S+ skip="\\\\\|\\." end="\s"me=e-1 contained nextgroup=lexMorePat,lexPatSep contains=lexPatTag,lexPatString,lexSlashQuote,lexBrace
66 syn region lexBrace fold start="\[" skip=+\\\\\|\\+ end="]" contained
67 syn region lexPatString fold matchgroup=String start=+"+ skip=+\\\\\|\\"+ matchgroup=String end=+"+ contained
68else
69 syn region lexPatBlock matchgroup=Todo start="^%%$" matchgroup=Todo end="^%%$" skipnl skipwhite contains=lexPatTag,lexPatTagZone,lexPatComment,lexPat
70 syn region lexPat start=+\S+ skip="\\\\\|\\." end="\s"me=e-1 contained nextgroup=lexMorePat,lexPatSep contains=lexPatTag,lexPatString,lexSlashQuote,lexBrace
71 syn region lexBrace start="\[" skip=+\\\\\|\\+ end="]" contained
72 syn region lexPatString matchgroup=String start=+"+ skip=+\\\\\|\\"+ matchgroup=String end=+"+ contained
73endif
74syn match lexPatTag "^<\I\i*\(,\I\i*\)*>" contained nextgroup=lexPat,lexPatTag,lexMorePat,lexPatSep
75syn match lexPatTagZone "^<\I\i*\(,\I\i*\)*>\s*\ze{" contained nextgroup=lexPatTagZoneStart
Bram Moolenaar071d4272004-06-13 20:20:40 +000076syn match lexPatTag +^<\I\i*\(,\I\i*\)*>*\(\\\\\)*\\"+ contained nextgroup=lexPat,lexPatTag,lexMorePat,lexPatSep
Bram Moolenaar5c736222010-01-06 20:54:52 +010077if has("folding")
78 syn region lexPatTagZoneStart matchgroup=lexPatTag fold start='{' end='}' contained contains=lexPat,lexPatComment
79 syn region lexPatComment start="\s\+/\*" end="\*/" fold skipnl contained contains=cTodo skipwhite nextgroup=lexPatComment,lexPat,@Spell
80else
81 syn region lexPatTagZoneStart matchgroup=lexPatTag start='{' end='}' contained contains=lexPat,lexPatComment
82 syn region lexPatComment start="\s\+/\*" end="\*/" skipnl contained contains=cTodo skipwhite nextgroup=lexPatComment,lexPat,@Spell
83endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000084syn match lexPatCodeLine ".*$" contained contains=ALLBUT,@lexListGroup
85syn match lexMorePat "\s*|\s*$" skipnl contained nextgroup=lexPat,lexPatTag,lexPatComment
86syn match lexPatSep "\s\+" contained nextgroup=lexMorePat,lexPatCode,lexPatCodeLine
87syn match lexSlashQuote +\(\\\\\)*\\"+ contained
Bram Moolenaar5c736222010-01-06 20:54:52 +010088if has("folding")
89 syn region lexPatCode matchgroup=Delimiter start="{" end="}" fold skipnl contained contains=ALLBUT,@lexListPatCodeGroup
90else
91 syn region lexPatCode matchgroup=Delimiter start="{" end="}" skipnl contained contains=ALLBUT,@lexListPatCodeGroup
92endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000093
94syn keyword lexCFunctions BEGIN input unput woutput yyleng yylook yytext
95syn keyword lexCFunctions ECHO output winput wunput yyless yymore yywrap
96
97" <c.vim> includes several ALLBUTs; these have to be treated so as to exclude lex* groups
98syn cluster cParenGroup add=lex.*
99syn cluster cDefineGroup add=lex.*
100syn cluster cPreProcGroup add=lex.*
101syn cluster cMultiGroup add=lex.*
102
103" Synchronization
104syn sync clear
105syn sync minlines=300
106syn sync match lexSyncPat grouphere lexPatBlock "^%[a-zA-Z]"
107syn sync match lexSyncPat groupthere lexPatBlock "^<$"
108syn sync match lexSyncPat groupthere lexPatBlock "^%%$"
109
110" The default highlighting.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000111hi def link lexAbbrvComment lexPatComment
Bram Moolenaar5c736222010-01-06 20:54:52 +0100112hi def link lexBrace lexPat
113hi def link lexPatTagZone lexPatTag
114hi def link lexSlashQuote lexPat
Bram Moolenaar071d4272004-06-13 20:20:40 +0000115
Bram Moolenaar071d4272004-06-13 20:20:40 +0000116hi def link lexAbbrvRegExp Macro
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000117hi def link lexAbbrv SpecialChar
Bram Moolenaar071d4272004-06-13 20:20:40 +0000118hi def link lexCFunctions Function
119hi def link lexMorePat SpecialChar
Bram Moolenaar071d4272004-06-13 20:20:40 +0000120hi def link lexPatComment Comment
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000121hi def link lexPat Function
Bram Moolenaar071d4272004-06-13 20:20:40 +0000122hi def link lexPatString Function
123hi def link lexPatTag Special
124hi def link lexSep Delimiter
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000125hi def link lexStartState Statement
Bram Moolenaar071d4272004-06-13 20:20:40 +0000126
127let b:current_syntax = "lex"
128
129" vim:ts=10