search
Log In
6 votes
374 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 we don't find */ here

in Compiler Design 374 views
0
a is definitely token here.

then /*...........*/ if there then it will not count as token.

But it can take divide sign and * separately

So, why not 4 tokens?
0

@srestha  what would be number of tokens if pattern is given as a/*b ;

1

chk here https://gateoverflow.in/193991/token

discussion going on. just follow it

1 Answer

2 votes
I think, it gives lexical error bcz in a/*b it first scan 'a',

and after that it scan '/' then '*'. after  /* lexical analyzer consider this as a start of comment but,

it not get the end of comment it fall in infinite loop that's why it gives lexical error.

Related questions

9 votes
3 answers
1
1k views
When do we count ++(post increment or pre increment) as 1 or 2 token ?
asked Sep 29, 2017 in Compiler Design junaid ahmad 1k views
5 votes
4 answers
2
1k views
if there is miss spelling in some keyword in a program then this misspelled keyword will be treated as lexical errors or it will be treated as a new identifier and accepted as a token ?? ex - whiel (1) ; here while is misspelled as whiel
asked Nov 2, 2017 in Compiler Design itsvkp1 1k views
2 votes
1 answer
3
645 views
This screenshot is token from the book Ullman, How can following be a lexical error? because "elipseSize" should have a token recorded as an identifier.
asked Sep 26, 2017 in Compiler Design Manu Thakur 645 views
5 votes
3 answers
4
...