Home Download Buy Blog Forum Support

C/C++ syntax highlighting bug

C/C++ syntax highlighting bug

Postby Prazz on Sat Oct 20, 2012 4:39 pm

Arguments of macros which have more than one argument can't be hightlighted correctly.
Attachments
bug.jpg
bug.jpg (17.11 KiB) Viewed 3109 times
Prazz
 
Posts: 5
Joined: Sat Oct 20, 2012 4:16 pm

Re: C/C++ syntax highlighting bug

Postby pete340 on Sat Oct 20, 2012 7:13 pm

That's because the code has undefined behavior. <g>
pete340
 
Posts: 78
Joined: Mon Oct 10, 2011 9:45 pm

Re: C/C++ syntax highlighting bug

Postby Prazz on Mon Oct 22, 2012 11:05 am

pete340 wrote:That's because the code has undefined behavior. <g>


No, There is something wrong with the C.tmLanguage

Line 170: ((,) \s* \g&lt;id&gt; \s*)* // \g<id> dosen't work
Line 171: (?:\.\.\.)? // should be corrected as (?:,\s*\.\.\.\s*)?
Prazz
 
Posts: 5
Joined: Sat Oct 20, 2012 4:16 pm

Re: C/C++ syntax highlighting bug

Postby facelessuser on Mon Oct 22, 2012 4:39 pm

In short...

replace starting at line 162 with this:

            <key>begin</key>
<string>(?x)
^\s*\#\s*(define)\s+ # define
(([a-zA-Z_][a-zA-Z0-9_]*)) # macro name
(?: # and optionally:
(\() # an open parenthesis
(
\s* ([a-zA-Z_][a-zA-Z0-9_]*) \s* # first argument
((,) \s* ([a-zA-Z_][a-zA-Z0-9_]*) \s*)* # additional arguments
(?:,\s*\.\.\.\s*)? # varargs ellipsis?
)
(\)) # a close parenthesis
)?
</string>
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: C/C++ syntax highlighting bug

Postby pete340 on Mon Oct 22, 2012 5:15 pm

Prazz wrote:
pete340 wrote:That's because the code has undefined behavior. <g>


No, There is something wrong with the C.tmLanguage


Sigh. No sense of humor.
pete340
 
Posts: 78
Joined: Mon Oct 10, 2011 9:45 pm

Re: C/C++ syntax highlighting bug

Postby jwegrzyn on Tue Oct 23, 2012 2:16 pm

Hi, I also noticed some bugs in C++ syntax highlighting.

Keywords public/private/protected are not properly highlighted for base classes.

Image

Method name highlighting breaks in classes with more than one base class.

Image

Edit: There's also bug when calling template functions/methods.

Image
jwegrzyn
 
Posts: 2
Joined: Tue Oct 23, 2012 2:00 pm
Location: Szczecin, Poland

Re: C/C++ syntax highlighting bug

Postby Prazz on Tue Oct 23, 2012 2:44 pm

facelessuser wrote:In short...
replace starting at line 162 with this: ...


Yeah, but even if this is fixed, there is still a second problem - The commas separating the macro arguments would be highlighted along with the macro arguments!
And the this problem can't be solved just by editing the C.tmLanguage... It got me, a perfectionist, anxious.
Attachments
.jpg
.jpg (17.28 KiB) Viewed 2931 times
Prazz
 
Posts: 5
Joined: Sat Oct 20, 2012 4:16 pm

Re: C/C++ syntax highlighting bug

Postby Prazz on Tue Oct 23, 2012 3:24 pm

jwegrzyn wrote:Hi, I also noticed some bugs in C++ syntax highlighting...

:cry: I can't see the pictures
sigh, really wish the author work more on C/C++ syntax highlighting.
Prazz
 
Posts: 5
Joined: Sat Oct 20, 2012 4:16 pm

Re: C/C++ syntax highlighting bug

Postby facelessuser on Tue Oct 23, 2012 3:45 pm

Prazz wrote:
facelessuser wrote:In short...
replace starting at line 162 with this: ...


Yeah, but even if this is fixed, there is still a second problem - The commas separating the macro arguments would be highlighted along with the macro arguments!
And the this problem can't be solved just by editing the C.tmLanguage... It got me, a perfectionist, anxious.


This can be fixed as well in the C.tmLanguage. It would just require some more complexity. I don't have time right now, but maybe in a couple of days.

jwegrzyn wrote:Hi, I also noticed some bugs in C++ syntax highlighting.

Keywords public/private/protected are not properly highlighted for base classes.

Image

Method name highlighting breaks in classes with more than one base class.

Image

Edit: There's also bug when calling template functions/methods.

Image

Yes, the C tmLanguage file isn't that good. It needs a lot of work. I do a little here and there on my own personal copy of it. I mainly try to hit the things that annoy me most since I stare at C code all day.
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: C/C++ syntax highlighting bug

Postby jwegrzyn on Tue Oct 23, 2012 4:13 pm

Prazz wrote:
jwegrzyn wrote:Hi, I also noticed some bugs in C++ syntax highlighting...

:cry: I can't see the pictures.

I'm not sure why you can't see them. They are uploaded to CloudApp so maybe there are some issues with the service.

facelessuser wrote:Yes, the C tmLanguage file isn't that good. It needs a lot of work. I do a little here and there on my own personal copy of it. I mainly try to hit the things that annoy me most since I stare at C code all day.

I'm spending most of my time working with C++ code and those little things are making me crazy ;) Editing *.tmLanguage files is not trivial task, but maybe someone had worked on similar issues and simply will share some solutions.

It is a little suprising to see such limited support for C/C++, I belive that ST2 was written mainly with C++ so you could expect that it will at least provide better syntax highlighting.
jwegrzyn
 
Posts: 2
Joined: Tue Oct 23, 2012 2:00 pm
Location: Szczecin, Poland

Next

Return to Technical Support

Who is online

Users browsing this forum: No registered users and 24 guests