I have a protocol that's specified as an ABNF grammar. It describes a "message" of composite parts. I want to provide that BNF_spec.txt as input to <something>, and get as output:
The flex/bison toolchain has me arse-deep in converting the grammar I have into the grammar it wants. Even if I were to slog through that nightmare, I'm still left with building the data structure myself, and then fiddling with manual memory management to fill it. And then, debugging the errors I'll inevitably (unknowingly) inject into the bison grammar would be nigh-impossible. No thanks. Antlr wants me to install forty Java build tools just to get it running, which is a long road I don't want to start going down if I can in any way avoid it. I can write a recursive descent parser myself from scratch, which I've done before for other similar protocols, but it's long and boring work that I sense can be avoided.
What are my options, here?
- Protocol.h[pp], containing a data structure in C or C++ that represents that "message": struct ProtocolMessage { ... };
- Protocol.c[pp], containing a function to parse an input buffer and return a valid "message" structure: ProtocolMessage_t parse(char *buffer, size_t len) { ... }
The flex/bison toolchain has me arse-deep in converting the grammar I have into the grammar it wants. Even if I were to slog through that nightmare, I'm still left with building the data structure myself, and then fiddling with manual memory management to fill it. And then, debugging the errors I'll inevitably (unknowingly) inject into the bison grammar would be nigh-impossible. No thanks. Antlr wants me to install forty Java build tools just to get it running, which is a long road I don't want to start going down if I can in any way avoid it. I can write a recursive descent parser myself from scratch, which I've done before for other similar protocols, but it's long and boring work that I sense can be avoided.
What are my options, here?