@@ -1002,7 +1002,7 @@ static void token_info_warn(struct parser_params *p, const char *token, token_in
10021002%type <node> literal numeric simple_numeric ssym dsym symbol cpath
10031003%type <node> top_compstmt top_stmts top_stmt begin_block
10041004%type <node> bodystmt compstmt stmts stmt_or_begin stmt expr arg primary command command_call method_call
1005- %type <node> expr_value expr_value_do arg_value primary_value fcall rel_expr
1005+ %type <node> expr_value expr_value_do arg_value primary_value fcall rel_expr pipeline
10061006%type <node> if_tail opt_else case_body case_args cases opt_rescue exc_list exc_var opt_ensure
10071007%type <node> args call_args opt_call_args
10081008%type <node> paren_args opt_paren_args args_tail opt_args_tail block_args_tail opt_block_args_tail
@@ -1060,6 +1060,7 @@ static void token_info_warn(struct parser_params *p, const char *token, token_in
10601060%token <id> tANDDOT RUBY_TOKEN (ANDDOT ) " &."
10611061%token <id> tCOLON2 RUBY_TOKEN (COLON2 ) " ::"
10621062%token <id> tMETHREF RUBY_TOKEN (METHREF ) " .:"
1063+ %token tPIPE RUBY_TOKEN (PIPE ) " |>"
10631064%token tCOLON3 " :: at EXPR_BEG"
10641065%token <id> tOP_ASGN " operator-assignment" /* +=, -= etc. */
10651066%token tASSOC " =>"
@@ -1095,6 +1096,7 @@ static void token_info_warn(struct parser_params *p, const char *token, token_in
10951096%nonassoc modifier_if modifier_unless modifier_while modifier_until
10961097%left keyword_or keyword_and
10971098%right keyword_not
1099+ %left tPIPE
10981100%nonassoc keyword_defined
10991101%right ' =' tOP_ASGN
11001102%left modifier_rescue
@@ -2269,12 +2271,29 @@ arg : lhs '=' arg_rhs
22692271 /* % %*/
22702272 /* % ripper: ifop!($1, $3, $6) %*/
22712273 }
2274+ | pipeline
22722275 | primary
22732276 {
22742277 $$ = $1 ;
22752278 }
22762279 ;
22772280
2281+ pipeline : arg tPIPE operation2 opt_paren_args
2282+ {
2283+ /* %%%*/
2284+ $$ = new_command_qcall(p, ID2VAL (idPIPE), $1 , $3 , $4 , Qnull, &@3 , &@$ );
2285+ /* % %*/
2286+ /* % ripper: command_call!($1, ID2VAL(idPIPE), $3, $4) %*/
2287+ }
2288+ | arg tPIPE operation2 opt_paren_args brace_block
2289+ {
2290+ /* %%%*/
2291+ $$ = new_command_qcall(p, ID2VAL (idPIPE), $1 , $3 , $4 , $5 , &@3 , &@$ );
2292+ /* % %*/
2293+ /* % ripper: method_add_block!(command_call!($1, ID2VAL(idPIPE), $3, $4), $5) %*/
2294+ }
2295+ ;
2296+
22782297relop : ' >' {$$ = ' >' ;}
22792298 | ' <' {$$ = ' <' ;}
22802299 | tGEQ {$$ = idGE;}
@@ -8924,6 +8943,10 @@ parser_yylex(struct parser_params *p)
89248943 SET_LEX_STATE (EXPR_BEG );
89258944 return tOP_ASGN;
89268945 }
8946+ if (c == ' >' ) {
8947+ SET_LEX_STATE (EXPR_DOT );
8948+ return tPIPE;
8949+ }
89278950 SET_LEX_STATE (IS_AFTER_OPERATOR () ? EXPR_ARG : EXPR_BEG |EXPR_LABEL );
89288951 pushback (p, c);
89298952 return ' |' ;
0 commit comments