Header Ads Widget

Lexical Error

Lexical Error

During the lexical analysis phase this type of error can be detected.

Lexical error is a sequence of characters that does not match the pattern of any token. Lexical phase error is found during the execution of the program.

Lexical phase error can be:

  • Spelling error.
  • Exceeding length of identifier or numeric constants.
  • Appearance of illegal characters.
  • To remove the character that should be present.
  • To replace a character with an incorrect character.
  • Transposition of two characters.

Example:

  1. Void main()  
  2. {  
  3.      int x=10y=20;  
  4.      char * a;  
  5.      a= &x;  
  6.      x1xab;  
  7. }  

In this code, 1xab is neither a number nor an identifier. So this code will show the lexical error.

Post a Comment

0 Comments