Awesome q2a theme
+1 vote

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

in Compiler Design by (699 points) | 57 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.

by (1.9k points)
selected 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
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
95,111 users