How to define a permutation with EBNF?
-
21-06-2021 - |
Вопрос
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
Решение
Such a thing cannot be expressed in (E)BNF, other than simply defining every permutation manually:
values = "abc" | "acb" | "bac" | "bca" | "cab" | "cba" ;
Не связан с StackOverflow