Re: LexerInput

Mihai Badea <[email protected]> Mon, 27 Nov 2006 15:47:53 +0200
Newsgroups gmane.comp.lex.flex.general
Message-ID <[email protected]>
Mihai Badea wrote:
> Mihai Badea wrote:
>> Hi,
>>
>> I am studying a way to parse text data directly from memory (without 
>> using aditional temporary buffers). My questions are:
>> For C Flex:
>> What is the procedure to make sure that after using scan_buffer() as 
>> input method for Flex, the directly-scanned memory buffer remains 
>> intact (the content is restored)?
>> For Flex++:
>> Is there a way to addapt LexerInput() in such a way the scanning is 
>> done directly from the memory instead of reading into an additional 
>> buffer? If so, I have the same question regarding to the preservation 
>> of the buffer.
>> Any information or link to something would be helpful.
>>
>> Thanks and best regards,
>> Mihai
> 
> Well seems to me that either my question was not well stated, or maybe 
> it was not a problem of any interest or I don't know...
> Please someone reply to me (even in pvt) and say anything (stupid 
> question etc.).


Hi Martin,

Thanks for your answer:

 >   Did you try it, and it corrupted your buffer?  Since flex can read
 > input from a read-only file or stream, it's not even supposed to be
 > possible to alter the input...
 >
 > - - Martin Thurn

Regarding this, maybe I haven't well stated my question. Flex uses an 
internal buffer to process text data:

------------------------------------------------
|Original Input Data (File/Stream/Memory) (R/O)|
------------------------------------------------
	|
	|
	V
----------------------------------------------
|Flex's Internal Buffer (R/W) (gets modified)|
----------------------------------------------
	|
	|
	V
--------------------------------------
|Desired Results (i.e. data stucture)|
--------------------------------------

As I already have the text in memory, I try to avoid the internal buffer 
(by using directly the original buffer):

--------------------------------------------------
--------------------------------------------------
|| Original Data && Flex's Internal buffer (R/W)||
--------------------------------------------------
--------------------------------------------------
	|
	|
	V
--------------------------------------
|Desired Results (i.e. data stucture)|
--------------------------------------

Although possible, this will modify the original data buffer. What I was 
trying to find was a safe mechanism to ensure the integrity of the 
original buffer at the end of the scanning.

Best regards,
Mihai