Open queerviolet opened 6 years ago
That's funny; I added a similar feature in the past but then reverted it, mainly because arrays have special meaning in other places of the grammar (conflicts
, extras
, externals
, inline
), and so auto-converting them to rules in certain cases seemed to muddy the waters more than it helped.
I think that I'd rather address this problem by having optional
and repeat1
throw exceptions if you ever pass more than one argument, with an error like "Did you mean to put these rules in a seq
or a choice
?"
Ahhhh. Okay, that's fair. I'll tweak this PR to do that.
This PR is purely ergonomic. I find that I keep doing things like this:
(instead of
)
My time-of-confusion is dropping, but I'm still doing it occasionally, so I figure maybe it's worth just making it work.
As an also-nice-I-think side effect, this PR means we'll now interpret arrays as sequences when they occur as rule bodies.