in Compiler Design
1,311 views
3 votes
3 votes
How many tokens are there in the following statement:

x >> = 2;

 

In general, are shorthand operators counted as a single token as ">>=" or double as ">>" and "=". Or anything else?
in Compiler Design
1.3k views

1 Answer

5 votes
5 votes
Best answer

compiler follows greedy approach and will try to make longest pattern available. like x++ will be 2 token instead of x , + ,+ (3)

So here "01" , "!=" and ">>=" will be treated as 1 token only..

https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Compound_assignment_operators

selected by

4 Comments

@joshi_nitish Can you provide any link to read this?
0
0

see this

2
2
nothing is showing in the link, please update and thanks for telling me that it is a single token

PS

#define is not a token
0
0

Related questions