COMPUTER SCIENCE AND ENGINEERING
COMPILER DESIGN
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
%
|
|
{%
|
|
%}
|
|
%%
|
Detailed explanation-1: -Structure of a Lex Specification A lex program consists of three parts: the definition section, the rules section, and the user subroutines. The parts are separated by lines consisting of two percent signs. The first two parts are required, although a part may be empty.
Detailed explanation-2: -LEX is a program generator designed for lexical processing of character input/output stream. Anything from simple text search program that looks for pattern in its input-output file to a C compiler that transforms a program into optimized code.
Detailed explanation-3: -Lex: reads a specification file containing regular expressions and generates a C routine that performs lexical analysis. Matches sequences that identify tokens. Yacc: reads a specification file that codifies the grammar of a language and generates a parsing routine. yylex() .
Detailed explanation-4: -Function yywrap is called by lex when input is exhausted. Return 1 if you are done or 0 if more processing is required. Every C program requires a main function. In this case we simply call yylex that is the main entry-point for lex .