help-flex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: scanning string


From: Nikos Balkanas
Subject: Re: scanning string
Date: Mon, 14 Jan 2002 18:17:55 +0200

You can either rewrite YY_INPUT or use yy_scan_string. There is advise out
there how to modify YY_INPUT. Personally I prefer yy_scan_string. It is more
elegant and you can switch between buffers and files interchangeably. With
YY_INPUT you are pretty much locked (one can of course keep redefining it,
but it is not recommended, since flex reorganizes the source code and the
results will be unpredictable). It is also more of a hassle.

The correct entry point is, as John pointed out, before the call to yylex().
However, it is not limited there. It will setup and initialize all buffers.
As a result I routinely use it in the middle of actions the same way and
interchangeably with
yyrestart().

Cheers,
Nikos

----- Original Message -----
From: John W. Millaway <address@hidden>
To: flex list <address@hidden>
Sent: Monday, January 14, 2002 10:05 PM
Subject: Re: scanning string


> > "yy_scan_string(const char* str)". Before this shall I rewrite the
YY_INPUT
> > macro so that it'll read through the string not from the file ? Where
should
> > I call this YY_INPUT ? After calling YY_INPUT,
> > where should I call yy_scan_string( ). How shall I pass my char string
so
> > that it should start parsing ( I mean what should be my entry point into
> > flex& bison)?
>
> All you need to do is call yy_scan_string BEFORE the first call to
yylex().
> There is no need to touch YY_INPUT. (This question pops up frequenty, so I
> guess the manual is unclear.)
>






reply via email to

[Prev in Thread] Current Thread [Next in Thread]