-
Notifications
You must be signed in to change notification settings - Fork 43
Description
from @Mohan-Dhawan on Slack
Spicy does not allow enum fields to be defined using expressions, for example:
type MyPolicy = enum { NONE = 0, SUCCESS = 1, FAILURE = 2, ALL = (SUCCESS | FAILURE), CLEAR = 4, };Is there an easy workaround for this limitation? I am translating from an existing DSL specification in which such expressions are common. Allowing expressions in enum definitions would be a useful enhancement to Spicy
I agree with this. Right now, the enum_label is parsed to only be CUINTEGER (which is just ints and character literals). It'd be nice to have more flexibility.
There are a couple hurdles here, namely that we would need to fold the SUCCESS | FAILURE constant at some point, then validate that to ensure that it's not overlapping with another enum label and whatnot. I think that problem and some related ones would make this tricky, but doable.