0

i have a file format that looks like the following:

fileformat : <flag1><flag2><flag3><flag4><field1><field2><field3><field4>

each flag is 1 bit, and each field is 1 byte. when the flag is '1', the respective field will be present. when the flag is '0', the respective field will be absent.

is there a way to represent that in EBNF/BNF without enumerating all the 2^4 possibilities?

falsetru
  • 357,413
  • 63
  • 732
  • 636
  • If there were it wouldn't be context free. – ahilsend Jul 30 '13 at 07:24
  • Context-free grammars encoded in (E)BNF don't address how entities are packed, or deep semantic relationships among them. It can encode the fact that you have 4 flags, followed by 4 optional fields, but not that the field presence is controlled by the flags. – Ira Baxter Jul 30 '13 at 08:19

0 Answers0