MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

COMPILER DESIGN

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
The statement/function used to get input from the user in a LEX program is
A
yylex()
B
yytext()
C
main()
D
yywrap()
Explanation: 

Detailed explanation-1: -yylex() returns a value indicating the type of token that has been obtained. If the token has an actual value, this value (or some representation of the value, for example, a pointer to a string containing the value) is returned in an external variable named yylval.

Detailed explanation-2: -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 .

Detailed explanation-3: -yywrap() Returns the value 1 when the end of input occurs. yymore() Appends the next matched string to the current value of the yytext array rather than replacing the contents of the yytext array. yyless(int n)

Detailed explanation-4: -lex also creates two important external data objects: A string named yytext. This string contains a sequence of characters making up a single input token. The token is read from the stream yyin, which, by default, is the standard input (stdin).

There is 1 question to complete.