Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Conversation

@MaximSokolov
Copy link
Contributor

Fixes #114, fixes #123

// sizeof
sizeof unary_expression
sizeof(int)

// arithmetic
+a
-a

a + b
a - b
a * b
a / b
a % b

i++
++i
i--
--i

// comparison
a < b
a > b
a >= b
a <= b
a == b
a != b

// bitwise
~a
a & b
a | b
a ^ b
a << b
a >> b

// logical
!a
a && b
a || b

// assignment
a = b
a += b
a -= b
a *= b
a /= b
a %= b
a &= b
a ^= b
a |= b
a <<= b
a >>= b

// pointer
*a
&a

// ternary
a ? b : c

@winstliu winstliu self-assigned this Sep 16, 2016
grammars/c.cson Outdated
}
{
'match': '<<|>>'
'name': 'keyword.operator.c'
Copy link
Contributor

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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.logical.bitwise?

Copy link
Contributor Author

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
*a

Same for bitwise NOT and address-of operators

&a
a & b

I didn't add bitwise subscope for |, ~, ^ for consistency with &. I made an exception for shift operators(see 2a5fafe)

Copy link
Contributor

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", ->
Copy link
Contributor

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?

@winstliu
Copy link
Contributor

winstliu commented Sep 19, 2016

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?

@hgdsraj
Copy link
Contributor

hgdsraj commented Oct 3, 2016

Overloaded operators are probably still relevant but I'm uncertain why this code would not account for them?

@MaximSokolov
Copy link
Contributor Author

The only issue with overloading operators:

cout << "test"; // insertion operator '<<' would have a `bitwise.shift` subscope

Fixed in 80db385:

~Foo() {}

I didn't fix this:

vector<vector<int> > a;
template <typename T>

@winstliu
Copy link
Contributor

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?

@winstliu winstliu merged commit a414592 into atom:master Oct 10, 2016
@MaximSokolov MaximSokolov deleted the operators-support branch December 3, 2016 15:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Operators like + , -, *, /, %, ^, |, &, ||, && Highlighting? Operators are not being tokenized

3 participants