|Restarting lex portably email@example.com (Michael A Copenhafer) (2000-08-21)|
|Re: Restarting lex portably firstname.lastname@example.org (2000-09-08)|
|From:||Michael A Copenhafer <email@example.com>|
|Date:||21 Aug 2000 00:02:17 -0400|
|Organization:||CSE Dept., UC San Diego|
Hi -- I want to restart lex after an error occurs in parsing. It isn't
obvious to me how to do this in a portable manner. Flex offers the
function yyrestart(), pclex has the macro YY_INIT, MKS lex has the
function yy_reset(). Is there a more portable method of restarting lex?
Page 171 of Levine's 'Lex and Yacc' (2nd ed.) says the following:
...you cannot restart a lexer just by calling yylex(). you have
to reset it into the default state using
BEGIN(INITIAL), discard any input text buffered up by unput(),
and otherwise arrange so that the
next call to input() will start reading the new input.
Could someone explain what code is necessary to accomplish this?
[You can't really do it portably in lex. I'd suggest deciding that your
favorite version of lex is flex, and shipping the lex.yy.c along with
your C routines if you want to move the code to another system. -John]
Return to the
Search the comp.compilers archives again.