Last active
September 19, 2020 09:47
-
-
Save k-tsj/25c6da431c109c1879c11dc326b0614e to your computer and use it in GitHub Desktop.
Pattern matching with R-assign
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/parse.y b/parse.y | |
index 93bc2ef9ff..81db9a660d 100644 | |
--- a/parse.y | |
+++ b/parse.y | |
@@ -1539,33 +1539,23 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem | |
| expr | |
; | |
-rassign : arg_value tASSOC lhs | |
+rassign : arg_value tASSOC | |
{ | |
- /*%%%*/ | |
- $$ = node_assign(p, $3, $1, &@$); | |
- /*% %*/ | |
- /*% ripper: assign!($3, $1) %*/ | |
- } | |
- | arg_value tASSOC mlhs | |
- { | |
- /*%%%*/ | |
- $$ = node_assign(p, $3, $1, &@$); | |
- /*% %*/ | |
- /*% ripper: massign!($3, $1) %*/ | |
- } | |
- | rassign tASSOC lhs | |
- { | |
- /*%%%*/ | |
- $$ = node_assign(p, $3, $1, &@$); | |
- /*% %*/ | |
- /*% ripper: assign!($3, $1) %*/ | |
+ value_expr($1); | |
+ SET_LEX_STATE(EXPR_BEG|EXPR_LABEL); | |
+ p->command_start = FALSE; | |
+ $<ctxt>$ = p->ctxt; | |
+ p->ctxt.in_kwarg = 1; | |
} | |
- | rassign tASSOC mlhs | |
+ {$<tbl>$ = push_pvtbl(p);} | |
+ p_expr | |
+ {pop_pvtbl(p, $<tbl>4);} | |
{ | |
+ p->ctxt.in_kwarg = $<ctxt>3.in_kwarg; | |
/*%%%*/ | |
- $$ = node_assign(p, $3, $1, &@$); | |
+ $$ = new_case3(p, $1, NEW_IN($5, 0, 0, &@5), &@$); | |
/*% %*/ | |
- /*% ripper: massign!($3, $1) %*/ | |
+ /*% ripper: case!($1, in!($5, Qnil, Qnil)) %*/ | |
} | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment