-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Support .a.[] and .a.[]? each syntax #2650
Conversation
} | | ||
Term '.' '[' ']' %prec NONOPT { | ||
$$ = block_join($1, gen_op_simple(EACH)); | ||
} | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe there a nice way? some concerns:
- I'm a bit bit confused how the chaining/suffix-list thing actually works in the grammar, what rule allows for the chaining?
- Does the new rules allow for some syntax that we don't want?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably also support slice syntax? .a.[1:2]
. Looking at the grammar the slice stuff has lots of rules. Wondering if there is some nice way to add optional dot without duplicating all the rules?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I second @wader's comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit bit confused how the chaining/suffix-list thing actually works in the grammar, what rule allows for the chaining?
This one:
Exp '|' Exp {
$$ = block_join($1, $3);
} |
and:
Exp:
FuncDef Exp %prec FUNCDEF {
$$ = block_bind_referenced($1, $2, OP_IS_CALL_PSEUDO);
} |
... /* elided */
Term {
$$ = $1;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the new rules allow for some syntax that we don't want?
I don't think so.
0a082d1
to
b59fb49
Compare
I mean, |
Yeap looks a bit weird :) the main reason for me is mostly to make things more consistent now when |
Oh. Interesting, I hadn't noticed that we allow that now. Yeah, I agree that if we're going to allow |
I believe this PR also in effect addresses the concerns expressed in #2512 |
LGTM |
Thanks! |
} | | ||
Term '.' '[' ']' %prec NONOPT { | ||
$$ = block_join($1, gen_op_simple(EACH)); | ||
} | | ||
Term '[' Exp ':' Exp ']' '?' { | ||
$$ = gen_slice_index($1, $3, $5, INDEX_OPT); | ||
} | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicowilliams Sorry i should have marked this PR as draft as i think we probably want to support extra dot with all the different slice variants? also probably good with some basic tests for it. Then also thinking if there is some nicer way to write the rules that don't need as much duplication?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can always add that later.
Fixes #1699