The Gateway to Computer Science Excellence
+3 votes
361 views

 

in Compiler Design by Loyal (7k points) | 361 views
0
Please explain when Lexical error generates and when Syntax error generates i usually get confuse in between both :(
0
Ok brother so only in these 6 types lrxical error occurs ?
+1
c?
0

Shaik Masthan bro can you please post all images for lexical, syntax, symentaic error conditions if you have in your notes

0
Yeah brother that would be really helpful
+1

3 Answers

+4 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

by Active (1.7k points)
+2 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.
by (189 points)
0 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.

 

by (11 points)
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,833 questions
57,700 answers
199,396 comments
107,474 users