Re: [Flex-help] Handle NULL-NULL in input stream.
flex is a tool for generating scanners
Brought to you by:
wlestes
From: Chris v. <che...@gm...> - 2014-12-13 11:49:25
|
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 > |