Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Explain the automatic generation of lexical analyzer.

  1. Automatic generation of lexical analyzer is done using LEX programming language.
  2. The LEX specification file can be denoted using the extension .l (often pronounced as dot L).
  3. For example, let us consider specification file as x.l.
  4. This x.l file is then given to LEX compiler to produce lex.yy.c as shown in image (A )This lex.yy.c is a C program which is actually a lexical analyzer program.
  1. The LEX specification file stores the regular expressions for the token and the lex.yy.c file consists of the tabular representation of the transition diagrams constructed for the regular expression.
  2. In specification file, LEX actions are associated with every regular expression.
  3. These actions are simply the pieces of C code that are directly carried over to the lex.yy.c.
  4. Finally, the C compiler compiles this generated lex.yy.c and produces an object program a. out as shown in image.
  5. When some input stream is given to a. out then sequence of tokens gets generated. The described scenario is shown in image( B).

Leave a Comment