-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
repeat.as outputs [] for empty string input #126
Comments
Yes there is. It becomes apparent when you do something like this:
However, I would consider a second (third/last) argument to
|
Just want to say that i also have some rules that i would like to clean up, remove the duplication. |
|
If you add multiple layers of Entity, Sequence, ... on top, you wont be able to tell. |
I've thought about this and see the opportunity for improvement now. I'll execute your last idea as soon as I get to it. |
Is there any plan to implement this? This issue is old but looks like there has been some recent activity on the repo. I agree with everything @hagabaka said above. |
Normally when you use
as
onrepeat
, the matched string will be in the result hash:However when the input string is empty, which
repeat
accepts by default, the result will have an empty array instead:This inconsistency makes it hard to write transform rules, because "simple" only matches if the input string is non-empty, and "sequence" only matches if the input is empty:
Of course if the subtree is as simple as
{:b => '...'}
or{:b => []}
, another transform rule can normalize them. But if there are multiple keys in the subtree, it would be tedious to write that rule. Is there a reason why the parser shouldn't just output empty string forrepeat.as
when the input is empty?The text was updated successfully, but these errors were encountered: