Awesome q2a theme
+1 vote
57 views

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

in Compiler Design by (699 points) | 57 views
0

1 Answer

0 votes
Best answer

Both += and >>= are single operators - they fall under the category of compound assignment operators - https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#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.

by (1.9k points)
selected by
0

My life in short-->

1. Birth

2. Tagging @shashin on doubts

3. Death

0
Val+=5;

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

@shashin

Is #define part count as token?

I mean macro or stdio part

0
afaik, #define, #include and '\' doesn't. typedef does.
0
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.
0

@shashin 

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

e.g.

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

int main(){
    int a = 4;
    if(a == 4){
        "";
    }else{
        printf("tf");
    }
}

tokens here?!!

0
Not sure - try out on jdoodle.com 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
Top Users 2020 Aug 10 - 16
  1. Arkaprava

    404 Points

  2. jayeshasawa001

    198 Points

  3. SarathBaswa

    126 Points

  4. Ashutosh777

    67 Points

  5. toxicdesire

    20 Points

  6. Nilabja Sarkar

    12 Points

  7. premu

    10 Points

  8. iarnav

    7 Points

  9. Jhumpa_Sarma

    6 Points

  10. Patel0967

    6 Points

Weekly Top User (excluding moderators) will get free access to GATE Overflow Test Series for GATE 2021
Welcome to GATE CSE Doubts, where you can ask questions and receive answers from other members of the community.
Top Users Aug 2020
  1. Arkaprava

    404 Points

  2. jayeshasawa001

    203 Points

  3. Mellophi

    156 Points

  4. Ashutosh777

    143 Points

  5. SarathBaswa

    126 Points

  6. anurag sharma

    49 Points

  7. toxicdesire

    20 Points

  8. shashankrustagi2021

    16 Points

  9. premu

    16 Points

  10. Kushagra गुप्ता

    15 Points

7,769 questions
1,977 answers
11,275 comments
95,111 users