Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: Lex |
| 3 | " Maintainer: Dr. Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz> |
Bram Moolenaar | d4755bb | 2004-09-02 19:12:26 +0000 | [diff] [blame] | 4 | " Last Change: Jul 28, 2004 |
| 5 | " Version: 5 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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 |
| 13 | if version < 600 |
| 14 | syntax clear |
| 15 | elseif exists("b:current_syntax") |
| 16 | finish |
| 17 | endif |
| 18 | |
| 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 |
| 34 | |
Bram Moolenaar | d4755bb | 2004-09-02 19:12:26 +0000 | [diff] [blame] | 35 | " --- ========= --- |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 36 | " --- Lex stuff --- |
Bram Moolenaar | d4755bb | 2004-09-02 19:12:26 +0000 | [diff] [blame] | 37 | " --- ========= --- |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 38 | |
| 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 |
| 42 | |
| 43 | " Abbreviations Section |
Bram Moolenaar | d4755bb | 2004-09-02 19:12:26 +0000 | [diff] [blame] | 44 | syn region lexAbbrvBlock start="^\(\h\+\s\|%{\)" end="^\ze%%$" skipnl nextgroup=lexPatBlock contains=lexAbbrv,lexInclude,lexAbbrvComment,lexStartState |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 45 | syn match lexAbbrv "^\I\i*\s"me=e-1 skipwhite contained nextgroup=lexAbbrvRegExp |
| 46 | syn match lexAbbrv "^%[sx]" contained |
| 47 | syn match lexAbbrvRegExp "\s\S.*$"lc=1 contained nextgroup=lexAbbrv,lexInclude |
| 48 | syn region lexInclude matchgroup=lexSep start="^%{" end="%}" contained contains=ALLBUT,@lexListGroup |
| 49 | syn region lexAbbrvComment start="^\s\+/\*" end="\*/" contains=@Spell |
Bram Moolenaar | d4755bb | 2004-09-02 19:12:26 +0000 | [diff] [blame] | 50 | syn region lexStartState matchgroup=lexAbbrv start="^%\a\+" end="$" contained |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 51 | |
| 52 | "%% : Patterns {Actions} |
| 53 | syn region lexPatBlock matchgroup=Todo start="^%%$" matchgroup=Todo end="^%%$" skipnl skipwhite contains=lexPat,lexPatTag,lexPatComment |
| 54 | syn region lexPat start=+\S+ skip="\\\\\|\\." end="\s"me=e-1 contained nextgroup=lexMorePat,lexPatSep contains=lexPatString,lexSlashQuote,lexBrace |
| 55 | syn region lexBrace start="\[" skip=+\\\\\|\\+ end="]" contained |
| 56 | syn region lexPatString matchgroup=String start=+"+ skip=+\\\\\|\\"+ matchgroup=String end=+"+ contained |
| 57 | syn match lexPatTag "^<\I\i*\(,\I\i*\)*>*" contained nextgroup=lexPat,lexPatTag,lexMorePat,lexPatSep |
| 58 | syn match lexPatTag +^<\I\i*\(,\I\i*\)*>*\(\\\\\)*\\"+ contained nextgroup=lexPat,lexPatTag,lexMorePat,lexPatSep |
| 59 | syn region lexPatComment start="^\s*/\*" end="\*/" skipnl contained contains=cTodo nextgroup=lexPatComment,lexPat,lexPatString,lexPatTag,@Spell |
| 60 | syn match lexPatCodeLine ".*$" contained contains=ALLBUT,@lexListGroup |
| 61 | syn match lexMorePat "\s*|\s*$" skipnl contained nextgroup=lexPat,lexPatTag,lexPatComment |
| 62 | syn match lexPatSep "\s\+" contained nextgroup=lexMorePat,lexPatCode,lexPatCodeLine |
| 63 | syn match lexSlashQuote +\(\\\\\)*\\"+ contained |
| 64 | syn region lexPatCode matchgroup=Delimiter start="{" matchgroup=Delimiter end="}" skipnl contained contains=ALLBUT,@lexListPatCodeGroup |
| 65 | |
| 66 | syn keyword lexCFunctions BEGIN input unput woutput yyleng yylook yytext |
| 67 | syn keyword lexCFunctions ECHO output winput wunput yyless yymore yywrap |
| 68 | |
| 69 | " <c.vim> includes several ALLBUTs; these have to be treated so as to exclude lex* groups |
| 70 | syn cluster cParenGroup add=lex.* |
| 71 | syn cluster cDefineGroup add=lex.* |
| 72 | syn cluster cPreProcGroup add=lex.* |
| 73 | syn cluster cMultiGroup add=lex.* |
| 74 | |
| 75 | " Synchronization |
| 76 | syn sync clear |
| 77 | syn sync minlines=300 |
| 78 | syn sync match lexSyncPat grouphere lexPatBlock "^%[a-zA-Z]" |
| 79 | syn sync match lexSyncPat groupthere lexPatBlock "^<$" |
| 80 | syn sync match lexSyncPat groupthere lexPatBlock "^%%$" |
| 81 | |
| 82 | " The default highlighting. |
| 83 | hi def link lexSlashQuote lexPat |
| 84 | hi def link lexBrace lexPat |
| 85 | hi def link lexAbbrvComment lexPatComment |
| 86 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 87 | hi def link lexAbbrvRegExp Macro |
Bram Moolenaar | d4755bb | 2004-09-02 19:12:26 +0000 | [diff] [blame] | 88 | hi def link lexAbbrv SpecialChar |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 89 | hi def link lexCFunctions Function |
| 90 | hi def link lexMorePat SpecialChar |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 91 | hi def link lexPatComment Comment |
Bram Moolenaar | d4755bb | 2004-09-02 19:12:26 +0000 | [diff] [blame] | 92 | hi def link lexPat Function |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 93 | hi def link lexPatString Function |
| 94 | hi def link lexPatTag Special |
| 95 | hi def link lexSep Delimiter |
Bram Moolenaar | d4755bb | 2004-09-02 19:12:26 +0000 | [diff] [blame] | 96 | hi def link lexStartState Statement |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 97 | |
| 98 | let b:current_syntax = "lex" |
| 99 | |
| 100 | " vim:ts=10 |