I am trying to write a grammar for EXR files. These have a header with a list of attributes. each attribute consists of an attribute name (string), type (another string), size (int) and then some data (dependent on the size). There are various predefined attribute types that I can write grammars to parse, and can fall back to a base-case undefined attribute for any unknown attribute types. This seems to be mostly working.
The problem is that this list of attributes is null terminated. So I need to know when there is a zero at the start of the next structure, and then move on to parsing the next bit of the file. Since the grammar is trying to parse another attribute, this shows up as a zero length attribute name (attribute names are zero-terminated). As far as I can tell there is no way to reject a zero-length string. And no direct way to detect the null terminator. I have written a script that detects the zero-length string, but then I don't know how to control the parser to tell it to move on. Any ideas?