Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which global variable in LEX points to matched string and which global variable contains the length of the matched string ?

  • A.yylex, yylval
  • B.lextext, lexval
  • C.yytext, yyleng
  • D.lexyy, yylex

Answer: C

The variables are yytext, yyleng.

In a LEX-generated scanner, yytext points to the text of the lexeme just matched, and yyleng holds its length. Actions in the rules use them, for example to copy the matched identifier or number.

yylex is the scanning function itself, which returns the next token, and yylval is the variable used to pass a token's value to a YACC parser. lextext, lexval and lexyy are not LEX's global variables (lex.yy.c is the name of the generated file).

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.