| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
14 Values Available To the User
This chapter summarizes the various values available to the user in the rule actions.
char *yytextholds the text of the current token. It may be modified but not lengthened (you cannot append characters to the end).
If the special directive
%arrayappears in the first section of the scanner description, thenyytextis instead declaredchar yytext[YYLMAX], whereYYLMAXis a macro definition that you can redefine in the first section if you don’t like the default value (generally 8KB). Using%arrayresults in somewhat slower scanners, but the value ofyytextbecomes immune to calls tounput(), which potentially destroy its value whenyytextis a character pointer. The opposite of%arrayis%pointer, which is the default.You cannot use
%arraywhen generating C++ scanner classes (the ‘-+’ flag).int yylengholds the length of the current token.
FILE *yyinis the file which by default
flexreads from. It may be redefined but doing so only makes sense before scanning begins or after an EOF has been encountered. Changing it in the midst of scanning will have unexpected results sinceflexbuffers its input; useyyrestart()instead. Once scanning terminates because an end-of-file has been seen, you can assign ‘yyin’ at the new input file and then call the scanner again to continue scanning.void yyrestart( FILE *new_file )may be called to point ‘yyin’ at the new input file. The switch-over to the new file is immediate (any previously buffered-up input is lost). Note that calling
yyrestart()with ‘yyin’ as an argument thus throws away the current input buffer and continues scanning the same input file.FILE *yyoutis the file to which
ECHOactions are done. It can be reassigned by the user.YY_CURRENT_BUFFERreturns a
YY_BUFFER_STATEhandle to the current buffer.YY_STARTreturns an integer value corresponding to the current start condition. You can subsequently use this value with
BEGINto return to that start condition.
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on November 4, 2011 using texi2html 5.0.
