atom / language-c

C support in Atom
Other
118 stars 152 forks source link

syntax/grammar color broke with 'operator' #356

Closed sylvere-k closed 2 years ago

sylvere-k commented 3 years ago

I noticed that you can't type "operator+" when I wan't to overload an operator in a custom class (or anything like that) else "operator" and the '+' sign won't be colored as they should. The only way to have them colored the right way is to separate them with spaces "operator + ", which is awful but could be fine IF it didn't broke the color/grammar/syntax of the rest of the function/etc : when doing so, "const" won't be his normal color, and "return" either. tmpgithubissue tmpgithubissue1 Here's the screenshots. I can also give the whole source code if needed.

Thanks !

CPterion commented 3 years ago

More details:

The highlighting error is fixed when > is added. No > With >

Also, the following code has a problem:

bool operator , (const Nbcomplexe & b) const {
    return (mod() > b.mod());
}

The highlighting error is partially fixed when a non-whitespace character(s) are added. Alphanumeric Alphanumeric Number Number Opening Parenthesis Opening Parenthesis

bool operator > (const Nbcomplexe & b) const {
    return (mod() > b.mod());
}
bool operator < (const Nbcomplexe & b) const {
    return (mod() > b.mod());
}
bool operator , (const Nbcomplexe & b) const {
    return (mod() > b.mod());
}

I tested this code and the syntax highlighting works for TextMate, both the highlighting on operator without spaces and when < or , is used. Tree-sitter Tree-sitter TextMate TextMate TextMate no spaces

chbk commented 3 years ago

Mentioned here: https://github.com/tree-sitter/tree-sitter-cpp/issues/110