Re: [Flex-help] working with two bufffers?
flex is a tool for generating scanners
Brought to you by:
wlestes
From: Oliver B. <li...@ol...> - 2009-11-17 22:41:26
|
Hello, after another change I could get the unfolding work properly. But I like your suggestion to separate the unfolding from the scanner though. I changed my regular expressions to from > folded_line ^[^\r\n]*{mycrlf}{wsp} to folded_line ^[^\r\n]*{mycrlf}/{wsp} and did some other minor changes because yyleng is different due to the use of {wsp} as lookahead pattern. I am not sure why the first expression did only match every second result. I assume that this has to do with the length of actual lines that are scanned but this is just a hunch. Best regards, Oliver Block Marcel Laverdet schrieb: > I would recommend writing your stream unfolder outside of Flex because > it's an extremely simple transformation. Then run Flex to scan for tokens > in your unfolded stream. A manual unfolder is going to be more effective > since the transformed text will always be smaller than the original text so > you can reuse memory and avoid having to alloc twice. I would just alloc > the size of your file plus 2 bytes, run the manual unfolding (just a simple > for loop), terminate the unfolded text with 2 NULL bytes, then use > yy_scan_buffer on that text. > |