Lex program to identify the identifier
Lex is a computer program that generates lexical analyzers and was written by Mike Lesk and Eric Schmidt. Lex reads an input stream specifying the lexical analyzer and outputs source code implementing the lex in the C programming language.
In C, an identifier must begin with either an alphabet or underscore, it can not begin with a digit or any other special character, moreover digits can come after.
gfg : valid identifier 123 : invalid identifier _abc12 : valid identifier #abc : invalid identifier
Let’s see the lex program to determine whether input is an identifier or not.