Related articles |
---|
Binary File parsing with Flex & Bison??? usenet.raghu@gmail.com (Raghu Kodali) (2005-05-14) |
Re: Binary File parsing with Flex & Bison??? haberg@math.su.se (2005-05-14) |
From: | "Raghu Kodali" <usenet.raghu@gmail.com> |
Newsgroups: | comp.compilers |
Date: | 14 May 2005 02:06:51 -0400 |
Organization: | Compilers Central |
Keywords: | flex, question, comment |
Posted-Date: | 14 May 2005 02:06:51 EDT |
Hi All,
Can I use Flex & Bison to parse a binary file?
I know the BNF of the binary file but I dont know how to do it with
Flex & Bison.
Can you please let me know if this is possible? if yes, how?
Thanks
Raghu
[Flex is pretty much 8-bit clean, so you can put arbitrary bytes in
your patterns as \123 or \x42. You might want to check carefully to
make sure that \000 zero bytes are handled correctly. If your file
format is more complex than flex can handle on its own, your lexer can
be called from a yacc or bison parser like any other flex lexer. Yacc
parsers parse tokens, not input bytes, so they don't care what the
input format was, altough again you need to be sure that you're using
lengths when passing around binary strings from the input and not
trying to zero-terminate them. -John]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.