3 " Maintainer: Dr. Charles E. Campbell, Jr. <Charles.E.Campbell.1@gsfc.nasa.gov>
4 " Last Change: February 1, 2001
6 " lex_uses_cpp : if this variable exists, then C++ is loaded rather than C
8 " For version 5.x: Clear all syntax items
9 " For version 6.x: Quit when a syntax file was already loaded
12 elseif exists("b:current_syntax")
16 " Read the C syntax to start with
18 if exists("lex_uses_cpp")
19 runtime! syntax/cpp.vim
23 unlet b:current_syntax
25 if exists("lex_uses_cpp")
26 so <sfile>:p:h/cpp.vim
34 "I'd prefer to use lex.* , but it doesn't handle forward definitions yet
35 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
36 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
38 " Abbreviations Section
39 syn region lexAbbrvBlock start="^\([a-zA-Z_]\+\t\|%{\)" end="^%%$"me=e-2 skipnl nextgroup=lexPatBlock contains=lexAbbrv,lexInclude,lexAbbrvComment
40 syn match lexAbbrv "^\I\i*\s"me=e-1 skipwhite contained nextgroup=lexAbbrvRegExp
41 syn match lexAbbrv "^%[sx]" contained
42 syn match lexAbbrvRegExp "\s\S.*$"lc=1 contained nextgroup=lexAbbrv,lexInclude
43 syn region lexInclude matchgroup=lexSep start="^%{" end="%}" contained contains=ALLBUT,@lexListGroup
44 syn region lexAbbrvComment start="^\s\+/\*" end="\*/"
46 "%% : Patterns {Actions}
47 syn region lexPatBlock matchgroup=Todo start="^%%$" matchgroup=Todo end="^%%$" skipnl skipwhite contains=lexPat,lexPatTag,lexPatComment
48 syn region lexPat start=+\S+ skip="\\\\\|\\." end="\s"me=e-1 contained nextgroup=lexMorePat,lexPatSep contains=lexPatString,lexSlashQuote,lexBrace
49 syn region lexBrace start="\[" skip=+\\\\\|\\+ end="]" contained
50 syn region lexPatString matchgroup=String start=+"+ skip=+\\\\\|\\"+ matchgroup=String end=+"+ contained
51 syn match lexPatTag "^<\I\i*\(,\I\i*\)*>*" contained nextgroup=lexPat,lexPatTag,lexMorePat,lexPatSep
52 syn match lexPatTag +^<\I\i*\(,\I\i*\)*>*\(\\\\\)*\\"+ contained nextgroup=lexPat,lexPatTag,lexMorePat,lexPatSep
53 syn region lexPatComment start="^\s*/\*" end="\*/" skipnl contained contains=cTodo nextgroup=lexPatComment,lexPat,lexPatString,lexPatTag
54 syn match lexPatCodeLine ".*$" contained contains=ALLBUT,@lexListGroup
55 syn match lexMorePat "\s*|\s*$" skipnl contained nextgroup=lexPat,lexPatTag,lexPatComment
56 syn match lexPatSep "\s\+" contained nextgroup=lexMorePat,lexPatCode,lexPatCodeLine
57 syn match lexSlashQuote +\(\\\\\)*\\"+ contained
58 syn region lexPatCode matchgroup=Delimiter start="{" matchgroup=Delimiter end="}" skipnl contained contains=ALLBUT,@lexListPatCodeGroup
60 syn keyword lexCFunctions BEGIN input unput woutput yyleng yylook yytext
61 syn keyword lexCFunctions ECHO output winput wunput yyless yymore yywrap
63 " <c.vim> includes several ALLBUTs; these have to be treated so as to exclude lex* groups
64 syn cluster cParenGroup add=lex.*
65 syn cluster cDefineGroup add=lex.*
66 syn cluster cPreProcGroup add=lex.*
67 syn cluster cMultiGroup add=lex.*
72 syn sync match lexSyncPat grouphere lexPatBlock "^%[a-zA-Z]"
73 syn sync match lexSyncPat groupthere lexPatBlock "^<$"
74 syn sync match lexSyncPat groupthere lexPatBlock "^%%$"
76 " The default highlighting.
77 hi def link lexSlashQuote lexPat
78 hi def link lexBrace lexPat
79 hi def link lexAbbrvComment lexPatComment
81 hi def link lexAbbrv SpecialChar
82 hi def link lexAbbrvRegExp Macro
83 hi def link lexCFunctions Function
84 hi def link lexMorePat SpecialChar
85 hi def link lexPat Function
86 hi def link lexPatComment Comment
87 hi def link lexPatString Function
88 hi def link lexPatTag Special
89 hi def link lexSep Delimiter
91 let b:current_syntax = "lex"