Home » 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:

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

Next TopicSyntax Error

You may also like