Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
lex.vim191 linesDownload Raw Back to syntax
1" Vim syntax file2" Language:	Lex and Flex3" Maintainer:	This runtime file is looking for a new maintainer.4" Former Maintainer:	Charles E. Campbell5" Contributor:	Robert A. van Engelen <engelen@acm.org>6" Version:	187" Last Change:	Apr 24, 20208"   2024 Feb 19 by Vim Project (announce adoption)9 10" quit when a syntax file was already loaded11if exists("b:current_syntax")12  finish13endif14 15" Read the C++ syntax to start with16let s:Cpath= fnameescape(expand("<sfile>:p:h")."/cpp.vim")17if !filereadable(s:Cpath)18 for s:Cpath in split(globpath(&rtp,"syntax/cpp.vim"),"\n")19  if filereadable(fnameescape(s:Cpath))20   let s:Cpath= fnameescape(s:Cpath)21   break22  endif23 endfor24endif25exe "syn include @lexCcode ".s:Cpath26 27" --- ========= ---28" --- Lex stuff ---29" --- ========= ---30 31" Definitions32" %%33" Rules34" %%35" User Code36"37" --- ======= ---38" --- Example ---39" --- ======= ---40"41"   // this is a valid lex file42"   // indented initial code block43"   #include <stdlib.h>44" %{45" // initial code block46" #include <stdio.h>47" const char *sep = "";48" %}49" %option outfile="scanner.c" noyywrap nodefault50" %x COMMENT51" id      [A-Za-z_][A-Za-z0-9_]*52" %%53"   // indented initial action code block54"   printf("BEGIN");55" {id}    printf("%s%s", sep, yytext); sep = "";56" .       |57" \n      { sep = "\n"; }58" "/*"    { BEGIN COMMENT; }59" "//".*  { }60" <COMMENT>{61" "*/"    { BEGIN INITIAL; }62" .|\n    63" }64" <*><<EOF>> { // end of file65"              printf("\nEND\n");66"              yyterminate();67"            }68" %%69" void scan()70" {71"   while (yylex())72"     continue;73" }74" /* main program */75" int main()76" { 77"   scan();78" }   79 80" Definitions Section with initial code blocks, abbreviations, options, states81if has("folding")82 syn region lexAbbrvBlock	fold	start="^\S"	end="^\ze%%"	skipnl	nextgroup=lexPatBlock	contains=lexOptions,lexAbbrv,lexInitialCodeBlock,lexInclude,lexAbbrvComment,lexStartState83else84 syn region lexAbbrvBlock		start="^\S"	end="^\ze%%"	skipnl	nextgroup=lexPatBlock	contains=lexOptions,lexAbbrv,lexInitialCodeBlock,lexInclude,lexAbbrvComment,lexStartState85endif86syn match  lexOptions		"^%\a\+\(\s.*\|[^{]*\)$"				contains=lexOptionsEq,lexPatString,lexSlashQuote,lexBrace,lexSlashBrace87syn match  lexOptionsEq		"="					skipwhite	contained88syn match  lexAbbrv		"^\I\i*\s"me=e-1			skipwhite	contained	nextgroup=lexAbbrvPat89syn match  lexAbbrvPat		"\s\S.*$"lc=1						contained	contains=lexPatAbbrv,lexPatString,lexSlashQuote,lexBrace,lexSlashBrace	nextgroup=lexAbbrv,lexInclude90syn match  lexStartState	"^%\(xs\?\|s\)\(t\(a\(t\(e\?\)\?\)\?\)\?\)\?\(\s\+\I\i*\)\+\s*$"	contained	contains=lexStartStateCmd91syn match  lexStartStateCmd	'^%\(xs\?\|s\)\(t\(a\(t\(e\?\)\?\)\?\)\?\)\?'	contained92if has("folding")93 syn region lexInitialCodeBlock	fold				start="^\s\+"	end="^\S"me=e-1			contains=@lexCcode94 syn region lexInclude		fold	matchgroup=lexSep	start="^%\a*{"	end="^%\?}"	contained	contains=@lexCcode,lexCFunctions95 syn region lexAbbrvComment	fold				start="^\s*//"	end="$"		contains=@Spell96 syn region lexAbbrvComment	fold				start="^\s*/\*"	end="\*/"	contains=@Spell97else98 syn region lexInitialCodeBlock					start="^\s\+"	end="^\S"me=e-1			contains=@lexCcode99 syn region lexInclude			matchgroup=lexSep	start="^%\a*{"	end="^%\?}"	contained	contains=@lexCcode,lexCFunctions100 syn region lexAbbrvComment					start="^\s*//"	end="$"		contains=@Spell101 syn region lexAbbrvComment					start="^\s*/\*"	end="\*/"	contains=@Spell102endif103 104" Rules Section with patterns and actions105if has("folding")106 syn region lexPatBlock		fold	matchgroup=Todo		start="^%%"	matchgroup=Todo		end="^\ze%%"	skipnl	skipwhite	nextgroup=lexFinalCodeBlock	contains=lexPatTag,lexPatTagZone,lexPatComment,lexPat,lexPatSep,lexPatInclude107 syn region lexPat		fold				start="\S"	skip="\\\\\|\\\s"	end="\ze\(\s*$\|\s\+\(\h\|{\W\|{$\|[-+*]\|//\|/\*\)\)"	skipwhite	contained nextgroup=lexMorePat,lexPatSep,lexPatEnd	contains=lexPatTag,lexPatString,lexSlashQuote,lexPatAbbrv,lexBrace,lexSlashBrace108 syn region lexPatInclude	fold	matchgroup=lexSep	start="^%{"	end="^%}"	contained	contains=@lexCcode109 syn region lexBrace		fold	matchgroup=Character	start="\["	skip="\\.\|\[:\a\+:\]\|\[\.\a\+\.\]\|\[=.=\]"	end="\]"	contained110 syn region lexPatString	fold	matchgroup=String	start=+"+	skip=+\\\\\|\\"+	matchgroup=String	end=+"+	contained111else112 syn region lexPatBlock			matchgroup=Todo		start="^%%"	matchgroup=Todo		end="^\ze%%"	skipnl	skipwhite	nextgroup=lexFinalCodeBlock	contains=lexPatTag,lexPatTagZone,lexPatComment,lexPat,lexPatSep,lexPatInclude113 syn region lexPat						start="\S"	skip="\\\\\|\\\s"	end="\ze\(\s*$\|\s\+\(\h\|{\W\|{$\|[-+*]\|//\|/\*\)\)"	skipwhite	contained nextgroup=lexMorePat,lexPatSep,lexPatEnd	contains=lexPatTag,lexPatString,lexSlashQuote,lexPatAbbrv,lexBrace,lexSlashBrace114 syn region lexPatInclude		matchgroup=lexSep	start="^%{"	end="^%}"	contained	contains=@lexCcode115 syn region lexBrace			matchgroup=Character	start="\["	skip="\\.\|\[:\a\+:\]\|\[\.\a\+\.\]\|\[=.=\]"	end="\]"	contained116 syn region lexPatString		matchgroup=String	start=+"+	skip=+\\\\\|\\"+	matchgroup=String	end=+"+	contained117endif118syn match  lexPatAbbrv		"{\I\i*}"hs=s+1,he=e-1					contained119syn match  lexPatTag		"^<\^\?\(\I\i*\|\*\)\(,\^\?\(\I\i*\|\*\)\)*>"		contained	nextgroup=lexPat,lexMorePat,lexPatSep,lexPatEnd120syn match  lexPatTagZone	"^<\^\?\(\I\i*\|\*\)\(,\^\?\(\I\i*\|\*\)\)*>\s*{$"me=e-1	contained	nextgroup=lexPatTagZoneStart121 122if has("folding")123 syn region lexPatTagZoneStart	fold	matchgroup=lexPatTag	start='{$'	end='^}'	skipnl	skipwhite	contained	contains=lexPatTag,lexPatTagZone,lexPatComment,lexPat,lexPatSep,lexPatInclude124 syn region lexPatComment	fold	start="//"	end="$"		skipnl	contained	contains=cTodo	skipwhite	nextgroup=lexPatComment,lexPat,@Spell125 syn region lexPatComment	fold	start="/\*"	end="\*/"	skipnl	contained	contains=cTodo	skipwhite	nextgroup=lexPatComment,lexPat,@Spell126else127 syn region lexPatTagZoneStart		matchgroup=lexPatTag		start='{'	end='^}'	skipnl	skipwhite	contained	contains=lexPatTag,lexPatTagZone,lexPatComment,lexPat,lexPatSep,lexPatInclude128 syn region lexPatComment		start="//"	end="$"		skipnl	contained	contains=cTodo	skipwhite	nextgroup=lexPatComment,lexPat,@Spell129 syn region lexPatComment		start="/\*"	end="\*/"	skipnl	contained	contains=cTodo	skipwhite	nextgroup=lexPatComment,lexPat,@Spell130endif131syn match  lexPatEnd		"\s*$"				skipnl	contained132syn match  lexPatCodeLine	"[^{\[].*"				contained	contains=@lexCcode,lexCFunctions133syn match  lexMorePat		"\s*|\s*$"			skipnl	contained	nextgroup=lexPat,lexPatTag,lexPatComment134syn match  lexPatSep		"\s\+"					contained	nextgroup=lexMorePat,lexPatCode,lexPatCodeLine135syn match  lexSlashQuote	+\(\\\\\)*\\"+				contained136syn match  lexSlashBrace	+\(\\\\\)*\\\[+				contained137if has("folding")138 syn region lexPatCode		fold	matchgroup=Delimiter	start="{"	end="}"	skipnl	contained	contains=@lexCcode,lexCFunctions139else140 syn region lexPatCode			matchgroup=Delimiter	start="{"	end="}"	skipnl	contained	contains=@lexCcode,lexCFunctions141endif142 143" User Code Section with final code block144syn region lexFinalCodeBlock	matchgroup=Todo	start="^%%"	end="\%$"	contained	contains=@lexCcode145 146" Lex macros which may appear in C/C++ code blocks147syn keyword lexCFunctions	BEGIN	ECHO	REJECT	yytext	YYText	yyleng	YYLeng	yymore	yyless	yywrap	yylook148syn keyword lexCFunctions	yyrestart	yyterminate	yylineno	yycolumno	yyin	yyout149syn keyword lexCFunctions	input	unput	output		winput		wunput		woutput150syn keyword lexCFunctions	yyinput	yyunput	yyoutput	yywinput	yywunput	yywoutput151 152" <c.vim> includes several ALLBUTs; these have to be treated so as to exclude lex* groups153syn cluster cParenGroup		add=lex.*154syn cluster cDefineGroup	add=lex.*155syn cluster cPreProcGroup	add=lex.*156syn cluster cMultiGroup		add=lex.*157 158" Synchronization159syn sync clear160syn sync minlines=500161syn sync match lexSyncPat	grouphere  lexPatBlock	"^%[a-zA-Z]"162syn sync match lexSyncPat	groupthere lexPatBlock	"^<$"163syn sync match lexSyncPat	groupthere lexPatBlock	"^%%"164 165" The default highlighting.166if !exists("skip_lex_syntax_inits")167 hi def link lexAbbrvComment	lexPatComment168 hi def link lexAbbrvPat	lexPat169 hi def link lexAbbrv		Special170 hi def link lexBrace		lexPat171 hi def link lexCFunctions	PreProc172 hi def link lexMorePat		Special173 hi def link lexOptions		PreProc174 hi def link lexOptionsEq	Operator175 hi def link lexPatComment	Comment176 hi def link lexPat		Function177 hi def link lexPatString	lexPat178 hi def link lexPatAbbrv	Special179 hi def link lexPatTag		Statement180 hi def link lexPatTagZone	lexPatTag181 hi def link lexSep		Delimiter182 hi def link lexSlashQuote	lexPat183 hi def link lexSlashBrace	lexPat184 hi def link lexStartState	lexPatTag185 hi def link lexStartStateCmd	Special186endif187 188let b:current_syntax = "lex"189 190" vim:ts=8191 
codekingpro/portable-devtools · Team Ai