Re: syntax highlighting rules for C++

Benno Schulenberg <[email protected]>
Newsgroups gmane.editors.nano.general
Message-ID <1476610172.2278174.757353281.6CF123C4@webmail.messagingengine.com>
On Sun, Oct 16, 2016, at 07:40, Mark Yagnatinsky wrote:
> Here's a simple example of what I had in mind:
> 
> #include<vector>
> using namespace std;
> int main(){} // whatever
> vector<int> v;
> 
> In the example above, <int> is colored yellow (last line).  I don't think
> this is good, and I don't think it was the intent of the person who wrote
> these rules.

You would want the "int" between angular brackets to be colored
green, like any other type?  Adding the following line to your
~/.nanorc should partially achieve that:

  extendsyntax c color green "<(bool|enum|float|wchar_t|((un?)signed )?(long |short )?char|double|int)>"

But it colors the angular brackets green too, which is not nice.

So better would be to... not "allow" comments after include
statements: add a "$" at the end of the string coloring rule,
so only strings of the form <word> at line's end get colored.

color brightyellow ""([^"]|\\")*"" "<[^[:blank:]=]*>$"

Benno

-- 
http://www.fastmail.com - Does exactly what it says on the tin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.