Question1. Count number of Distinct tokens and lexemes in following code
{
float a=20.6;
float b=19.8;
float c=19.8;
float a=20.6;
float c=15.7;
printf("Hello!How r u");
printf("I am Good");
}
Doubt:- Does float constants and string constants like(20,6/19.8/printf string) will be counted as different tokens or same token?
There is multiple declarations of some variables in above code,but i am only concerned about lexical analysis o/p.
I dont have the answer as it is self made question
Question 2 : Nuber of lexemes will always be same as number of tokens?
Question 3. Number of distinct lexemes will always be same as number of distinct tokens?
I have read following statement from dragon
In a compiler, the lexical analyzer reads the characters of the source program,
groups them into lexically meaningful units called lexemes, and produces
as output tokens representing these lexemes.
So i guess lexems and tokens are same as token is just a representation of lexemes associated with it?So by this the answer to 2 and 3 statement will be true?