Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
ruby
提交
1b2d351b
R
ruby
项目概览
张重言
/
ruby
通知
3
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
ruby
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
1b2d351b
编写于
6月 11, 2019
作者:
N
Nobuyoshi Nakada
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rightward-assign by ASSOC
[Feature #15921]
上级
d94960f2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
52 addition
and
2 deletion
+52
-2
NEWS.md
NEWS.md
+7
-0
parse.y
parse.y
+38
-2
test/ruby/test_syntax.rb
test/ruby/test_syntax.rb
+7
-0
未找到文件。
NEWS.md
浏览文件 @
1b2d351b
...
...
@@ -38,6 +38,12 @@ sufficient information, see the ChangeLog file or Redmine
instead of a warning. yield in a class definition outside of a method
is now a SyntaxError instead of a LocalJumpError. [[Feature #15575]]
*
Rightward assignment statement is added. [[Feature #15921]]
```ruby
fib(10) => x
```
## Command line options
## Core classes updates
...
...
@@ -170,5 +176,6 @@ Excluding feature bug fixes.
[
Feature #16274
]:
https://bugs.ruby-lang.org/issues/16274
[
Feature #16377
]:
https://bugs.ruby-lang.org/issues/16377
[
Bug #12706
]:
https://bugs.ruby-lang.org/issues/12706
[
Feature #15921
]:
https://bugs.ruby-lang.org/issues/15921
[
Feature #16555
]:
https://bugs.ruby-lang.org/issues/16555
[
GH-2991
]:
https://github.com/ruby/ruby/pull/2991
parse.y
浏览文件 @
1b2d351b
...
...
@@ -1083,7 +1083,7 @@ static int looking_at_eol_p(struct parser_params *p);
%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 simple_numeric ssym dsym symbol cpath
%type <node> top_compstmt top_stmts top_stmt begin_block
%type <node> top_compstmt top_stmts top_stmt begin_block
rassign
%type <node> bodystmt compstmt stmts stmt_or_begin stmt expr arg primary command command_call method_call
%type <node> expr_value expr_value_do arg_value primary_value fcall rel_expr
%type <node> if_tail opt_else case_body case_args cases opt_rescue exc_list exc_var opt_ensure
...
...
@@ -1481,9 +1481,44 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem
/*% %*/
/*% ripper: massign!($1, $3) %*/
}
| rassign
| expr
;
rassign : primary tASSOC lhs
{
/*%%%*/
value_expr($1);
$$ = node_assign(p, $3, $1, &@$);
/*% %*/
/*% ripper: assign!($3, $1) %*/
}
| primary tASSOC mlhs
{
/*%%%*/
value_expr($1);
$$ = node_assign(p, $3, $1, &@$);
/*% %*/
/*% ripper: massign!($3, $1) %*/
}
| rassign tASSOC lhs
{
/*%%%*/
value_expr($1);
$$ = node_assign(p, $3, $1, &@$);
/*% %*/
/*% ripper: assign!($3, $1) %*/
}
| rassign tASSOC mlhs
{
/*%%%*/
value_expr($1);
$$ = node_assign(p, $3, $1, &@$);
/*% %*/
/*% ripper: massign!($3, $1) %*/
}
;
command_asgn : lhs '=' command_rhs
{
/*%%%*/
...
...
@@ -8866,10 +8901,11 @@ parser_yylex(struct parser_params *p)
pushback(p, c);
if (space_seen) dispatch_scan_event(p, tSP);
goto retry;
case '=':
case '&':
case '.': {
dispatch_delayed_token(p, tIGNORED_NL);
if (
peek(p, '.') == (c == '&'
)) {
if (
c == '=' ? peek(p, '>') : (peek(p, '.') == (c == '&')
)) {
pushback(p, c);
dispatch_scan_event(p, tSP);
goto retry;
...
...
test/ruby/test_syntax.rb
浏览文件 @
1b2d351b
...
...
@@ -1559,6 +1559,13 @@ def obj3.bar(*args, &block)
end
end
def
test_rightward_assign
assert_equal
(
1
,
eval
(
"1 => a"
))
assert_equal
([
2
,
3
],
eval
(
"13.divmod(5) => a,b; [a, b]"
))
assert_equal
([
2
,
3
,
2
,
3
],
eval
(
"13.divmod(5) => a,b => c, d; [a, b, c, d]"
))
assert_equal
([
2
,
3
],
eval
(
"13.divmod(5)
\n
=> a,b; [a, b]"
))
end
private
def
not_label
(
x
)
@result
=
x
;
@not_label
||=
nil
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录