edited by
3,860 views
10 votes
10 votes
When do we count ++(post increment or pre increment) as 1 or 2 token ?
edited by

3 Answers

Best answer
8 votes
8 votes
Preprocessor follows greedy approach to tokenize,  This can be done in TWO steps

1 => Separated by space (A+ ++B) => Have 4 tokens(Space is not considered as token), here tokens are A, +, ++, B(In order of expression). If any operator doesn't have any space ,

then ,

2 => Greedy approach (A+++B) for longest possible valid operator in the Grammer => Like we have '++' > '+' so here the tokens are A,++, +, B(In order of expression).
selected by
5 votes
5 votes
Always when we count the token complier always see next symbol

Eg-

++= 1token

a+++++b =5tokens

&&= 1token
edited by
0 votes
0 votes
I think 2 tokens because count is an identifier and ++ is an operator.

Related questions

6 votes
6 votes
1 answer
1
junaid ahmad asked Jan 12, 2018
1,267 views
Is this line a/*b successfully generating the token's or it give lexical error ? if it is given the lexical error then why so ?I think it will give lexical error because...
0 votes
0 votes
1 answer
2
syncronizing asked Sep 21, 2018
5,363 views
Question:Find the number of tokens in the following C code using lexical analyzer of the compiler.
1 votes
1 votes
1 answer
3
sagar27 asked Sep 21, 2018
5,291 views
Find no of tokens in below program.#include<stdio.h>main(){ int I; int *pi = &I; //parent pointer scanf("%d",pi); printf("%d\n", I+5);}
0 votes
0 votes
2 answers
4
saumya mishra asked Jun 12, 2018
2,267 views
In this question we will take n-=n1 as n=n-n1 as 5 tokens or n-=n1 as 4 tokens ????