help-flex
[Top][All Lists]
Advanced

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

scanning from buffer in-place


From: Matt Carter
Subject: scanning from buffer in-place
Date: Tue, 19 Mar 2002 17:22:16 -0500

I would like to be able to use flex to scan from a buffer "in-place" (i.e.,
without making copies of the data).  I want an in-place scanner because I
want to avoid the unnecessary cost of copying and I want to minimize memory
allocations.  None of my scan actions modifies yytext, so in theory, I
shouldn't need to do any copying from the original data string.

I would use yy_scan_buffer(), but I can't because:
  1) it requires the buffer to have two trailing NILs, which requires me to
make a copy, which defeats the purpose of avoiding unnecessary copying, and
  2) yy_scan_buffer() only seems to be available in basic flex (not flex++),
and my application requires the thread safety of flex++ .

I haven't been able to find anything in the flex++ documentation telling how
to scan a string in place.  In fact, it seems impossible because
yyFlexLexer::yylex() calls yy_get_next_buffer() which calls YY_INPUT() which
calls LexerInput() which _has_ to copy data .  I don't see any way around
it.

Is there any way to thread-safely scan from a string in-place?

Thank you.



reply via email to

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