Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,573 changes: 1,317 additions & 1,256 deletions core/src/main/java/org/jruby/ext/ripper/RipperParser.java

Large diffs are not rendered by default.

11,802 changes: 5,997 additions & 5,805 deletions core/src/main/java/org/jruby/ext/ripper/YyTables.java

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions core/src/main/java/org/jruby/ir/builder/IRBuilderAST.java
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,10 @@ protected Operand[] buildCallArgsArray(ListNode args, int[] flags) {

protected Operand[] buildCallArgs(Node args, int[] flags) {
switch (args.getNodeType()) {
case DEFNNODE:
case DEFSNODE:
build(args);
return new Operand[] { new Symbol(((MethodDefNode) args).getName()) };
case ARGSCATNODE:
case ARGSPUSHNODE:
Operand lhs = build(((TwoValueNode) args).getFirstNode());
Expand Down
2,551 changes: 1,298 additions & 1,253 deletions core/src/main/java/org/jruby/parser/RubyParser.java

Large diffs are not rendered by default.

81 changes: 57 additions & 24 deletions core/src/main/java/org/jruby/parser/RubyParser.y
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ import static org.jruby.util.CommonByteLists.FWD_KWREST;
%type <DefHolder> def_name defn_head defs_head
%type <NodeExits> block_open k_while k_until k_for allow_exits
%type <@@prod_type@@> top_compstmt top_stmts top_stmt begin_block endless_arg endless_command
%type <@@prod_type@@> bodystmt compstmt stmts stmt_or_begin stmt expr arg primary command command_call method_call
%type <@@prod_type@@> bodystmt compstmt stmts stmt_or_begin stmt expr arg primary command command_call command_call_value method_call
%type <@@prod_type@@> expr_value expr_value_do arg_value primary_value
%type <@@prod_type@@> rel_expr
%type <@@prod_fcall_type@@> fcall
Expand Down Expand Up @@ -673,9 +673,8 @@ stmt : keyword_alias fitem {
/*% ripper: END!($4) %*/
}
| command_asgn
| mlhs '=' lex_ctxt command_call {
| mlhs '=' lex_ctxt command_call_value {
/*%%%*/
p.value_expr($4);
$$ = node_assign($1, $4, $3);
/*% %*/
/*% ripper: massign!($1, $4) %*/
Expand Down Expand Up @@ -737,20 +736,33 @@ command_asgn : lhs '=' lex_ctxt command_rhs {
/*% %*/
/*% ripper: opassign!(field!($1, $2, $3), $4, $6) %*/
}
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN lex_ctxt command_rhs {
/*%%%*/
p.value_expr($6);
$$ = p.new_attr_op_assign($1, $2, $3, $4, $6);
/*% %*/
/*% ripper: opassign!(field!($1, ID2VAL(idCOLON2), $3), $4, $6) %*/
}
| primary_value tCOLON2 tCONSTANT tOP_ASGN lex_ctxt command_rhs {
/*%%%*/
int line = @1.start();
$$ = p.new_const_op_assign(line, p.new_colon2(line, $1, $3), $4, $6, $5);
/*% %*/
/*% ripper: opassign!(const_path_field!($1, $3), $4, $6) %*/
}
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN lex_ctxt command_rhs {
| tCOLON3 tCONSTANT tOP_ASGN lex_ctxt command_rhs {
/*%%%*/
p.value_expr($6);
$$ = p.new_attr_op_assign($1, $2, $3, $4, $6);
Integer pos = p.src_line();
$$ = p.new_const_op_assign(pos, new Colon3Node(pos, p.symbolID($2)), $3, $5, $4);
/*% %*/
/*% ripper: opassign!(field!($1, ID2VAL(idCOLON2), $3), $4, $6) %*/
/*% ripper: opassign!(top_const_field!($2), $3, $5) %*/
}
| backref tOP_ASGN lex_ctxt command_rhs {
/*%%%*/
p.backref_error($1);
/*% %*/
/*% ripper[error]: backref_error(p, RNODE($1), assign!(var_field(p, $1), $4)) %*/
};
| defn_head f_opt_paren_args '=' endless_command {
p.endless_method_name($1, @1);
p.restore_defun($1);
Expand All @@ -769,12 +781,6 @@ command_asgn : lhs '=' lex_ctxt command_rhs {
/*% %*/
/*% ripper: defs!(AREF($1, 0), AREF($1, 1), AREF($1, 2), $2, bodystmt!($4, Qnil, Qnil, Qnil)) %*/
p.popCurrentScope();
}
| backref tOP_ASGN lex_ctxt command_rhs {
/*%%%*/
p.backref_error($1);
/*% %*/
/*% ripper[error]: backref_error(p, RNODE($1), assign!(var_field(p, $1), $4)) %*/
};

endless_command : command
Expand All @@ -786,15 +792,15 @@ endless_command : command
/*% ripper: rescue_mod!($:1, $:4) %*/
}
| keyword_not opt_nl endless_command {
/*%%%/
$$ = p.call_uni_op(p.method_cond($3), NOT);
/*% ripper: unary!(ID2VAL(idNOT), $:3) %*/
};

command_rhs : command_call %prec tOP_ASGN {
p.value_expr($1);
command_rhs : command_call_value %prec tOP_ASGN {
$$ = $1;
}
| command_call modifier_rescue after_rescue stmt {
| command_call_value modifier_rescue after_rescue stmt {
/*%%%*/
p.getLexContext().in_rescue = $3.in_rescue;
p.value_expr($1);
Expand Down Expand Up @@ -913,6 +919,11 @@ expr_value_do : {
command_call : command
| block_command

command_call_value : command_call {
p.value_expr($1);
$$ = $1;
};

// Node:block_command - A call with a block (foo.bar {...}, foo::bar {...}, bar {...}) [!null]
block_command : block_call
| block_call call_op2 operation2 command_args {
Expand Down Expand Up @@ -1716,7 +1727,7 @@ arg : lhs '=' lex_ctxt arg_rhs {
$$ = node_assign($1, $4, $3);
/*% %*/
/*% ripper: assign!($1, $4) %*/
}
}
| var_lhs tOP_ASGN lex_ctxt arg_rhs {
/*%%%*/
$$ = p.new_op_assign($1, $2, $4, $3);
Expand Down Expand Up @@ -1902,13 +1913,6 @@ arg : lhs '=' lex_ctxt arg_rhs {
p.getLexContext().in_defined = false;
$$ = p.new_defined(@1.start(), $4);
}
| arg '?' arg opt_nl ':' arg {
/*%%%*/
p.value_expr($1);
$$ = p.new_if(@1.start(), $1, $3, $6);
/*% %*/
/*% ripper: ifop!($1, $3, $6) %*/
}
| defn_head f_opt_paren_args '=' endless_arg {
p.endless_method_name($1, @1);
p.restore_defun($1);
Expand All @@ -1930,10 +1934,18 @@ arg : lhs '=' lex_ctxt arg_rhs {
/*% ripper: defs!(AREF($1, 0), AREF($1, 1), AREF($1, 2), $2, bodystmt!($4, Qnil, Qnil, Qnil)) %*/
p.popCurrentScope();
}
| arg '?' arg opt_nl ':' arg {
/*%%%*/
p.value_expr($1);
$$ = p.new_if(@1.start(), $1, $3, $6);
/*% %*/
/*% ripper: ifop!($1, $3, $6) %*/
}
| primary {
$$ = $1;
};


endless_arg : arg %prec modifier_rescue
| endless_arg modifier_rescue after_rescue arg {
p.getLexContext().in_rescue = $3.in_rescue;
Expand Down Expand Up @@ -2073,6 +2085,27 @@ call_args : command {
/*% %*/
/*% ripper: args_add!(args_new!, $1) %*/
}
| defn_head f_opt_paren_args '=' endless_command {
p.endless_method_name($1, @1);
p.restore_defun($1);
/*%%%*/
$$ = new DefnNode($1.line, $1.name, $2, p.getCurrentScope(), p.reduce_nodes(p.remove_begin($4)), @4.end());
if (p.isNextBreak) $<DefnNode>$.setContainsNextBreak();
// Changed from MRI (combined two stmts)
/*% %*/
/*% ripper: def!(get_value($1), $2, bodystmt!($4, Qnil, Qnil, Qnil)) %*/
p.popCurrentScope();
}
| defs_head f_opt_paren_args '=' endless_command {
p.endless_method_name($1, @1);
p.restore_defun($1);
/*%%%*/
$$ = new DefsNode($1.line, (Node) $1.singleton, $1.name, $2, p.getCurrentScope(), p.reduce_nodes(p.remove_begin($4)), @4.end());
if (p.isNextBreak) $<DefsNode>$.setContainsNextBreak();
/*% %*/
/*% ripper: defs!(AREF($1, 0), AREF($1, 1), AREF($1, 2), $2, bodystmt!($4, Qnil, Qnil, Qnil)) %*/
p.popCurrentScope();
}
| args opt_block_arg {
/*%%%*/
$$ = arg_blk_pass($1, $2);
Expand Down
Loading