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? Compiler Design compiler-tokenization + – Rishabh Gupta 2 asked Oct 2, 2017 Rishabh Gupta 2 1.3k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 5 votes 5 votes 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 ♥_Less answered Oct 2, 2017 selected Oct 6, 2017 by Arjun ♥_Less comment Share Follow See all 11 Comments See all 11 11 Comments reply Show 8 previous comments Rishabh Gupta 2 commented Dec 17, 2017 reply Follow Share @joshi_nitish Can you provide any link to read this? 0 votes 0 votes joshi_nitish commented Dec 17, 2017 reply Follow Share see this 2 votes 2 votes shashankrustagi commented Dec 16, 2020 reply Follow Share 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 votes 0 votes Please log in or register to add a comment.