ruby-changes:30279
From: nobu <ko1@a...>
Date: Fri, 2 Aug 2013 23:14:28 +0900 (JST)
Subject: [ruby-changes:30279] nobu:r42331 (trunk): parse.y: simplify numerics
nobu 2013-08-02 23:14:18 +0900 (Fri, 02 Aug 2013) New Revision: 42331 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42331 Log: parse.y: simplify numerics * parse.y (simple_numeric): integrate numeric literals and simplify numeric rules. Modified files: trunk/ChangeLog trunk/parse.y Index: ChangeLog =================================================================== --- ChangeLog (revision 42330) +++ ChangeLog (revision 42331) @@ -1,4 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 -Fri Aug 2 23:13:18 2013 Nobuyoshi Nakada <nobu@r...> +Fri Aug 2 23:14:16 2013 Nobuyoshi Nakada <nobu@r...> + + * parse.y (simple_numeric): integrate numeric literals and simplify + numeric rules. * ext/ripper/eventids2.c (ripper_init_eventids2): ripper support for new literals, tRATIONAL and tIMAGINARY. Index: parse.y =================================================================== --- parse.y (revision 42330) +++ parse.y (revision 42331) @@ -761,7 +761,7 @@ static void token_info_pop(struct parser https://github.com/ruby/ruby/blob/trunk/parse.y#L761 %type <node> singleton strings string string1 xstring regexp %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 dsym cpath +%type <node> literal numeric simple_numeric dsym cpath %type <node> top_compstmt top_stmts top_stmt %type <node> bodystmt compstmt stmts stmt_or_begin stmt expr arg primary command command_call method_call %type <node> expr_value arg_value primary_value fcall @@ -2110,7 +2110,7 @@ arg : lhs '=' arg https://github.com/ruby/ruby/blob/trunk/parse.y#L2110 $$ = dispatch3(binary, $1, ripper_intern("**"), $3); %*/ } - | tUMINUS_NUM tINTEGER tPOW arg + | tUMINUS_NUM simple_numeric tPOW arg { /*%%%*/ $$ = NEW_CALL(call_bin_op($2, tPOW, $4), tUMINUS, 0); @@ -2119,33 +2119,6 @@ arg : lhs '=' arg https://github.com/ruby/ruby/blob/trunk/parse.y#L2119 $$ = dispatch2(unary, ripper_intern("-@"), $$); %*/ } - | tUMINUS_NUM tFLOAT tPOW arg - { - /*%%%*/ - $$ = NEW_CALL(call_bin_op($2, tPOW, $4), tUMINUS, 0); - /*% - $$ = dispatch3(binary, $2, ripper_intern("**"), $4); - $$ = dispatch2(unary, ripper_intern("-@"), $$); - %*/ - } - | tUMINUS_NUM tRATIONAL tPOW arg - { - /*%%%*/ - $$ = NEW_CALL(call_bin_op($2, tPOW, $4), tUMINUS, 0); - /*% - $$ = dispatch3(binary, $2, ripper_intern("**"), $4); - $$ = dispatch2(unary, ripper_intern("-@"), $$); - %*/ - } - | tUMINUS_NUM tIMAGINARY tPOW arg - { - /*%%%*/ - $$ = NEW_CALL(call_bin_op($2, tPOW, $4), tUMINUS, 0); - /*% - $$ = dispatch3(binary, $2, ripper_intern("**"), $4); - $$ = dispatch2(unary, ripper_intern("-@"), $$); - %*/ - } | tUPLUS arg { /*%%%*/ @@ -4310,11 +4283,8 @@ dsym : tSYMBEG xstring_contents tSTRING https://github.com/ruby/ruby/blob/trunk/parse.y#L4283 } ; -numeric : tINTEGER - | tFLOAT - | tRATIONAL - | tIMAGINARY - | tUMINUS_NUM tINTEGER %prec tLOWEST +numeric : simple_numeric + | tUMINUS_NUM simple_numeric %prec tLOWEST { /*%%%*/ $$ = negate_lit($2); @@ -4322,30 +4292,12 @@ numeric : tINTEGER https://github.com/ruby/ruby/blob/trunk/parse.y#L4292 $$ = dispatch2(unary, ripper_intern("-@"), $2); %*/ } - | tUMINUS_NUM tFLOAT %prec tLOWEST - { - /*%%%*/ - $$ = negate_lit($2); - /*% - $$ = dispatch2(unary, ripper_intern("-@"), $2); - %*/ - } - | tUMINUS_NUM tRATIONAL %prec tLOWEST - { - /*%%%*/ - $$ = negate_lit($2); - /*% - $$ = dispatch2(unary, ripper_intern("-@"), $2); - %*/ - } - | tUMINUS_NUM tIMAGINARY %prec tLOWEST - { - /*%%%*/ - $$ = negate_lit($2); - /*% - $$ = dispatch2(unary, ripper_intern("-@"), $2); - %*/ - } + ; + +simple_numeric : tINTEGER + | tFLOAT + | tRATIONAL + | tIMAGINARY ; user_variable : tIDENTIFIER -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/