retagged by
3,856 views
0 votes
0 votes
  1. Which of the following error will not come under Lexical error (Compiler Design - 1Mark)

  1. Spelling error

  2. Exceeding length of an identifier or numeric constants

  3. Appearance of illegal characters

  4. Missing semicolon

 

A.   I only

B.   II only

C.   III only

D.   IV only

 

    Explanation:

Spelling error, exceeding length of identifier or numeric constants,

Appearance of illegal characters all of these will comes under Lexical Error.

Missing semicolon is a type of Syntax error.

--- I think answer should be both missing semicolon and spelling error...  unmatched strings are detected in lexical phase but spelling errors will be caught in syntax phase because spelling errors make string to match with another pattern. Ex ::-- while , whiel,  instead of keyword it would be recognized as variable ...

Can any one explain what is true...

retagged by

1 Answer

3 votes
3 votes

answer is both I and IV ..

According to the dragon book of compiler design

 Therefore misspelled word can not be detected by lexical analysis since it always matches with the pattern of identifier which is used to generate identifier token. Therefore as mentioned in above reference it can be detected in further stages like syntax analysis phase.. Any missing of semi colon  will be detected in syntax analysis phase since it is purely syntax of programming language to end statement with a semicolon(;).

Related questions

4 votes
4 votes
2 answers
1
jatin khachane 1 asked Nov 23, 2018
1,208 views
int main() { int a,b; a=10; b=15; printf("a=%d,b=%d",a++,b ); }The number of tokens in the above C program is_________.I am getting 30The answer given is 29
1 votes
1 votes
1 answer
3
aaru14 asked Nov 21, 2017
1,400 views
in c programming which of the following is not used as a token seprator during lexical analysis?a)white spaceb)commentc)semicolond)none of thesetoken seprator means??