summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y14
1 files changed, 13 insertions, 1 deletions
diff --git a/parse.y b/parse.y
index df16cf62365..dec4b7dfd9c 100644
--- a/parse.y
+++ b/parse.y
@@ -1203,7 +1203,7 @@ static int looking_at_eol_p(struct parser_params *p);
%type <id> cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg f_bad_arg
%type <id> f_kwrest f_label f_arg_asgn call_op call_op2 reswords relop dot_or_colon
%type <id> p_rest p_kwrest p_kwnorest p_any_kwrest p_kw_label
-%type <id> f_no_kwarg f_any_kwrest args_forward excessed_comma
+%type <id> f_no_kwarg f_any_kwrest args_forward excessed_comma nonlocal_var
%type <ctxt> lex_ctxt /* keep <ctxt> in ripper */
%token END_OF_INPUT 0 "end-of-input"
%token <id> '.'
@@ -4517,6 +4517,13 @@ p_var_ref : '^' tIDENTIFIER
/*% %*/
/*% ripper: var_ref!($2) %*/
}
+ | '^' nonlocal_var
+ {
+ /*%%%*/
+ if (!($$ = gettable(p, $2, &@$))) $$ = NEW_BEGIN(0, &@$);
+ /*% %*/
+ /*% ripper: var_ref!($2) %*/
+ }
;
p_expr_ref : '^' tLPAREN expr_value ')'
@@ -4993,6 +5000,11 @@ simple_numeric : tINTEGER
| tIMAGINARY
;
+nonlocal_var : tIVAR
+ | tGVAR
+ | tCVAR
+ ;
+
user_variable : tIDENTIFIER
| tIVAR
| tGVAR