Proposal:
Make the expression of an "optional" field optional.
When parsing an optional field the parser always saves the current position before starting to parse the field.
If when parsing the field no "AssertionException" is being caught, this information is just discarded. If however such an exception is caught, then the parser resets the position to the initial position and the next field can continue parsing from that location.
In addition to this, we add a new field type: "assertion" ... these can generally be seen similar to "const" fields. However in contrast to "const" fields these need to be saved as properties in the model. An assert field contains an expression field. If the value parsed matches this, the value is saved in the property. If however this value doesn't match the expected value, an "AssertionException" is thrown.
These changes are intended especially for protocols like BacNET and PROFINET where there are optional fields, based on their content.