Re: [Flex-help] Handle NULL-NULL in input stream.
flex is a tool for generating scanners
Brought to you by:
wlestes
From: Allen B. <Al...@ep...> - 2014-12-14 21:46:12
|
I found the issue to be with the way I was providing the input file to flex. I was redirecting file content to stdin which would interpret two consecutive NULLs as the end of the stream thus cutting flex off from the input data. The issue was on Windows and I haven't tested it on any *nix based systems. Thanks for sanity check. Allen Blaylock ________________________________________ From: Chris verBurg [che...@gm...] Sent: Saturday, December 13, 2014 4:48 AM To: Allen Blaylock Cc: fle...@li... Subject: Re: [Flex-help] Handle NULL-NULL in input stream. Hmm, I don't see flex skipping consecutive NULLs. Here's what I got: % perl -e 'open($fh, "> t.in"); print {$fh} "asdf\0\0\0asdf"; close($fh);' % cat t.l %option noyywrap %% . { printf("'%c' = %i\n", yytext[0], yytext[0]); } %% int main(int argc, char ** argv) { yylex(); return 0; } % flex -o t.c t.l % cc t.c % ./a.out < t.in 'a' = 97 's' = 115 'd' = 100 'f' = 102 '' = 0 '' = 0 '' = 0 'a' = 97 's' = 115 'd' = 100 'f' = 102 -Chris On Fri, Dec 12, 2014 at 6:34 AM, Allen Blaylock <Al...@ep...> wrote: > > Is there a way to get the parser to handle more than one consecutive NULL > in the input stream? > > Currently the parser generated by flex recognizes the consecutive NULLs as > an EOF which I do not want, > I would like to be able to tell the parser when the end of file is reached > explicitly through one of my rules calling yyterminate(). > > For instance say I had a blob of binary data in my input file that may > contain a sequence of NULL characters. > Luckily I know the length of the binary data because the preceding token > contains the following binary length. > With this information is it possible to tell the parser, move forward by N > bytes and not scan them? > > Allen Blaylock > > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > > http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk > -- > Flex-help mailing list > Fle...@li... > https://lists.sourceforge.net/lists/listinfo/flex-help > ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk -- Flex-help mailing list Fle...@li... https://lists.sourceforge.net/lists/listinfo/flex-help |