Dear Sirs:
I am trying to get BC3 to consider white space at the end of C++ //-style comments to be unimportant. However, I need the rest of the comment to be important.
In other words, I want changes to //-style comments to be considered important, except for changes to any white space that is at the end of the line.
-------------
First, I tried making a new Grammar Item that declares white space at the end of lines to be unimportant:
Grammar Item Element Name = "end of line white space"
Category = Delimited
Text from = \s+$
to =
Check marks are in "Stop at end of line", "Regular expressions", and "This element is case sensitive".
This grammar item is at the TOP of the list on the "Grammar" tab, and is NOT checked in the "Importance" tab.
This scheme works correctly for non-comment lines, like the following line. White spaces at the end of that line are correctly matched to my new grammar item.
if (GetType()==TYPE_CHEVY)
Unfortunately, this scheme does NOT work for //-style comment lines, like the following line. White spaces at the end of that line are declared to be part of the comment, rather than part of my new grammar item.
// This is a test
I don't understand this behavior. The white space at the end of the comment is matched by both the "Comment" grammar item and my new "end of line white space" grammar item. Since my "end of line white space" grammar item is at the top of the list, shouldn't it win?
-------------
Since my first scheme did not work, I deleted my new grammar item and modified the "built in" C++ "Comment" grammar item which defines //-style comments, to be the following...
Grammar Item Element Name = "Comment"
Category = Delimited
Text from = //
to = (\s*[^\s]+)*
Check marks are in "Stop at end of line", "Regular expressions", and "This element is case sensitive".
My "to" RegEx is intended to be (zero or more whitespaces followed by one or more non-whitespace-chars) repeated zero or more times. In other words, if there is white space, it has to be followed by non-whitespace in order to be matched.
Unfortunately, every single character (including the trailing white space) in all of the following lines is declared to be "Comment" by BC3. I would expect BC3 to declare everything from the "//" to the last "a" (inclusive) to be "Comment" and the trailing spaces to be "Default text". This does not happen, though...
//
//a
// a
//a a a
// a a a
//a a aa
// a a aa
-------------
Is my RegEx wrong, or am I trying to do something that is impossible?
Thank you very much for any help you can give me in this matter!
I am running version 3.1.11 build 12204.
- KevinC
I am trying to get BC3 to consider white space at the end of C++ //-style comments to be unimportant. However, I need the rest of the comment to be important.
In other words, I want changes to //-style comments to be considered important, except for changes to any white space that is at the end of the line.
-------------
First, I tried making a new Grammar Item that declares white space at the end of lines to be unimportant:
Grammar Item Element Name = "end of line white space"
Category = Delimited
Text from = \s+$
to =
Check marks are in "Stop at end of line", "Regular expressions", and "This element is case sensitive".
This grammar item is at the TOP of the list on the "Grammar" tab, and is NOT checked in the "Importance" tab.
This scheme works correctly for non-comment lines, like the following line. White spaces at the end of that line are correctly matched to my new grammar item.
if (GetType()==TYPE_CHEVY)
Unfortunately, this scheme does NOT work for //-style comment lines, like the following line. White spaces at the end of that line are declared to be part of the comment, rather than part of my new grammar item.
// This is a test
I don't understand this behavior. The white space at the end of the comment is matched by both the "Comment" grammar item and my new "end of line white space" grammar item. Since my "end of line white space" grammar item is at the top of the list, shouldn't it win?
-------------
Since my first scheme did not work, I deleted my new grammar item and modified the "built in" C++ "Comment" grammar item which defines //-style comments, to be the following...
Grammar Item Element Name = "Comment"
Category = Delimited
Text from = //
to = (\s*[^\s]+)*
Check marks are in "Stop at end of line", "Regular expressions", and "This element is case sensitive".
My "to" RegEx is intended to be (zero or more whitespaces followed by one or more non-whitespace-chars) repeated zero or more times. In other words, if there is white space, it has to be followed by non-whitespace in order to be matched.
Unfortunately, every single character (including the trailing white space) in all of the following lines is declared to be "Comment" by BC3. I would expect BC3 to declare everything from the "//" to the last "a" (inclusive) to be "Comment" and the trailing spaces to be "Default text". This does not happen, though...
//
//a
// a
//a a a
// a a a
//a a aa
// a a aa
-------------
Is my RegEx wrong, or am I trying to do something that is impossible?
Thank you very much for any help you can give me in this matter!
I am running version 3.1.11 build 12204.
- KevinC
Comment