Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Problem in C highlight with
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Bram Moolenaar  
View profile  
 More options May 2 2012, 2:55 pm
From: Bram Moolenaar <B...@Moolenaar.net>
Date: Wed, 02 May 2012 20:55:50 +0200
Local: Wed, May 2 2012 2:55 pm
Subject: Re: Problem in C highlight with

The problem is that when we allow {} inside () then there is no way to
check for a missing ).  Therefore this is optional.
You can set the c_no_curly_error variable, see ":help c.vim".

--
Yesterday, all my deadlines seemed so far away
now it looks as though it's freeze in four days
oh I believe in cvs..
    [ CVS log "Beatles style" for FreeBSD ports/INDEX, Satoshi Asami ]

 /// Bram Moolenaar -- B...@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lucas De Marchi  
View profile  
 More options May 2 2012, 10:46 am
From: Lucas De Marchi <lucas.de.mar...@gmail.com>
Date: Wed, 2 May 2012 11:46:24 -0300
Local: Wed, May 2 2012 10:46 am
Subject: Problem in C highlight with
The following snippet breaks C syntax highlight for me. I'm using VIM 7.3.495

#define GDBUS_ARGS_INFO(args...) (const GDBusArgInfo[]) { args, { } }

static const GDBusMethodTable char_methods[] = {
        {
                "GetProperties", "", "a{sv}", get_properties,
                .out_args = GDBUS_ARGS_INFO({ "properties", "a{sv}" })
        },
        { }

};

If i change the "}" inside the string to \7xd, the problem disappears.
It appears that the problem is related to the open parenthesis and the
close bracket. If I use anything that do not open a parenthesis, then
it's back working.

Is there a way to properly fix this in c.vim?

Regards,
Lucas De Marchi


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lucas De Marchi  
View profile  
 More options May 2 2012, 3:15 pm
From: Lucas De Marchi <lucas.de.mar...@gmail.com>
Date: Wed, 2 May 2012 16:15:15 -0300
Local: Wed, May 2 2012 3:15 pm
Subject: Re: Problem in C highlight with

On Wed, May 2, 2012 at 3:55 PM, Bram Moolenaar <B...@moolenaar.net> wrote:
> The problem is that when we allow {} inside () then there is no way to
> check for a missing ).  Therefore this is optional.
> You can set the c_no_curly_error variable, see ":help c.vim".

