retagged by
3,409 views
6 votes
6 votes

 

retagged by

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.

 

Related questions

0 votes
0 votes
2 answers
1
Mohit Aggarwal asked Dec 1, 2021
1,328 views
what is the difference between lexical error and syntax error?
12 votes
12 votes
5 answers
2
Shubhanshu asked Jan 31, 2018
7,014 views
int main() { int 1a, b; Printf("\nGate 2018"); Printf("%d",x); }How many types of error are there in this code?
1 votes
1 votes
3 answers
4
shikharV asked Nov 19, 2015
2,392 views
Given answer: DPlease explain