Awesome q2a theme
+1 vote

Is $>>=$ a single tocken or 2 tockens?

ago in Compiler Design by (613 points) | 29 views

1 Answer

0 votes
Best answer

Both += and >>= are single operators - they fall under the category of compound assignment operators - - clearly says they are included in both C and C++, so there should be no debate.

For this reason, I will say there are single token.

ago by (1.2k points)
selected ago by

My life in short-->

1. Birth

2. Tagging @shashin on doubts

3. Death


Will create syntax error right?
(As Val gets replaced by 10 bcz of macro)
Yes. It will complain that it cannot assign to a literal, or that it needs an expression with a memory address.


Is #define part count as token?

I mean macro or stdio part

afaik, #define, #include and '\' doesn't. typedef does.
Correct. For more details - please read up on preprocessor directives and in which stage of compilation they are evaluated. Typedef, iirc , is considered a synonym for a type and is evaluated during syntax analysis (I might be wrong on this) - but its counted towards a token.


One thing that bothers me, should we really ignore #defines tho?


#define if if(rand() % 256)if

int main(){
    int a = 4;
    if(a == 4){

tokens here?!!

Not sure - try out on and see how it evaluates. My understanding is that regardless of what's in the #define, the preprocessor just replaces it in the code before handing it to the compiler proper. Remember that compilers have a lot of different flavors, and aren't necessarily smart enough to properly interpret preprocessor directives.

I haven't dug that deep into the working of the C compiler tbh :)
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
Welcome to GATE CSE Doubts, where you can ask questions and receive answers from other members of the community.
Top Users Jan 2020
  1. shashin

    1163 Points

  2. Vimal Patel

    306 Points

  3. Deepakk Poonia (Dee)

    305 Points

  4. Debapaul

    237 Points

  5. Satbir

    192 Points

  6. SuvasishDutta

    137 Points

  7. Pratyush Priyam Kuan

    118 Points

  8. tp21

    108 Points

  9. pranay562

    95 Points

  10. DukeThunders

    94 Points

Monthly Top User and those within 60% of his/her points will get a share of monthly revenue of GO subject to a minimum payout of Rs. 500. Current monthly budget for Top Users is Rs. 75.
2,983 questions
1,509 answers
89,814 users