2,207 views
9 votes
9 votes

I am writing down some errors and its type with a reason.If there something wrong please correct it with a valid reason.

1.fi(a==10)

this is not a lexical error, because lexical analyzer cannot tell whether fi is a misspelling of the keyword if or an undeclared function identifier.

2. inz a;

this is also not a lexical error with the same reason as above.All token are valid.

3. int 2ab;

lexical error as 2ab is not a valid identifier.

4. int a#;

lexical error as a# is not a valid token. but this says it is not a lexical error

5.int a2.5c;

I think it is lexical error as a2.5c is not a valid token. but this says it is streams of valid tokens

6.int d=10.10.10

lexical error as invalid num token.

2 Answers

0 votes
0 votes

Lexical errors are the errors which include the misspelling of identifiers, keywords or operators.

Lexical analyzer will analyze it as a valid token. Hence this will not be the lexical error. Later it shall be recognized as a syntactic error.

edited by
0 votes
0 votes

There will be no error in 1 and 2.

3 also have a lexical error.

I don't get why people are saying int a2.5c; has a lexical error. I think this must have syntax error but not lexical error. There must be a case of lexical error only if C rules are followed.

Related questions

14 votes
14 votes
2 answers
1
dd asked Dec 13, 2016
3,273 views
Consider the following C program: int main (void) { in/*this is an example*/z; double/*is it an error?*/y; print( “This is simple” ); return 0; }- How many Different ...
2 votes
2 votes
4 answers
2
6 votes
6 votes
1 answer
3
junaid ahmad asked Jan 12, 2018
1,234 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...