Question

I'm using EBNF to define a grammar.

But I'm stuck because I need to define a permutation : I have a set of values that can be combined, but they have to be used only once and I don't care about the order.

How to do it with EBNF ?

example: values : a, b ,c

possible combinations : abc, acb, bac, bca, cab, cba

Was it helpful?

Solution

Such a thing cannot be expressed in (E)BNF, other than simply defining every permutation manually:

values = "abc" | "acb" | "bac" | "bca" | "cab" | "cba" ;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top