Update runtime files
[MacVim.git] / runtime / syntax / lex.vim
blobff414d63b92eae1ddebdb9da72b9d8170349e069
1 " Vim syntax file
2 " Language:     Lex
3 " Maintainer:   Dr. Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz>
4 " Last Change:  Sep 04, 2008
5 " Version:      9
6 " URL:  http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax
8 " Option:
9 "   lex_uses_cpp : if this variable exists, then C++ is loaded rather than C
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
19 " Read the C syntax to start with
20 if 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
27 else
28   if exists("lex_uses_cpp")
29     so <sfile>:p:h/cpp.vim
30   else
31     so <sfile>:p:h/c.vim
32   endif
33 endif
35 " --- ========= ---
36 " --- Lex stuff ---
37 " --- ========= ---
39 "I'd prefer to use lex.* , but it doesn't handle forward definitions yet
40 syn 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
41 syn 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
43 " Abbreviations Section
44 if has("folding")
45  syn region lexAbbrvBlock       fold start="^\(\h\+\s\|%{\)" end="^\ze%%$"      skipnl  nextgroup=lexPatBlock contains=lexAbbrv,lexInclude,lexAbbrvComment,lexStartState
46 else
47  syn region lexAbbrvBlock       start="^\(\h\+\s\|%{\)" end="^\ze%%$"   skipnl  nextgroup=lexPatBlock contains=lexAbbrv,lexInclude,lexAbbrvComment,lexStartState
48 endif
49 syn match  lexAbbrv             "^\I\i*\s"me=e-1                        skipwhite       contained nextgroup=lexAbbrvRegExp
50 syn match  lexAbbrv             "^%[sx]"                                        contained
51 syn match  lexAbbrvRegExp       "\s\S.*$"lc=1                           contained nextgroup=lexAbbrv,lexInclude
52 if 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
56 else
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
60 endif
62 "%% : Patterns {Actions}
63 if has("folding")
64  syn region lexPatBlock fold matchgroup=Todo    start="^%%$" matchgroup=Todo end="^%%$" skipnl skipwhite contains=lexPat,lexPatTag,lexPatComment
65  syn region lexPat              fold start=+\S+ skip="\\\\\|\\."        end="\s"me=e-1  contained nextgroup=lexMorePat,lexPatSep contains=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
68 else
69  syn region lexPatBlock matchgroup=Todo start="^%%$" matchgroup=Todo end="^%%$" skipnl skipwhite contains=lexPat,lexPatTag,lexPatComment
70  syn region lexPat              start=+\S+ skip="\\\\\|\\."     end="\s"me=e-1  contained nextgroup=lexMorePat,lexPatSep contains=lexPatString,lexSlashQuote,lexBrace
71  syn region lexBrace    start="\[" skip=+\\\\\|\\+              end="]"         contained
72  syn region lexPatString        matchgroup=String start=+"+     skip=+\\\\\|\\"+        matchgroup=String end=+"+       contained
73 endif
74 syn match  lexPatTag    "^<\I\i*\(,\I\i*\)*>*"                  contained nextgroup=lexPat,lexPatTag,lexMorePat,lexPatSep
75 syn match  lexPatTag    +^<\I\i*\(,\I\i*\)*>*\(\\\\\)*\\"+              contained nextgroup=lexPat,lexPatTag,lexMorePat,lexPatSep
76 if has("folding")
77  syn region lexPatComment       fold start="\s\+/\*" end="\*/"          skipnl  contained contains=cTodo skipwhite nextgroup=lexPatComment,lexPat,@Spell
78 else
79  syn region lexPatComment       start="\s\+/\*" end="\*/"               skipnl  contained contains=cTodo skipwhite nextgroup=lexPatComment,lexPat,@Spell
80 endif
81 syn match  lexPatCodeLine       ".*$"                                   contained contains=ALLBUT,@lexListGroup
82 syn match  lexMorePat   "\s*|\s*$"                      skipnl  contained nextgroup=lexPat,lexPatTag,lexPatComment
83 syn match  lexPatSep    "\s\+"                                  contained nextgroup=lexMorePat,lexPatCode,lexPatCodeLine
84 syn match  lexSlashQuote        +\(\\\\\)*\\"+                          contained
85 if has("folding")
86  syn region lexPatCode fold matchgroup=Delimiter start="{" matchgroup=Delimiter end="}" skipnl contained contains=ALLBUT,@lexListPatCodeGroup
87 else
88  syn region lexPatCode matchgroup=Delimiter start="{" matchgroup=Delimiter end="}"      skipnl contained contains=ALLBUT,@lexListPatCodeGroup
89 endif
91 syn keyword lexCFunctions       BEGIN   input   unput   woutput yyleng  yylook  yytext
92 syn keyword lexCFunctions       ECHO    output  winput  wunput  yyless  yymore  yywrap
94 " <c.vim> includes several ALLBUTs; these have to be treated so as to exclude lex* groups
95 syn cluster cParenGroup add=lex.*
96 syn cluster cDefineGroup        add=lex.*
97 syn cluster cPreProcGroup       add=lex.*
98 syn cluster cMultiGroup add=lex.*
100 " Synchronization
101 syn sync clear
102 syn sync minlines=300
103 syn sync match lexSyncPat       grouphere  lexPatBlock  "^%[a-zA-Z]"
104 syn sync match lexSyncPat       groupthere lexPatBlock  "^<$"
105 syn sync match lexSyncPat       groupthere lexPatBlock  "^%%$"
107 " The default highlighting.
108 hi def link lexSlashQuote       lexPat
109 hi def link lexBrace    lexPat
110 hi def link lexAbbrvComment     lexPatComment
112 hi def link lexAbbrvRegExp      Macro
113 hi def link lexAbbrv    SpecialChar
114 hi def link lexCFunctions       Function
115 hi def link lexMorePat  SpecialChar
116 hi def link lexPatComment       Comment
117 hi def link lexPat              Function
118 hi def link lexPatString        Function
119 hi def link lexPatTag   Special
120 hi def link lexSep              Delimiter
121 hi def link lexStartState       Statement
123 let b:current_syntax = "lex"
125 " vim:ts=10