| I built a grammar to tackle these sorts of problems when I had trouble writing formal grammar notations for my binary data format. It's even got a syntax highlighter. https://dogma-lang.org/ So far it's been able to describe 90% of what's out there. Some examples: - 802.3 layer 2 Ethernet: https://github.com/kstenerud/dogma/blob/master/v1/examples/8... - Microsoft ICO format: https://github.com/kstenerud/dogma/blob/master/v1/examples/i... - Android Dex v39: https://github.com/kstenerud/dogma/blob/master/v1/examples/d... - IPv4: https://github.com/kstenerud/dogma/blob/master/v1/examples/i... - DNS query: https://github.com/kstenerud/dogma/blob/master/v1/examples/d... - Microsoft Minidump: https://github.com/kstenerud/dogma/blob/master/v1/examples/m... - Concise Binary Encoding: https://github.com/kstenerud/concise-encoding/blob/master/cb... - Concise Text Encoding: https://github.com/kstenerud/concise-encoding/blob/master/ct... |