3

I have a number of packet formats that are bit-oriented. Rather than writing many fairly complex lexer by hand I am looking for a bit-level lexer generator, a bit-oriented version of flex/lex say. Obviously I could just write straight C, but I was wondering whether such a bit-level lexer generator exists. After a quick Google, I found a number of media decoders and such, however, I am not parsing media files, but network packets.

Alternatively is there a way to run flex in a bit-oriented made?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
jhoyla
  • 1,191
  • 1
  • 9
  • 26

1 Answers1

1

You could look into redefining YY_INPUT (see Generated Scanner in the flex documentation) and decompose each input byte into its individual bits and use '0' and '1' as alphabet of the regular expressions. You may want to consider if a slightly bigger alphabet can be defined with a simple definition of YY_INPUT.

Bryan Olivier
  • 5,207
  • 2
  • 16
  • 18