I am looking for a solution to parse asn.1 spec files and generate a decoder from those.
Ideally I would like to work with Python modules, but if nothing is available I would use C/C++ libraries and interface them with Python with the plethora of solutions out there.
In the past I have been using pyasn1 and building everything by hand but that has become too unwieldly.
I have also looked superficially to libtasn1 and asn1c. The first one had problems parsing even the simplest of files. The second has a good parser but generating C code for decoding seems too complex; the solution worked well with straightforward specs but choked on complex ones.
Any other good alternatives I may have overlooked?
I wrote such parser a few years ago. It generates python classes for pyasn1 library. I used in on ericsson doc to make parser for their CDRs.
I'll try posting the code here now.
This will take a file with syntax, similar to this one:
You will need to add this line on top of the generated file:
And name the result defs.py. Then, I attached a bunch of prettyprinters to the defs (if you don't have just skip it)
Then, it's down to:
If you're still interested I'll put the code somewhere. In fact, I'll put it somewhere in any case - but if you're interested just let me know and I'll point you there.