yyleng
yyleng is a variable used by the Lex/Flex family of lexical analyzer generators to store the length of the text matched by the current token. In typical Flex-generated scanners, yyleng corresponds to the number of characters in the string pointed to by yytext, which contains the actual token that was matched. The value of yyleng is updated automatically for each successful match and can be referenced within action code to process the token without relying on a separate NUL-terminated string.
- yyleng is commonly used in action blocks to examine or copy only the relevant portion of yytext,
- It is closely tied to yytext, since its value reflects the length of the data stored there.
- The exact declaration (type and scope) of yyleng can depend on the skeleton (C, C++, etc.) and
- The term originates from the Unix toolset Lex and its modern reimplementation Flex. yyleng is one
- While primarily associated with Flex, similar concepts exist in other lexer generators, sometimes under different names.