After setting that, { inside ( was not marked as an error, but the bug
remained. The rest of the file is highlighted as if it was inside the
string :(

Lucas De Marchi


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bram Moolenaar  
View profile  
 More options May 3 2012, 3:05 pm
From: Bram Moolenaar <B...@Moolenaar.net>
Date: Thu, 03 May 2012 21:05:05 +0200
Local: Thurs, May 3 2012 3:05 pm
Subject: Re: Problem in C highlight with

Lucas De Marchi wrote:
> On Wed, May 2, 2012 at 3:55 PM, Bram Moolenaar <B...@moolenaar.net> wrote:
> > The problem is that when we allow {} inside () then there is no way to
> > check for a missing ).  Therefore this is optional.
> > You can set the c_no_curly_error variable, see ":help c.vim".

> After setting that, { inside ( was not marked as an error, but the bug
> remained. The rest of the file is highlighted as if it was inside the
> string :(

Hmm, there are some weird dependencies with extend and keepend.  Try the
c.vim file below.  It might introduce new problems though.

" Vim syntax file
" Language:        C
" Maintainer:      Bram Moolenaar <B...@vim.org>
" Last Change:     2012 May 03

" Quit when a (custom) syntax file was already loaded
if exists("b:current_syntax")
  finish
endif

let s:cpo_save = &cpo
set cpo&vim

" A bunch of useful C keywords
syn keyword     cStatement      goto break return continue asm
syn keyword     cLabel          case default
syn keyword     cConditional    if else switch
syn keyword     cRepeat         while for do

syn keyword     cTodo           contained TODO FIXME XXX

" It's easy to accidentally add a space after a backslash that was intended
" for line continuation.  Some compilers allow it, which makes it
" unpredicatable and should be avoided.
syn match       cBadContinuation contained "\\\s\+$"

" cCommentGroup allows adding matches for special things in comments
syn cluster     cCommentGroup   contains=cTodo,cBadContinuation

" String and Character constants
" Highlight special characters (those which have a backslash) differently
syn match       cSpecial        display contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)"
if !exists("c_no_utf")
  syn match     cSpecial        display contained "\\\(u\x\{4}\|U\x\{8}\)"
endif
if exists("c_no_cformat")
  syn region    cString         start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,@Spell extend
  " cCppString: same as cString, but ends at end of line
  syn region    cCppString      start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,@Spell
else
  if !exists("c_no_c99") " ISO C99
    syn match   cFormat         display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlLjzt]\|ll\|hh\) \=\([aAbdiuoxXDOUfFeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained
  else
    syn match   cFormat         display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlL]\|ll\)\=\([bd iuoxXDOUfeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained
  endif
  syn match     cFormat         display "%%" contained
  syn region    cString         start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend
  " cCppString: same as cString, but ends at end of line
  syn region    cCppString      start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell
endif

syn match       cCharacter      "L\='[^\\]'"
syn match       cCharacter      "L'[^']*'" contains=cSpecial
if exists("c_gnu")
  syn match     cSpecialError   "L\='\\[^'\"?\\abefnrtv]'"
  syn match     cSpecialCharacter "L\='\\['\"?\\abefnrtv]'"
else
  syn match     cSpecialError   "L\='\\[^'\"?\\abfnrtv]'"
  syn match     cSpecialCharacter "L\='\\['\"?\\abfnrtv]'"
endif
syn match       cSpecialCharacter display "L\='\\\o\{1,3}'"
syn match       cSpecialCharacter display "'\\x\x\{1,2}'"
syn match       cSpecialCharacter display "L'\\x\x\+'"

if !exists("c_no_c11") " ISO C11
  if exists("c_no_cformat")
    syn region  cString         start=+\%(U\|u8\=\)"+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,@Spell extend
  else
    syn region  cString         start=+\%(U\|u8\=\)"+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend
  endif
  syn match     cCharacter      "[Uu]'[^\\]'"
  syn match     cCharacter      "[Uu]'[^']*'" contains=cSpecial
  if exists("c_gnu")
    syn match   cSpecialError   "[Uu]'\\[^'\"?\\abefnrtv]'"
    syn match   cSpecialCharacter "[Uu]'\\['\"?\\abefnrtv]'"
  else
    syn match   cSpecialError   "[Uu]'\\[^'\"?\\abfnrtv]'"
    syn match   cSpecialCharacter "[Uu]'\\['\"?\\abfnrtv]'"
  endif
  syn match     cSpecialCharacter display "[Uu]'\\\o\{1,3}'"
  syn match     cSpecialCharacter display "[Uu]'\\x\x\+'"
endif

"when wanted, highlight trailing white space
if exists("c_space_errors")
  if !exists("c_no_trail_space_error")
    syn match   cSpaceError     display excludenl "\s\+$"
  endif
  if !exists("c_no_tab_space_error")
    syn match   cSpaceError     display " \+\t"me=e-1
  endif
endif

" This should be before cErrInParen to avoid problems with #define ({ xxx })
if exists("c_curly_error")
  syntax match cCurlyError "}"
  syntax region cBlock          start="{" end="}" contains=ALLBUT,cBadBlock,cCurlyError,@cParenGroup,cErrInParen,cCppParen,cE rrInBracket,cCppBracket,cCppString,@Spell fold
else
  syntax region cBlock          start="{" end="}" transparent fold
endif

"catch errors caused by wrong parenthesis and brackets
" also accept <% for {, %> for }, <: for [ and :> for ] (C99)
" But avoid matching <::.
syn cluster     cParenGroup     contains=cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cCommen t2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,c OctalZero,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumber sCom
if exists("c_no_curly_error")
  syn region    cParen          transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,cCppString,@Spell
  " cCppParen: same as cParen but ends at end-of-line; used in cDefine
  syn region    cCppParen       transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell
  syn match     cParenError     display ")"
  syn match     cErrInParen     display contained "^[{}]\|^<%\|^%>"
elseif exists("c_no_bracket_error")
  syn region    cParen          transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,cCppString,@Spell
  " cCppParen: same as cParen but ends at end-of-line; used in cDefine
  syn region    cCppParen       transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell
  syn match     cParenError     display ")"
  syn match     cErrInParen     display contained "[{}]\|<%\|%>"
else
  syn region    cParen          transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,cCp pString,@Spell
  " cCppParen: same as cParen but ends at end-of-line; used in cDefine
  syn region    cCppParen       transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell
  syn match     cParenError     display "[\])]"
  syn match     cErrInParen     display contained "[\]{}]\|<%\|%>"
  syn region    cBracket        transparent start='\[\|<::\@!' end=']\|:>' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cErrInParen,cCppParen,cCppBracket,cCppS tring,@Spell
  " cCppBracket: same as cParen but ends at end-of-line; used in cDefine
  syn region    cCppBracket     transparent start='\[\|<::\@!' skip='\\$' excludenl end=']\|:>' end='$' contained contains=ALLBUT,@cParenGroup,cErrInParen,cParen,cBracket,cString,@Spell
  syn match     cErrInBracket   display contained "[);{}]\|<%\|%>"
endif

syntax region   cBadBlock       keepend start="{" end="}" contained containedin=cParen,cBracket,cBadBlock transparent fold

"integer number, or floating point number without a dot and with "f".
syn case ignore
syn match       cNumbers        display transparent "\<\d\|\.\d" contains=cNumber,cFloat,cOctalError,cOctal
" Same, but without octal error (for comments)
syn match       cNumbersCom     display contained transparent "\<\d\|\.\d" contains=cNumber,cFloat,cOctal
syn match       cNumber         display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>"
"hex number
syn match       cNumber         display contained "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>"
" Flag the first zero of an octal number as something special
syn match       cOctal          display contained "0\o\+\(u\=l\{0,2}\|ll\=u\)\>" contains=cOctalZero
syn match       cOctalZero      display contained "\<0"
syn match       cFloat          display contained "\d\+f"
"floating point number, with dot, optional exponent
syn match       cFloat          display contained "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\="
"floating point number, starting with a dot, optional exponent
syn match       cFloat          display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
"floating point number, without dot, with exponent
syn match       cFloat          display contained "\d\+e[-+]\=\d\+[fl]\=\>"
if !exists("c_no_c99")
  "hexadecimal floating point number, optional leading digits, with dot, with exponent
  syn match     cFloat          display contained "0x\x*\.\x\+p[-+]\=\d\+[fl]\=\>"
  "hexadecimal floating point number, with leading digits, optional dot, with exponent
  syn match     cFloat          display contained "0x\x\+\.\=p[-+]\=\d\+[fl]\=\>"
endif

" flag an octal number with wrong digits
syn match       cOctalError     display contained "0\o*[89]\d*"
syn case match

if exists("c_comment_strings")
  " A comment can contain cString, cCharacter and cNumber.
  " But a "*/" inside a cString in a cComment DOES end the comment!  So we
  " need to use a special type of cString: cCommentString, which also ends on
  " "*/", and sees a "*" at the start of the line as comment again.
  " Unfortunately this doesn't very well work for // type of comments :-(
  syntax match  cCommentSkip    contained "^\s*\*\($\|\s\+\)"
  syntax region cCommentString  contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end=+\*/+me=s-1 contains=cSpecial,cCommentSkip
  syntax region cComment2String contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end="$" contains=cSpecial
  syntax region  cCommentL      start="//" skip="\\$" end="$" keepend contains=@cCommentGroup,cComment2String,cCharacter,cNumbersCom,cSpaceError, @Spell
  if exists("c_no_comment_fold")
    " Use "extend" here to have preprocessor lines not terminate halfway a
    " comment.
    syntax region cComment      matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cCommentString,cCharacter,cNumbe rsCom,cSpaceError,@Spell extend
  else
    syntax region cComment      matchgroup=cCommentStart start="/\*" end="\*/"
...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lucas De Marchi  
View profile  
 More options May 3 2012, 4:36 pm
From: Lucas De Marchi <lucas.de.mar...@gmail.com>
Date: Thu, 3 May 2012 17:36:20 -0300
Local: Thurs, May 3 2012 4:36 pm
Subject: Re: Problem in C highlight with

On Thu, May 3, 2012 at 4:05 PM, Bram Moolenaar <B...@moolenaar.net> wrote:

> Lucas De Marchi wrote:

>> On Wed, May 2, 2012 at 3:55 PM, Bram Moolenaar <B...@moolenaar.net> wrote:
>> > The problem is that when we allow {} inside () then there is no way to
>> > check for a missing ).  Therefore this is optional.
>> > You can set the c_no_curly_error variable, see ":help c.vim".

>> After setting that, { inside ( was not marked as an error, but the bug
>> remained. The rest of the file is highlighted as if it was inside the
>> string :(

> Hmm, there are some weird dependencies with extend and keepend.  Try the
> c.vim file below.  It might introduce new problems though.

It's correctly highlighted now and with a quick look, I don't see any
other problems.

Thanks
Lucas De Marchi


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »