Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: Lex |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 3 | " Maintainer: Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz> |
Bram Moolenaar | 81af925 | 2010-12-10 20:35:50 +0100 | [diff] [blame] | 4 | " Last Change: Nov 01, 2010 |
| 5 | " Version: 12 |
Bram Moolenaar | cafda4f | 2005-09-06 19:25:11 +0000 | [diff] [blame] | 6 | " URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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 | |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 19 | " Read the C/C++ syntax to start with |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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 | |
Bram Moolenaar | 81af925 | 2010-12-10 20:35:50 +0100 | [diff] [blame] | 39 | " Options Section |
| 40 | syn match lexOptions '^%\s*option\>.*$' contains=lexPatString |
| 41 | |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 42 | "I'd prefer to use lex.* , but vim doesn't handle forward definitions yet |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 43 | 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 |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 44 | syn 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 Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 45 | |
| 46 | " Abbreviations Section |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 47 | if has("folding") |
| 48 | syn region lexAbbrvBlock fold start="^\(\h\+\s\|%{\)" end="^\ze%%$" skipnl nextgroup=lexPatBlock contains=lexAbbrv,lexInclude,lexAbbrvComment,lexStartState |
| 49 | else |
| 50 | syn region lexAbbrvBlock start="^\(\h\+\s\|%{\)" end="^\ze%%$" skipnl nextgroup=lexPatBlock contains=lexAbbrv,lexInclude,lexAbbrvComment,lexStartState |
| 51 | endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 52 | syn match lexAbbrv "^\I\i*\s"me=e-1 skipwhite contained nextgroup=lexAbbrvRegExp |
| 53 | syn match lexAbbrv "^%[sx]" contained |
| 54 | syn match lexAbbrvRegExp "\s\S.*$"lc=1 contained nextgroup=lexAbbrv,lexInclude |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 55 | if has("folding") |
| 56 | syn region lexInclude fold matchgroup=lexSep start="^%{" end="%}" contained contains=ALLBUT,@lexListGroup |
| 57 | syn region lexAbbrvComment fold start="^\s\+/\*" end="\*/" contains=@Spell |
| 58 | syn region lexStartState fold matchgroup=lexAbbrv start="^%\a\+" end="$" contained |
| 59 | else |
| 60 | syn region lexInclude matchgroup=lexSep start="^%{" end="%}" contained contains=ALLBUT,@lexListGroup |
| 61 | syn region lexAbbrvComment start="^\s\+/\*" end="\*/" contains=@Spell |
| 62 | syn region lexStartState matchgroup=lexAbbrv start="^%\a\+" end="$" contained |
| 63 | endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 64 | |
| 65 | "%% : Patterns {Actions} |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 66 | if has("folding") |
Bram Moolenaar | 81af925 | 2010-12-10 20:35:50 +0100 | [diff] [blame] | 67 | syn region lexPatBlock fold matchgroup=Todo start="^%%$" matchgroup=Todo end="^%%$" skipnl skipwhite contains=lexPatTag,lexPatTagZone,lexPatComment,lexPat,lexPatInclude |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 68 | syn region lexPat fold start=+\S+ skip="\\\\\|\\." end="\s"me=e-1 contained nextgroup=lexMorePat,lexPatSep contains=lexPatTag,lexPatString,lexSlashQuote,lexBrace |
Bram Moolenaar | 81af925 | 2010-12-10 20:35:50 +0100 | [diff] [blame] | 69 | syn region lexPatInclude fold matchgroup=lexSep start="^%{" end="%}" contained contains=lexPatCode |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 70 | syn region lexBrace fold start="\[" skip=+\\\\\|\\+ end="]" contained |
| 71 | syn region lexPatString fold matchgroup=String start=+"+ skip=+\\\\\|\\"+ matchgroup=String end=+"+ contained |
| 72 | else |
Bram Moolenaar | 81af925 | 2010-12-10 20:35:50 +0100 | [diff] [blame] | 73 | syn region lexPatBlock matchgroup=Todo start="^%%$" matchgroup=Todo end="^%%$" skipnl skipwhite contains=lexPatTag,lexPatTagZone,lexPatComment,lexPat,lexPatInclude |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 74 | syn region lexPat start=+\S+ skip="\\\\\|\\." end="\s"me=e-1 contained nextgroup=lexMorePat,lexPatSep contains=lexPatTag,lexPatString,lexSlashQuote,lexBrace |
Bram Moolenaar | 81af925 | 2010-12-10 20:35:50 +0100 | [diff] [blame] | 75 | syn region lexPatInclude matchgroup=lexSep start="^%{" end="%}" contained contains=lexPatCode |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 76 | syn region lexBrace start="\[" skip=+\\\\\|\\+ end="]" contained |
| 77 | syn region lexPatString matchgroup=String start=+"+ skip=+\\\\\|\\"+ matchgroup=String end=+"+ contained |
| 78 | endif |
| 79 | syn match lexPatTag "^<\I\i*\(,\I\i*\)*>" contained nextgroup=lexPat,lexPatTag,lexMorePat,lexPatSep |
| 80 | syn match lexPatTagZone "^<\I\i*\(,\I\i*\)*>\s*\ze{" contained nextgroup=lexPatTagZoneStart |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 81 | syn match lexPatTag +^<\I\i*\(,\I\i*\)*>*\(\\\\\)*\\"+ contained nextgroup=lexPat,lexPatTag,lexMorePat,lexPatSep |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 82 | if has("folding") |
| 83 | syn region lexPatTagZoneStart matchgroup=lexPatTag fold start='{' end='}' contained contains=lexPat,lexPatComment |
| 84 | syn region lexPatComment start="\s\+/\*" end="\*/" fold skipnl contained contains=cTodo skipwhite nextgroup=lexPatComment,lexPat,@Spell |
| 85 | else |
| 86 | syn region lexPatTagZoneStart matchgroup=lexPatTag start='{' end='}' contained contains=lexPat,lexPatComment |
| 87 | syn region lexPatComment start="\s\+/\*" end="\*/" skipnl contained contains=cTodo skipwhite nextgroup=lexPatComment,lexPat,@Spell |
| 88 | endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 89 | syn match lexPatCodeLine ".*$" contained contains=ALLBUT,@lexListGroup |
| 90 | syn match lexMorePat "\s*|\s*$" skipnl contained nextgroup=lexPat,lexPatTag,lexPatComment |
| 91 | syn match lexPatSep "\s\+" contained nextgroup=lexMorePat,lexPatCode,lexPatCodeLine |
| 92 | syn match lexSlashQuote +\(\\\\\)*\\"+ contained |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 93 | if has("folding") |
| 94 | syn region lexPatCode matchgroup=Delimiter start="{" end="}" fold skipnl contained contains=ALLBUT,@lexListPatCodeGroup |
| 95 | else |
| 96 | syn region lexPatCode matchgroup=Delimiter start="{" end="}" skipnl contained contains=ALLBUT,@lexListPatCodeGroup |
| 97 | endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 98 | |
| 99 | syn keyword lexCFunctions BEGIN input unput woutput yyleng yylook yytext |
| 100 | syn keyword lexCFunctions ECHO output winput wunput yyless yymore yywrap |
| 101 | |
| 102 | " <c.vim> includes several ALLBUTs; these have to be treated so as to exclude lex* groups |
| 103 | syn cluster cParenGroup add=lex.* |
| 104 | syn cluster cDefineGroup add=lex.* |
| 105 | syn cluster cPreProcGroup add=lex.* |
| 106 | syn cluster cMultiGroup add=lex.* |
| 107 | |
| 108 | " Synchronization |
| 109 | syn sync clear |
| 110 | syn sync minlines=300 |
| 111 | syn sync match lexSyncPat grouphere lexPatBlock "^%[a-zA-Z]" |
| 112 | syn sync match lexSyncPat groupthere lexPatBlock "^<$" |
| 113 | syn sync match lexSyncPat groupthere lexPatBlock "^%%$" |
| 114 | |
| 115 | " The default highlighting. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 116 | hi def link lexAbbrvComment lexPatComment |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 117 | hi def link lexBrace lexPat |
| 118 | hi def link lexPatTagZone lexPatTag |
| 119 | hi def link lexSlashQuote lexPat |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 120 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 121 | hi def link lexAbbrvRegExp Macro |
Bram Moolenaar | d4755bb | 2004-09-02 19:12:26 +0000 | [diff] [blame] | 122 | hi def link lexAbbrv SpecialChar |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 123 | hi def link lexCFunctions Function |
| 124 | hi def link lexMorePat SpecialChar |
Bram Moolenaar | 81af925 | 2010-12-10 20:35:50 +0100 | [diff] [blame] | 125 | hi def link lexOptions PreProc |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 126 | hi def link lexPatComment Comment |
Bram Moolenaar | d4755bb | 2004-09-02 19:12:26 +0000 | [diff] [blame] | 127 | hi def link lexPat Function |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 128 | hi def link lexPatString Function |
| 129 | hi def link lexPatTag Special |
| 130 | hi def link lexSep Delimiter |
Bram Moolenaar | d4755bb | 2004-09-02 19:12:26 +0000 | [diff] [blame] | 131 | hi def link lexStartState Statement |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 132 | |
| 133 | let b:current_syntax = "lex" |
| 134 | |
| 135 | " vim:ts=10 |