xref: /vim-8.2.3635/runtime/syntax/lex.vim (revision 044b68f4)
1" Vim syntax file
2" Language:	Lex
3" Maintainer:	Dr. Charles E. Campbell, Jr. <[email protected]>
4" Last Change:	Sep 06, 2005
5" Version:	7
6" URL:	http://mysite.verizon.net/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" --- ========= ---
36" --- Lex stuff ---
37" --- ========= ---
38
39"I'd prefer to use lex.* , but it doesn't handle forward definitions yet
40syn 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
41syn 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
44syn region lexAbbrvBlock	start="^\(\h\+\s\|%{\)" end="^\ze%%$"	skipnl	nextgroup=lexPatBlock contains=lexAbbrv,lexInclude,lexAbbrvComment,lexStartState
45syn match  lexAbbrv		"^\I\i*\s"me=e-1			skipwhite	contained nextgroup=lexAbbrvRegExp
46syn match  lexAbbrv		"^%[sx]"					contained
47syn match  lexAbbrvRegExp	"\s\S.*$"lc=1				contained nextgroup=lexAbbrv,lexInclude
48syn region lexInclude	matchgroup=lexSep	start="^%{" end="%}"	contained	contains=ALLBUT,@lexListGroup
49syn region lexAbbrvComment	start="^\s\+/\*"	end="\*/"			contains=@Spell
50syn region lexStartState	matchgroup=lexAbbrv	start="^%\a\+"	end="$"			contained
51
52"%% : Patterns {Actions}
53syn region lexPatBlock	matchgroup=Todo	start="^%%$" matchgroup=Todo end="^%%$"	skipnl skipwhite contains=lexPat,lexPatTag,lexPatComment
54syn region lexPat		start=+\S+ skip="\\\\\|\\."	end="\s"me=e-1	contained nextgroup=lexMorePat,lexPatSep contains=lexPatString,lexSlashQuote,lexBrace
55syn region lexBrace	start="\[" skip=+\\\\\|\\+		end="]"		contained
56syn region lexPatString	matchgroup=String start=+"+	skip=+\\\\\|\\"+	matchgroup=String end=+"+	contained
57syn match  lexPatTag	"^<\I\i*\(,\I\i*\)*>*"			contained nextgroup=lexPat,lexPatTag,lexMorePat,lexPatSep
58syn match  lexPatTag	+^<\I\i*\(,\I\i*\)*>*\(\\\\\)*\\"+		contained nextgroup=lexPat,lexPatTag,lexMorePat,lexPatSep
59syn region lexPatComment	start="^\s*/\*" end="\*/"		skipnl	contained contains=cTodo skipwhite nextgroup=lexPatComment,lexPat,@Spell
60syn match  lexPatCodeLine	".*$"					contained contains=ALLBUT,@lexListGroup
61syn match  lexMorePat	"\s*|\s*$"			skipnl	contained nextgroup=lexPat,lexPatTag,lexPatComment
62syn match  lexPatSep	"\s\+"					contained nextgroup=lexMorePat,lexPatCode,lexPatCodeLine
63syn match  lexSlashQuote	+\(\\\\\)*\\"+				contained
64syn region lexPatCode matchgroup=Delimiter start="{" matchgroup=Delimiter end="}"	skipnl contained contains=ALLBUT,@lexListPatCodeGroup
65
66syn keyword lexCFunctions	BEGIN	input	unput	woutput	yyleng	yylook	yytext
67syn 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
70syn cluster cParenGroup	add=lex.*
71syn cluster cDefineGroup	add=lex.*
72syn cluster cPreProcGroup	add=lex.*
73syn cluster cMultiGroup	add=lex.*
74
75" Synchronization
76syn sync clear
77syn sync minlines=300
78syn sync match lexSyncPat	grouphere  lexPatBlock	"^%[a-zA-Z]"
79syn sync match lexSyncPat	groupthere lexPatBlock	"^<$"
80syn sync match lexSyncPat	groupthere lexPatBlock	"^%%$"
81
82" The default highlighting.
83hi def link lexSlashQuote	lexPat
84hi def link lexBrace	lexPat
85hi def link lexAbbrvComment	lexPatComment
86
87hi def link lexAbbrvRegExp	Macro
88hi def link lexAbbrv	SpecialChar
89hi def link lexCFunctions	Function
90hi def link lexMorePat	SpecialChar
91hi def link lexPatComment	Comment
92hi def link lexPat		Function
93hi def link lexPatString	Function
94hi def link lexPatTag	Special
95hi def link lexSep		Delimiter
96hi def link lexStartState	Statement
97
98let b:current_syntax = "lex"
99
100" vim:ts=10
101