[Flex-help] Reading from a buffer.
flex is a tool for generating scanners
Brought to you by:
wlestes
From: Timothy S. Ph.D. <sch...@gm...> - 2014-01-31 05:09:28
|
Hello, I am using flex to scan a buffer I have in memory. I see the methods yy_scan_string, yy_scan_bytes and yy_scan_buffer. These methods appear to (1) copy data and (2) want to see two trailing NULLs at the end of the buffer. So my question is: is there a way to have flex use an existing in-memory buffer that doesn't necessarily have two trailing NULLs without making an entire copy of it? For example, can I just define the YY_INPUT macro to read from my buffer or something similar? As a follow up, what is the motivation for requiring the trailing NULLs? If you know the length why does it matter that a buffer has these? I could make my own yy_scan_bytes method but I am worried that flex will not find the trailing NULLs it wants and everything will crash and burn. Thanks! Tim |