Previous: , Up: Reentrant C Scanners   [Contents][Index]


19.5 Functions and Macros Available in Reentrant C Scanners

The following Functions are available in a reentrant scanner:

    char *yyget_text ( yyscan_t scanner );
    int yyget_leng ( yyscan_t scanner );
    FILE *yyget_in ( yyscan_t scanner );
    FILE *yyget_out ( yyscan_t scanner );
    int yyget_lineno ( yyscan_t scanner );
    YY_EXTRA_TYPE yyget_extra ( yyscan_t scanner );
    int  yyget_debug ( yyscan_t scanner );

    void yyset_debug ( int flag, yyscan_t scanner );
    void yyset_in  ( FILE * in_str , yyscan_t scanner );
    void yyset_out  ( FILE * out_str , yyscan_t scanner );
    void yyset_lineno ( int line_number , yyscan_t scanner );
    void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t scanner );

There are no “set” functions for yytext and yyleng. This is intentional.

The following Macro shortcuts are available in actions in a reentrant scanner:

    yytext
    yyleng
    yyin
    yyout
    yylineno
    yyextra
    yy_flex_debug

In a reentrant C scanner, support for yylineno is always present (i.e., you may access yylineno), but the value is never modified by flex unless %option yylineno is enabled. This is to allow the user to maintain the line count independently of flex.

The following functions and macros are made available when %option bison-bridge (‘--bison-bridge’) is specified:

    YYSTYPE * yyget_lval ( yyscan_t scanner );
    void yyset_lval ( YYSTYPE * yylvalp , yyscan_t scanner );
    yylval

The following functions and macros are made available when %option bison-locations (‘--bison-locations’) is specified:

    YYLTYPE *yyget_lloc ( yyscan_t scanner );
    void yyset_lloc ( YYLTYPE * yyllocp , yyscan_t scanner );
    yylloc

Support for yylval assumes that YYSTYPE is a valid type. Support for yylloc assumes that YYSLYPE is a valid type. Typically, these types are generated by bison, and are included in section 1 of the flex input.


Previous: The Reentrant API in Detail, Up: Reentrant C Scanners   [Contents][Index]