Dominique Pellé wrote:
> On Mon, Mar 8, 2010 at 12:07 AM, Charles E Campbell Jr
> <[email protected]> wrote:
>
>> Dominique Pellé wrote:
>>>
>>> Hi
>>>
>>> Attached patch fixes a syntax highlighting problem in Vim-7.2.385
>>> when opening the attached flex file "foo.l".
>>>
>>> Notice how syntax hightlighting is wrong right after
>>> "<def_mode>{ID}" in the first screenshot.
>>>
>>> http://dominique.pelle.free.fr/pic/flex-syntax-highlighting-before.png
>>> http://dominique.pelle.free.fr/pic/flex-syntax-highlighting-after.png
>>>
>>
>> Unfortunately this patch destroys the capability to handle "start condition
>> scopes".
>>
>> <SCs>{
>> list of rules (ith <SCs> prefixes automatically applied)
>> }
>>
>> A SCs is a list of one or more start conditions. See
>> http://dinosaur.compilertools.net/flex/manpage.html .
>
>
> You're right. I was aware of the "start conditions" (my sample
> flex file which showed broken syntax highlighting in Vim
> contained one) but I was not aware of the "start condition
> scopes". Hmmm, it's harder to fix the highlighting problem
> then. Curly braces are used for all kind of things in flex files:
> - in regexes to match something n times: (e.g. r{2,5})
> - in references to name definitions (e.g. {DIGIT})
> - for start condition scopes, which can be nested
> multiple times (e.g. <SCs>{ ... })
> - to delimit the action (these should always have space(s)
> before them according to your link)
>
> I'm don't really know vim syntax file enough yet to fix.
> Time to read ":help syntax"...
>
> -- Dominique
What about the new attached patch?
It adds a the syntax group lexPatAbbrRef for references
to name definitions (i.e. things like {ID} for example).
With attached patch, Vim correctly hightlights the following
sample flex file (incorrectly highlighted without patch):
ID [a-zA-Z0-9_]+
%x def_mode
%%
<def_mode>{
foo { /* just a comment */ }
}
<def_mode>{ID} { /* just a comment */ }
%%
/* Just a comment */
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff -r 907cf09fbb32 runtime/syntax/lex.vim
--- a/runtime/syntax/lex.vim Tue Mar 02 18:16:09 2010 +0100
+++ b/runtime/syntax/lex.vim Mon Mar 08 23:12:24 2010 +0100
@@ -37,7 +37,7 @@
" --- ========= ---
"I'd prefer to use lex.* , but vim doesn't handle forward definitions yet
-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
+syn cluster lexListGroup contains=lexAbbrvBlock,lexAbbrv,lexAbbrv,lexAbbrvRegExp,lexInclude,lexPatBlock,lexPat,lexBrace,lexPatAbbrRef,lexPatString,lexPatTag,lexPatTag,lexPatComment,lexPatCodeLine,lexMorePat,lexPatSep,lexSlashQuote,lexPatCode,cInParen,cUserLabel,cOctalZero,cCppSkip,cErrInBracket,cErrInParen,cOctalError,cCppOut2,cCommentStartError,cParenError
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
" Abbreviations Section
@@ -62,17 +62,17 @@
"%% : Patterns {Actions}
if has("folding")
syn region lexPatBlock fold matchgroup=Todo start="^%%$" matchgroup=Todo end="^%%$" skipnl skipwhite contains=lexPatTag,lexPatTagZone,lexPatComment,lexPat
- syn region lexPat fold start=+\S+ skip="\\\\\|\\." end="\s"me=e-1 contained nextgroup=lexMorePat,lexPatSep contains=lexPatTag,lexPatString,lexSlashQuote,lexBrace
+ syn region lexPat fold start=+\S+ skip="\\\\\|\\." end="\s"me=e-1 contained nextgroup=lexMorePat,lexPatSep contains=lexPatTag,lexPatAbbrRef,lexPatString,lexSlashQuote,lexBrace
syn region lexBrace fold start="\[" skip=+\\\\\|\\+ end="]" contained
syn region lexPatString fold matchgroup=String start=+"+ skip=+\\\\\|\\"+ matchgroup=String end=+"+ contained
else
syn region lexPatBlock matchgroup=Todo start="^%%$" matchgroup=Todo end="^%%$" skipnl skipwhite contains=lexPatTag,lexPatTagZone,lexPatComment,lexPat
- syn region lexPat start=+\S+ skip="\\\\\|\\." end="\s"me=e-1 contained nextgroup=lexMorePat,lexPatSep contains=lexPatTag,lexPatString,lexSlashQuote,lexBrace
+ syn region lexPat start=+\S+ skip="\\\\\|\\." end="\s"me=e-1 contained nextgroup=lexMorePat,lexPatSep contains=lexPatTag,lexPatAbbrRef,lexPatString,lexSlashQuote,lexBrace
syn region lexBrace start="\[" skip=+\\\\\|\\+ end="]" contained
syn region lexPatString matchgroup=String start=+"+ skip=+\\\\\|\\"+ matchgroup=String end=+"+ contained
endif
syn match lexPatTag "^<\I\i*\(,\I\i*\)*>" contained nextgroup=lexPat,lexPatTag,lexMorePat,lexPatSep
-syn match lexPatTagZone "^<\I\i*\(,\I\i*\)*>\s*\ze{" contained nextgroup=lexPatTagZoneStart
+syn match lexPatTagZone "^<\I\i*\(,\I\i*\)*>\s*\ze{\(\h[A-Za-z0-9_-]*}\)\...@!" contained nextgroup=lexPatTagZoneStart
syn match lexPatTag +^<\I\i*\(,\I\i*\)*>*\(\\\\\)*\\"+ contained nextgroup=lexPat,lexPatTag,lexMorePat,lexPatSep
if has("folding")
syn region lexPatTagZoneStart matchgroup=lexPatTag fold start='{' end='}' contained contains=lexPat,lexPatComment
@@ -90,6 +90,7 @@
else
syn region lexPatCode matchgroup=Delimiter start="{" end="}" skipnl contained contains=ALLBUT,@lexListPatCodeGroup
endif
+syn match lexPatAbbrRef "{\h[A-Za-z0-9_-]*}" contained
syn keyword lexCFunctions BEGIN input unput woutput yyleng yylook yytext
syn keyword lexCFunctions ECHO output winput wunput yyless yymore yywrap
@@ -120,6 +121,7 @@
hi def link lexPatComment Comment
hi def link lexPat Function
hi def link lexPatString Function
+hi def link lexPatAbbrRef Macro
hi def link lexPatTag Special
hi def link lexSep Delimiter
hi def link lexStartState Statement