Open System Services Shell and Utilities Reference Manual (G06.28+, H06.05+)
flex(1) OSS Shell and Utilities Reference Manual
flex variables that can be used within actions are:
yytext Is a string (char *) containing the current matched input. It
cannot be modified.
yyleng Is the length (int) of the current matched input. It cannot be
modified.
yyin Is a stream (FILE *) that the lex and flex commands reads from
the standard input file by default. It can be changed, but
because of the buffering flex uses, changing the stream makes
sense only before scanning begins. Once scanning terminates
because an End-of-File was found, void yyrestart (FILE
*new_file) can be called to point yyin at a new input file. Alter-
natively, yyin can be changed whenever a new or different
buffer is selected (see yy_switch_to_buffer()).
yyout Is a stream (FILE *) to which ECHO output is written (the
standard output file by default). It can be changed by the user.
YY_CURRENT_BUFFER
Returns the current buffer (YY_BUFFER_STATE) used for
scanner input.
flex macros and functions that can be used within actions are:
ECHO Copies the yytext variable to the scanner’s output.
BEGIN state
Changes the scanner state to be state. This affects which rules are
active. The state must be defined in a %s or %x definition. The ini-
tial state of the scanner is INITIAL or 0 (zero).
REJECT Directs the scanner to proceed immediately to the next best pattern
that matches the input (which may be a prefix of the current match).
The yytext and yyleng variables are reset appropriately. Note that
REJECT is a particularly expensive feature in terms of scanner per-
formance; if it is used in any of the scanner’s actions, it slows down
all the scanner’s pattern matching operations. REJECT cannot be
used if the command is invoked with either the -f or -F flag.
yymore() Indicates that the next matched text should be appended to the
currently matched text in the yytext variable (rather than replace it).
yyless(n) Returns all but the first n characters of the current token back to the
input stream, where they are rescanned when the scanner looks for the
next match. The yytext and yyleng variables are adjusted accord-
ingly.
yywrap() Returns 0 (zero) if there is more input to scan or 1 if there is not. The
default yywrap() always returns 1. It is implemented as a macro.
yyterminate()
Can be used instead of a return statement in an action. It terminates
the scanner and returns a 0 (zero) to the scanner’s caller.
yyterminate() is automatically called when an End-of-File is
encountered. It is a macro and can be redefined.
3−150 Hewlett-Packard Company 527188-007