blob: 25c423ef534057dffa5beadd8d855fb6e70a3eaa [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: Lex
3" Maintainer: Dr. Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz>
4" Last Change: Sep 02, 2003
5" Version: 4
6" URL: http://www.erols.com/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 syntax to start with
20if 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
35" --- Lex stuff ---
36
37"I'd prefer to use lex.* , but it doesn't handle forward definitions yet
38syn 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
39syn cluster lexListPatCodeGroup contains=lexAbbrvBlock,lexAbbrv,lexAbbrv,lexAbbrvRegExp,lexInclude,lexPatBlock,lexPat,lexBrace,lexPatTag,lexPatTag,lexPatComment,lexPatCodeLine,lexMorePat,lexPatSep,lexSlashQuote,cInParen,cUserLabel,cOctalZero,cCppSkip,cErrInBracket,cErrInParen,cOctalError,cCppOut2,cCommentStartError,cParenError
40
41" Abbreviations Section
42syn region lexAbbrvBlock start="^\([a-zA-Z_]\+\t\|%{\)" end="^%%$"me=e-2 skipnl nextgroup=lexPatBlock contains=lexAbbrv,lexInclude,lexAbbrvComment
43syn match lexAbbrv "^\I\i*\s"me=e-1 skipwhite contained nextgroup=lexAbbrvRegExp
44syn match lexAbbrv "^%[sx]" contained
45syn match lexAbbrvRegExp "\s\S.*$"lc=1 contained nextgroup=lexAbbrv,lexInclude
46syn region lexInclude matchgroup=lexSep start="^%{" end="%}" contained contains=ALLBUT,@lexListGroup
47syn region lexAbbrvComment start="^\s\+/\*" end="\*/" contains=@Spell
48
49"%% : Patterns {Actions}
50syn region lexPatBlock matchgroup=Todo start="^%%$" matchgroup=Todo end="^%%$" skipnl skipwhite contains=lexPat,lexPatTag,lexPatComment
51syn region lexPat start=+\S+ skip="\\\\\|\\." end="\s"me=e-1 contained nextgroup=lexMorePat,lexPatSep contains=lexPatString,lexSlashQuote,lexBrace
52syn region lexBrace start="\[" skip=+\\\\\|\\+ end="]" contained
53syn region lexPatString matchgroup=String start=+"+ skip=+\\\\\|\\"+ matchgroup=String end=+"+ contained
54syn match lexPatTag "^<\I\i*\(,\I\i*\)*>*" contained nextgroup=lexPat,lexPatTag,lexMorePat,lexPatSep
55syn match lexPatTag +^<\I\i*\(,\I\i*\)*>*\(\\\\\)*\\"+ contained nextgroup=lexPat,lexPatTag,lexMorePat,lexPatSep
56syn region lexPatComment start="^\s*/\*" end="\*/" skipnl contained contains=cTodo nextgroup=lexPatComment,lexPat,lexPatString,lexPatTag,@Spell
57syn match lexPatCodeLine ".*$" contained contains=ALLBUT,@lexListGroup
58syn match lexMorePat "\s*|\s*$" skipnl contained nextgroup=lexPat,lexPatTag,lexPatComment
59syn match lexPatSep "\s\+" contained nextgroup=lexMorePat,lexPatCode,lexPatCodeLine
60syn match lexSlashQuote +\(\\\\\)*\\"+ contained
61syn region lexPatCode matchgroup=Delimiter start="{" matchgroup=Delimiter end="}" skipnl contained contains=ALLBUT,@lexListPatCodeGroup
62
63syn keyword lexCFunctions BEGIN input unput woutput yyleng yylook yytext
64syn keyword lexCFunctions ECHO output winput wunput yyless yymore yywrap
65
66" <c.vim> includes several ALLBUTs; these have to be treated so as to exclude lex* groups
67syn cluster cParenGroup add=lex.*
68syn cluster cDefineGroup add=lex.*
69syn cluster cPreProcGroup add=lex.*
70syn cluster cMultiGroup add=lex.*
71
72" Synchronization
73syn sync clear
74syn sync minlines=300
75syn sync match lexSyncPat grouphere lexPatBlock "^%[a-zA-Z]"
76syn sync match lexSyncPat groupthere lexPatBlock "^<$"
77syn sync match lexSyncPat groupthere lexPatBlock "^%%$"
78
79" The default highlighting.
80hi def link lexSlashQuote lexPat
81hi def link lexBrace lexPat
82hi def link lexAbbrvComment lexPatComment
83
84hi def link lexAbbrv SpecialChar
85hi def link lexAbbrvRegExp Macro
86hi def link lexCFunctions Function
87hi def link lexMorePat SpecialChar
88hi def link lexPat Function
89hi def link lexPatComment Comment
90hi def link lexPatString Function
91hi def link lexPatTag Special
92hi def link lexSep Delimiter
93
94let b:current_syntax = "lex"
95
96" vim:ts=10