Try this:
main:
a option(b) option(c) option(d) { [Some($1); $2; $3; $4] }
| b option(c) option(d) { [None; Some($1); $2; $3] }
| c option(d) { [None; None; Some($1); $2] }
| d { [None; None; None; Some($1)] }
I removed the last option, which matches the empty sequence, because it contradicts your requirement that at least one of a
, b
, c
or d
be present. If you are prepared to accept empty, you could just use
main:
option(a) option(b) option(c) option(d) { [$1; $2; $3; $4] }
although you might want to adjust the action to return [] in the case where all four options are None.