-
Notifications
You must be signed in to change notification settings - Fork 149
Add operators support #163
Conversation
grammars/c.cson
Outdated
| } | ||
| { | ||
| 'match': '<<|>>' | ||
| 'name': 'keyword.operator.c' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe keyword.operator.bitwise.c?
| } | ||
| { | ||
| 'match': '&|\\||\\^|~' | ||
| 'name': 'keyword.operator.c' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.logical.bitwise?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not possible to distinguish an indirection operator and a multiplication operator
a * b
*aSame for bitwise NOT and address-of operators
&a
a & bI didn't add bitwise subscope for |, ~, ^ for consistency with &. I made an exception for shift operators(see 2a5fafe)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. This isn't something that the grammar can handle right now.
| expect(lines[2][2]).toEqual value: 'b', scopes: ['source.c', 'meta.function.c', 'meta.block.c', 'variable.other.member.c'] | ||
|
|
||
| describe "operators", -> | ||
| it "tokenizes the sizeof operator", -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we throw in a sizeof$ or a sizeof_ check somewhere?
|
Very nice work as usual @MaximSokolov. Left some pretty minor comments. Also, what happened with your concern about overloaded operators? Is that still relevant, or did you realize that it didn't matter? |
|
Overloaded operators are probably still relevant but I'm uncertain why this code would not account for them? |
|
The only issue with overloading operators: cout << "test"; // insertion operator '<<' would have a `bitwise.shift` subscopeFixed in 80db385: ~Foo() {}I didn't fix this: vector<vector<int> > a;template <typename T> |
|
So while there are some incorrect scopes introduced with this PR, I think that the benefits of at least being able to syntax highlight operators outweighs the downsides of said incorrect scopes. @MaximSokolov would you be willing to create new issues for your last two examples? |
Fixes #114, fixes #123