Is there a way, in BNF, to specify a rule that an element consists of a list of items, and each item is optional, can appear only once, and order isn't important?

For example:

<meal> ::= <appetizer><salad><entree><dessert>

<appetizer> ::= <empty> | <cheeseplate> | <breadsticks> | ...

etc.

So I have my meal parts, all of which are optional (because I include the <empty> item). But how do I allow arbitrary sequences (e.g. <dessert> first)?

Thanks in advance

There isn't an easy way to do that in BNF, but maybe there is via one of its extensions. However, I'm pretty sure the mainstream extensions don't have that facility either.

There isn't an easy way to do that in BNF, but maybe there is via one of its extensions. However, I'm pretty sure the mainstream extensions don't have that facility either.

It seems to me it's a problem with my grammar and not the tools - I'll redesign it to avoid the construct. Thanks for your assistance.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.