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
Adding preprocessor comment styles for C++ lexer
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
  10 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
 
Neil Hodgson  
View profile  
 More options Jun 16 2012, 9:03 pm
From: Neil Hodgson <nyamaton...@me.com>
Date: Sun, 17 Jun 2012 11:03:38 +1000
Local: Sat, Jun 16 2012 9:03 pm
Subject: Adding preprocessor comment styles for C++ lexer
   A bug report (#3487406) is concerned with problems when comments occur within macro definitions when the "styling.within.preprocessor" option is off. One potential solution is to add new styles for comments inside preprocessor text. This would also allow some more choice when choosing how these comments would appear: they could be made indistinguishable from the rest of the preprocessor lines or could be blended in more than the standard comments.

   The most common use of comments inside preprocessor directives is to mark the end of constructs like this:

#ifdef UNICODE
#define strcpy wcscpy
#endif /* UNICODE */

  There are complex examples in multi-line macros like this:

#define BFD_FAKE_SECTION(SEC, FLAGS, SYM, NAME, IDX)                   \
  /* name, id,  index, next, prev, flags, user_set_vma,            */  \
  { NAME,  IDX, 0,     NULL, NULL, FLAGS, 0,                           \
                                                                       \
  /* linker_mark, linker_has_input, gc_mark, gc_mark_from_eh,      */  \
     0,           0,                1,       0,                        \
  ...

   One question here is which of the 6 comment styles would need to be duplicated as preprocessor comment styles. Are documentation comments ever located inside preprocessor text? Looking at the Doxygen documentation didn't show any examples -- it mostly shows separate lines of document comments and few examples of inline doc comments.

   There is a cost to defining new styles as it requires applications to add definitions for the visual appearance of these styles.

   Bug:
http://sourceforge.net/tracker/?func=detail&aid=3487406&group_id=2439...

   Neil


 
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.
mr.maX  
View profile  
 More options Jun 17 2012, 6:03 pm
From: "mr.maX" <marko.nje...@gmail.com>
Date: Sun, 17 Jun 2012 15:03:23 -0700 (PDT)
Local: Sun, Jun 17 2012 6:03 pm
Subject: Re: Adding preprocessor comment styles for C++ lexer

On Sunday, June 17, 2012 3:03:38 AM UTC+2, Neil Hodgson wrote:

>   A bug report (#3487406) is concerned with problems when comments occur
> within macro definitions when the "styling.within.preprocessor" option is
> off. One potential solution is to add new styles for comments inside
> preprocessor text. This would also allow some more choice when choosing how
> these comments would appear: they could be made indistinguishable from the
> rest of the preprocessor lines or could be blended in more than the
> standard comments.

For the sake of completeness in this discussion, I would also like to
point out that mentioned bug report already comes with a patch that fixes
handling of comments inside macros. The patch fixes the issue by properly
returning to the preprocessor style when terminating comment style that's
inside preprocessor.

The approach of using additional styles for comments inside macros would
also fix the problem, but in my opinion the amount of necessary code
changes does not justify it. Depending on all comment types that will be
supported inside macros, the resulting patch may end up being bigger than
the original one.

I would also like to mention that the main reason why handling of comments
inside macros should be fixed is because in some occasions they can disrupt
further code folding in the document.

--
Regards,
Marko Njezic - mr.maX @ MAX Interactive corp.
Personal: http://www.markonjezic.com/
MAX's Empire: http://www.maxempire.com/
MAX's HTML Beauty++ 2004: http://www.htmlbeauty.com/


 
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.
Neil Hodgson  
View profile  
 More options Jun 18 2012, 8:41 pm
From: Neil Hodgson <nyamaton...@me.com>
Date: Tue, 19 Jun 2012 10:41:31 +1000
Local: Mon, Jun 18 2012 8:41 pm
Subject: Re: [scintilla] Adding preprocessor comment styles for C++ lexer

   Since there have been no statements that documentation comments need to be supported inside preprocessor directives, it seems reasonable to apply a simple modification that adds a single new style SCE_C_PREPROCCOMMENT.

   Example before and after: http://www.scintilla.org/bfd.png

   Line comments can also appear at the end of preprocessor directives but this is far less common than stream comments, so has not been added in the proposed change.

   Diff attached.

  PREPROCCOMMENT.diff
2K Download

   Neil


 
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.
mr.maX  
View profile  
 More options Jun 18 2012, 9:14 pm
From: "mr.maX" <marko.nje...@gmail.com>
Date: Mon, 18 Jun 2012 18:14:32 -0700 (PDT)
Local: Mon, Jun 18 2012 9:14 pm
Subject: Re: [scintilla] Adding preprocessor comment styles for C++ lexer

On Tuesday, June 19, 2012 2:41:31 AM UTC+2, Neil Hodgson wrote:

>   Since there have been no statements that documentation comments need to
> be supported inside preprocessor directives, it seems reasonable to apply a
> simple modification that adds a single new style SCE_C_PREPROCCOMMENT.

Although this probably isn't widely used - it is possible to embed
documentation comments inside macros. One example:
http://stackoverflow.com/questions/7880811/how-to-doxygen-comment-gen...

>    Example before and after: http://www.scintilla.org/bfd.png

>    Line comments can also appear at the end of preprocessor directives but
> this is far less common than stream comments, so has not been added in the
> proposed change.

>    Diff attached.

Your patch does not handle transition back to preprocessor state always
correctly. The following code will not be highlighted properly:

#define MACRO()\
/* comment */\
{ ... <- wrong highlighting from here on

The patch also doesn't handle multiline comments at all and stops
highlighting at first encountered line end.

--
Regards,
Marko Njezic - mr.maX @ MAX Interactive corp.
Personal: http://www.markonjezic.com/
MAX's Empire: http://www.maxempire.com/
MAX's HTML Beauty++ 2004: http://www.htmlbeauty.com/


 
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.
Neil Hodgson  
View profile  
 More options Jun 18 2012, 11:01 pm
From: Neil Hodgson <nyamaton...@me.com>
Date: Tue, 19 Jun 2012 13:01:13 +1000
Local: Mon, Jun 18 2012 11:01 pm
Subject: Re: [scintilla] Adding preprocessor comment styles for C++ lexer

mr.maX:

> Your patch does not handle transition back to preprocessor state always correctly. The following code will not be highlighted properly:

> #define MACRO()\
> /* comment */\
> { ... <- wrong highlighting from here on

   OK

> The patch also doesn't handle multiline comments at all and stops highlighting at first encountered line end.

   I was thinking of the infamous old
#define COMMENT /*
#define ENDCOMMENT */
COMMENT Make the comments pretty! ENDCOMMENT
   but it appears that went away with C99.

   New patch attached. Not real happy with moving the sc.Forward() out of the for statement as it complicates termination checking.

  PREPROCCOMMENT.diff
3K Download

   Neil


 
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.
mr.maX  
View profile  
 More options Jun 19 2012, 6:08 pm
From: "mr.maX" <marko.nje...@gmail.com>
Date: Tue, 19 Jun 2012 15:08:42 -0700 (PDT)
Local: Tues, Jun 19 2012 6:08 pm
Subject: Re: [scintilla] Adding preprocessor comment styles for C++ lexer

On Tuesday, June 19, 2012 5:01:13 AM UTC+2, Neil Hodgson wrote:

>    New patch attached. Not real happy with moving the sc.Forward() out of
> the for statement as it complicates termination checking.

I would only change for loop to the while loop, now that the loop
expression consists only of condition check.

On a side note, I have been testing various different scenarios and found
one case where highlighting will be wrong:

#define MYMACRO() \[CRLF]
myfunc() { .. } \[CRLF]
/* comment */[CRLF]
\[CRLF] <- this line should not be highlighted as preprocessor, because
previous line does not end with backslash
{ ...

The reason why this happens is due to the way how line end is treated in
order to allow eol filled style as explained in the previously mentioned
bug report.

--
Regards,
Marko Njezic - mr.maX @ MAX Interactive corp.
Personal: http://www.markonjezic.com/
MAX's Empire: http://www.maxempire.com/
MAX's HTML Beauty++ 2004: http://www.htmlbeauty.com/


 
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.
Neil Hodgson  
View profile  
 More options Jun 19 2012, 10:23 pm
From: Neil Hodgson <nyamaton...@me.com>
Date: Wed, 20 Jun 2012 12:23:57 +1000
Local: Tues, Jun 19 2012 10:23 pm
Subject: Re: [scintilla] Adding preprocessor comment styles for C++ lexer
mr.maX:

> #define MYMACRO() \[CRLF]
> myfunc() { .. } \[CRLF]
> /* comment */[CRLF]
> \[CRLF] <- this line should not be highlighted as preprocessor, because previous line does not end with backslash
> { …

   This problem can be reproduced without comments:

#d M\

\
x
y

   Neil


 
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.
Neil Hodgson  
View profile  
 More options Jun 19 2012, 10:54 pm
From: Neil Hodgson <nyamaton...@me.com>
Date: Wed, 20 Jun 2012 12:54:46 +1000
Local: Tues, Jun 19 2012 10:54 pm
Subject: Re: [scintilla] Adding preprocessor comment styles for C++ lexer

   I think the answer is to move the revert-to-default before the line continuation handling.

   New patch attached.

   Neil

  PREPROCCOMMENT.diff
4K Download

 
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.
mr.maX  
View profile  
 More options Jun 21 2012, 4:31 am
From: "mr.maX" <marko.nje...@gmail.com>
Date: Thu, 21 Jun 2012 01:31:27 -0700 (PDT)
Local: Thurs, Jun 21 2012 4:31 am
Subject: Re: [scintilla] Adding preprocessor comment styles for C++ lexer

On Wednesday, June 20, 2012 4:54:46 AM UTC+2, Neil Hodgson wrote:

>   I think the answer is to move the revert-to-default before the line
> continuation handling.

That appears to have fixed the issue.

--
Regards,
Marko Njezic - mr.maX @ MAX Interactive corp.
Personal: http://www.markonjezic.com/
MAX's Empire: http://www.maxempire.com/
MAX's HTML Beauty++ 2004: http://www.htmlbeauty.com/


 
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.
Neil Hodgson  
View profile  
 More options Jun 22 2012, 12:28 am
From: Neil Hodgson <nyamaton...@me.com>
Date: Fri, 22 Jun 2012 14:28:02 +1000
Local: Fri, Jun 22 2012 12:28 am
Subject: Re: [scintilla] Adding preprocessor comment styles for C++ lexer
   Change committed but with name of new style not abbreviated: SCE_C_PREPROCESSORCOMMENT.

   Neil


 
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 »