in Compiler Design retagged by
3,393 views
6 votes
6 votes

 

in Compiler Design retagged by
by
3.4k views

4 Comments

Yeah brother that would be really helpful
0
0
1
1

7 Answers

5 votes
5 votes

int a b;= long identifier it can detect during lexical analysis

int 1ab2;=I'll formed numeric literal it can detect during lexical analysis

in t a b;= long identifier it can detect during lexical analysis

D) All the above

4 votes
4 votes
C will be right option

<1ab2> is invalid token as it is neither keyword nor can be an identifier as 1st  character is a number.
2 votes
2 votes

All of them are Lexical Errors. Lexical analysis is implemented using Finite Automata.  

Option A: int a b;
Start->int->a->"Expected either ; or = but got whitespace." (Error) Generated Tokens: 2

Option B: in t a b;
Start->i->n->"Expected t but got whitespace" (Error) Generated Tokens: 0

Option C: int 1ab2;
Start->int->"Expected a permitted character but got 1"->a "Didn't expect a character after a number" (Error) Generated Tokens: 1

Explanation of Option C: A parser doesn't support Backtracking. After getting 1 (Which was not permitted) the compiler got a which means that it has to backtrack.

 

0 votes
0 votes
Option D ) All of the above.