|Binary File parsing with Flex & Bison??? email@example.com (Raghu Kodali) (2005-05-14)|
|Re: Binary File parsing with Flex & Bison??? firstname.lastname@example.org (2005-05-14)|
|From:||"Raghu Kodali" <email@example.com>|
|Date:||14 May 2005 02:06:51 -0400|
|Keywords:||flex, question, comment|
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?
[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
Search the comp.compilers archives again.