aboutsummaryrefslogtreecommitdiffstats
path: root/parse.y
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-18 13:08:53 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-18 13:08:53 +0000
commitc1c3d07332d32f0981d6019c3f851e51739f0eb2 (patch)
tree0924474058037da85876a48fbac3c92718fbddc5 /parse.y
parent05fee6c108e1452d9481e6fe488dede5fc6613c4 (diff)
downloadruby-c1c3d07332d32f0981d6019c3f851e51739f0eb2.tar.gz
parse.y: relop
* parse.y (relop): extract to simplify comparisons. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y24
1 files changed, 9 insertions, 15 deletions
diff --git a/parse.y b/parse.y
index 94b268bfb9..2cd5c1eff0 100644
--- a/parse.y
+++ b/parse.y
@@ -914,7 +914,7 @@ static void token_info_pop_gen(struct parser_params*, const char *token, size_t
%type <node> mlhs mlhs_head mlhs_basic mlhs_item mlhs_node mlhs_post mlhs_inner
%type <id> fsym keyword_variable user_variable sym symbol operation operation2 operation3
%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
+%type <id> f_kwrest f_label f_arg_asgn call_op call_op2 reswords relop
/*%%%*/
/*%
%type <val> program then do
@@ -2093,21 +2093,9 @@ arg : lhs '=' arg_rhs
{
$$ = call_bin_op($1, idCmp, $3);
}
- | arg '>' arg
+ | arg relop arg %prec '>'
{
- $$ = call_bin_op($1, '>', $3);
- }
- | arg tGEQ arg
- {
- $$ = call_bin_op($1, idGE, $3);
- }
- | arg '<' arg
- {
- $$ = call_bin_op($1, '<', $3);
- }
- | arg tLEQ arg
- {
- $$ = call_bin_op($1, idLE, $3);
+ $$ = call_bin_op($1, $2, $3);
}
| arg tEQ arg
{
@@ -2178,6 +2166,12 @@ arg : lhs '=' arg_rhs
}
;
+relop : '>' {$$ = '>';}
+ | '<' {$$ = '<';}
+ | tGEQ {$$ = idGE;}
+ | tLEQ {$$ = idLE;}
+ ;
+
arg_value : arg
{
/*%%%*/