summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-10-26 18:00:24 +0900
committerGitHub <noreply@github.com>2020-10-26 18:00:24 +0900
commit52c630da004d9273e8e5fc91c6304e9eed902566 (patch)
tree8414c98aa099355174ca6525757128d560ce5f8a /parse.y
parentcffdacb15a363321e1c1879aa7d94924acafd1cf (diff)
Assoc pattern matching (#3703)
[Feature #17260] One-line pattern matching using tASSOC R-assignment is rejected instead.
Notes
Notes: Merged-By: nobu <nobu@ruby-lang.org>
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y37
1 files changed, 3 insertions, 34 deletions
diff --git a/parse.y b/parse.y
index f8d05ad44a..85cb671d44 100644
--- a/parse.y
+++ b/parse.y
@@ -1150,7 +1150,7 @@ static int looking_at_eol_p(struct parser_params *p);
%type <node> string_contents xstring_contents regexp_contents string_content
%type <node> words symbols symbol_list qwords qsymbols word_list qword_list qsym_list word
%type <node> literal numeric simple_numeric ssym dsym symbol cpath def_name defn_head defs_head
-%type <node> top_compstmt top_stmts top_stmt begin_block rassign
+%type <node> top_compstmt top_stmts top_stmt begin_block
%type <node> bodystmt compstmt stmts stmt_or_begin stmt expr arg primary command command_call method_call
%type <node> expr_value expr_value_do arg_value primary_value fcall rel_expr
%type <node> if_tail opt_else case_body case_args cases opt_rescue exc_list exc_var opt_ensure
@@ -1242,7 +1242,7 @@ static int looking_at_eol_p(struct parser_params *p);
%nonassoc tLOWEST
%nonassoc tLBRACE_ARG
-%nonassoc modifier_if modifier_unless modifier_while modifier_until keyword_in
+%nonassoc modifier_if modifier_unless modifier_while modifier_until
%left keyword_or keyword_and
%right keyword_not
%nonassoc keyword_defined
@@ -1548,40 +1548,9 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem
/*% %*/
/*% ripper: massign!($1, $3) %*/
}
- | rassign
| expr
;
-rassign : arg_value tASSOC lhs
- {
- /*%%%*/
- $$ = 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) %*/
- }
- | rassign tASSOC mlhs
- {
- /*%%%*/
- $$ = node_assign(p, $3, $1, &@$);
- /*% %*/
- /*% ripper: massign!($3, $1) %*/
- }
- ;
-
command_asgn : lhs '=' command_rhs
{
/*%%%*/
@@ -1677,7 +1646,7 @@ expr : command_call
{
$$ = call_uni_op(p, method_cond(p, $2, &@2), '!', &@1, &@$);
}
- | arg keyword_in
+ | arg tASSOC
{
value_expr($1);
SET_LEX_STATE(EXPR_BEG|EXPR_LABEL);