From 9cbb4dde74f854b0cfcdb48b1ce0604894c83665 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 5 Jan 2019 13:15:07 +0000 Subject: parse.y: refactored symbol rules * parse.y (symbol): turned into a node, as well as `numeric`, for a symbol literal, and includes `dsym` now. * parse.y (ssym): previous `symbol`. renamed as the counterpart of `dsym`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- parse.y | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/parse.y b/parse.y index bc1aa1f16c..701497c733 100644 --- a/parse.y +++ b/parse.y @@ -834,7 +834,7 @@ static void token_info_warn(struct parser_params *p, const char *token, token_in %type singleton strings string string1 xstring regexp %type string_contents xstring_contents regexp_contents string_content %type words symbols symbol_list qwords qsymbols word_list qword_list qsym_list word -%type literal numeric simple_numeric dsym cpath +%type literal numeric simple_numeric ssym dsym symbol cpath %type top_compstmt top_stmts top_stmt begin_block %type bodystmt compstmt stmts stmt_or_begin stmt expr arg primary command command_call method_call %type expr_value expr_value_do arg_value primary_value fcall rel_expr @@ -853,7 +853,7 @@ static void token_info_warn(struct parser_params *p, const char *token, token_in %type lambda f_larglist lambda_body brace_body do_body %type brace_block cmd_brace_block do_block lhs none fitem %type mlhs mlhs_head mlhs_basic mlhs_item mlhs_node mlhs_post mlhs_inner -%type fsym keyword_variable user_variable sym symbol operation operation2 operation3 +%type keyword_variable user_variable sym operation operation2 operation3 %type cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg f_bad_arg %type f_kwrest f_label f_arg_asgn call_op call_op2 reswords relop dot_or_colon %token END_OF_INPUT 0 "end-of-input" @@ -1763,18 +1763,14 @@ fname : tIDENTIFIER } ; -fsym : fname - | symbol - ; - -fitem : fsym +fitem : fname { /*%%%*/ $$ = NEW_LIT(ID2SYM($1), &@$); /*% %*/ /*% ripper: symbol_literal!($1) %*/ } - | dsym + | symbol ; undef_list : fitem @@ -3421,13 +3417,6 @@ opt_ensure : k_ensure compstmt literal : numeric | symbol - { - /*%%%*/ - $$ = NEW_LIT(ID2SYM($1), &@$); - /*% %*/ - /*% ripper: symbol_literal!($1) %*/ - } - | dsym ; strings : string @@ -3757,13 +3746,17 @@ string_dvar : tGVAR | backref ; -symbol : tSYMBEG sym +symbol : ssym + | dsym + ; + +ssym : tSYMBEG sym { SET_LEX_STATE(EXPR_END); /*%%%*/ - $$ = $2; + $$ = NEW_LIT(ID2SYM($2), &@$); /*% %*/ - /*% ripper: symbol!($2) %*/ + /*% ripper: symbol_literal!(symbol!($2)) %*/ } ; -- cgit v1.2.3