Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
8d239a25
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8d239a25
编写于
2月 26, 2013
作者:
E
Erick Tryzelaar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
libsyntax: change closures to take fn(&Parser)
上级
375c2982
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
33 addition
and
33 deletion
+33
-33
src/libsyntax/parse/common.rs
src/libsyntax/parse/common.rs
+9
-9
src/libsyntax/parse/parser.rs
src/libsyntax/parse/parser.rs
+24
-24
未找到文件。
src/libsyntax/parse/common.rs
浏览文件 @
8d239a25
...
...
@@ -250,7 +250,7 @@ fn expect_gt() {
// before the '>'.
fn
parse_seq_to_before_gt
<
T
:
Copy
>
(
sep
:
Option
<
token
::
Token
>
,
f
:
fn
(
Parser
)
->
T
f
:
fn
(
&
Parser
)
->
T
)
->
~
[
T
]
{
let
mut
first
=
true
;
let
mut
v
=
~
[];
...
...
@@ -263,7 +263,7 @@ fn parse_seq_to_before_gt<T: Copy>(
}
_
=>
()
}
v
.push
(
f
(
self
));
v
.push
(
f
(
&
self
));
}
return
v
;
...
...
@@ -271,7 +271,7 @@ fn parse_seq_to_before_gt<T: Copy>(
fn
parse_seq_to_gt
<
T
:
Copy
>
(
sep
:
Option
<
token
::
Token
>
,
f
:
fn
(
Parser
)
->
T
f
:
fn
(
&
Parser
)
->
T
)
->
~
[
T
]
{
let
v
=
self
.parse_seq_to_before_gt
(
sep
,
f
);
self
.expect_gt
();
...
...
@@ -282,7 +282,7 @@ fn parse_seq_to_gt<T: Copy>(
// parse a sequence bracketed by '<' and '>'
fn
parse_seq_lt_gt
<
T
:
Copy
>
(
sep
:
Option
<
token
::
Token
>
,
f
:
fn
(
Parser
)
->
T
f
:
fn
(
&
Parser
)
->
T
)
->
spanned
<~
[
T
]
>
{
let
lo
=
self
.span.lo
;
self
.expect
(
&
token
::
LT
);
...
...
@@ -298,7 +298,7 @@ fn parse_seq_lt_gt<T: Copy>(
fn
parse_seq_to_end
<
T
:
Copy
>
(
ket
:
&
token
::
Token
,
sep
:
SeqSep
,
f
:
fn
(
Parser
)
->
T
f
:
fn
(
&
Parser
)
->
T
)
->
~
[
T
]
{
let
val
=
self
.parse_seq_to_before_end
(
ket
,
sep
,
f
);
self
.bump
();
...
...
@@ -311,7 +311,7 @@ fn parse_seq_to_end<T: Copy>(
fn
parse_seq_to_before_end
<
T
:
Copy
>
(
ket
:
&
token
::
Token
,
sep
:
SeqSep
,
f
:
fn
(
Parser
)
->
T
f
:
fn
(
&
Parser
)
->
T
)
->
~
[
T
]
{
let
mut
first
:
bool
=
true
;
let
mut
v
:
~
[
T
]
=
~
[];
...
...
@@ -324,7 +324,7 @@ fn parse_seq_to_before_end<T: Copy>(
_
=>
()
}
if
sep
.trailing_sep_allowed
&&
*
self
.token
==
*
ket
{
break
;
}
v
.push
(
f
(
self
));
v
.push
(
f
(
&
self
));
}
return
v
;
}
...
...
@@ -336,7 +336,7 @@ fn parse_unspanned_seq<T: Copy>(
bra
:
&
token
::
Token
,
ket
:
&
token
::
Token
,
sep
:
SeqSep
,
f
:
fn
(
Parser
)
->
T
f
:
fn
(
&
Parser
)
->
T
)
->
~
[
T
]
{
self
.expect
(
bra
);
let
result
=
self
.parse_seq_to_before_end
(
ket
,
sep
,
f
);
...
...
@@ -350,7 +350,7 @@ fn parse_seq<T: Copy>(
bra
:
&
token
::
Token
,
ket
:
&
token
::
Token
,
sep
:
SeqSep
,
f
:
fn
(
Parser
)
->
T
f
:
fn
(
&
Parser
)
->
T
)
->
spanned
<~
[
T
]
>
{
let
lo
=
self
.span.lo
;
self
.expect
(
bra
);
...
...
src/libsyntax/parse/parser.rs
浏览文件 @
8d239a25
...
...
@@ -768,7 +768,7 @@ fn is_named_argument() -> bool {
}
}
fn
parse_capture_item_or
(
parse_arg_fn
:
fn
(
Parser
)
->
arg_or_capture_item
)
fn
parse_capture_item_or
(
parse_arg_fn
:
fn
(
&
Parser
)
->
arg_or_capture_item
)
->
arg_or_capture_item
{
if
self
.eat_keyword
(
&~
"copy"
)
{
...
...
@@ -776,7 +776,7 @@ fn parse_capture_item_or(parse_arg_fn: fn(Parser) -> arg_or_capture_item)
self
.parse_ident
();
either
::
Right
(())
}
else
{
parse_arg_fn
(
self
)
parse_arg_fn
(
&
self
)
}
}
...
...
@@ -893,8 +893,8 @@ fn parse_path_without_tps() -> @path {
}
fn
parse_path_without_tps_
(
parse_ident
:
fn
(
Parser
)
->
ident
,
parse_last_ident
:
fn
(
Parser
)
->
ident
)
->
@
path
{
parse_ident
:
fn
(
&
Parser
)
->
ident
,
parse_last_ident
:
fn
(
&
Parser
)
->
ident
)
->
@
path
{
maybe_whole!
(
self
,
nt_path
);
let
lo
=
self
.span.lo
;
...
...
@@ -906,10 +906,10 @@ fn parse_path_without_tps_(
&&
self
.look_ahead
(
1u
)
==
token
::
MOD_SEP
;
if
is_not_last
{
ids
.push
(
parse_ident
(
self
));
ids
.push
(
parse_ident
(
&
self
));
self
.expect
(
&
token
::
MOD_SEP
);
}
else
{
ids
.push
(
parse_last_ident
(
self
));
ids
.push
(
parse_last_ident
(
&
self
));
break
;
}
}
...
...
@@ -1415,7 +1415,7 @@ fn parse_sep_and_zerok() -> (Option<token::Token>, bool) {
fn
parse_token_tree
()
->
token_tree
{
maybe_whole!
(
deref
self
,
nt_tt
);
fn
parse_non_delim_tt_tok
(
p
:
Parser
)
->
token_tree
{
fn
parse_non_delim_tt_tok
(
p
:
&
Parser
)
->
token_tree
{
maybe_whole!
(
deref
p
,
nt_tt
);
match
*
p
.token
{
token
::
RPAREN
|
token
::
RBRACE
|
token
::
RBRACKET
...
...
@@ -1452,7 +1452,7 @@ fn parse_non_delim_tt_tok(p: Parser) -> token_tree {
}
// turn the next token into a tt_tok:
fn
parse_any_tt_tok
(
p
:
Parser
)
->
token_tree
{
fn
parse_any_tt_tok
(
p
:
&
Parser
)
->
token_tree
{
let
res
=
tt_tok
(
*
p
.span
,
*
p
.token
);
p
.bump
();
res
...
...
@@ -1468,7 +1468,7 @@ fn parse_any_tt_tok(p: Parser) -> token_tree{
tt_delim
(
vec
::
append
(
// the open delimiter:
~
[
parse_any_tt_tok
(
self
)],
~
[
parse_any_tt_tok
(
&
self
)],
vec
::
append
(
self
.parse_seq_to_before_end
(
&
ket
,
...
...
@@ -1476,12 +1476,12 @@ fn parse_any_tt_tok(p: Parser) -> token_tree{
|
p
|
p
.parse_token_tree
()
),
// the close delimiter:
~
[
parse_any_tt_tok
(
self
)]
~
[
parse_any_tt_tok
(
&
self
)]
)
)
)
}
_
=>
parse_non_delim_tt_tok
(
self
)
_
=>
parse_non_delim_tt_tok
(
&
self
)
}
}
...
...
@@ -2441,7 +2441,7 @@ fn parse_instance_var(pr: visibility) -> @struct_field {
fn
parse_stmt
(
+
first_item_attrs
:
~
[
attribute
])
->
@
stmt
{
maybe_whole!
(
self
,
nt_stmt
);
fn
check_expected_item
(
p
:
Parser
,
current_attrs
:
~
[
attribute
])
{
fn
check_expected_item
(
p
:
&
Parser
,
current_attrs
:
~
[
attribute
])
{
// If we have attributes then we should have an item
if
!
current_attrs
.is_empty
()
{
p
.fatal
(
~
"expected item after attrs"
);
...
...
@@ -2450,7 +2450,7 @@ fn check_expected_item(p: Parser, current_attrs: ~[attribute]) {
let
lo
=
self
.span.lo
;
if
self
.is_keyword
(
&~
"let"
)
{
check_expected_item
(
self
,
first_item_attrs
);
check_expected_item
(
&
self
,
first_item_attrs
);
self
.expect_keyword
(
&~
"let"
);
let
decl
=
self
.parse_let
();
return
@
spanned
(
lo
,
decl
.span.hi
,
stmt_decl
(
decl
,
self
.get_id
()));
...
...
@@ -2458,7 +2458,7 @@ fn check_expected_item(p: Parser, current_attrs: ~[attribute]) {
&&
!
self
.is_any_keyword
(
&
copy
*
self
.token
)
&&
self
.look_ahead
(
1
)
==
token
::
NOT
{
check_expected_item
(
self
,
first_item_attrs
);
check_expected_item
(
&
self
,
first_item_attrs
);
// Potential trouble: if we allow macros with paths instead of
// idents, we'd need to look ahead past the whole path here...
...
...
@@ -2514,7 +2514,7 @@ fn check_expected_item(p: Parser, current_attrs: ~[attribute]) {
iovi_none
()
=>
{
/* fallthrough */
}
}
check_expected_item
(
self
,
item_attrs
);
check_expected_item
(
&
self
,
item_attrs
);
// Remainder are line-expr stmts.
let
e
=
self
.parse_expr_res
(
RESTRICT_STMT_EXPR
);
...
...
@@ -2538,7 +2538,7 @@ fn parse_inner_attrs_and_block(parse_attrs: bool)
maybe_whole!
(
pair_empty
self
,
nt_block
);
fn
maybe_parse_inner_attrs_and_next
(
p
:
Parser
,
parse_attrs
:
bool
)
->
fn
maybe_parse_inner_attrs_and_next
(
p
:
&
Parser
,
parse_attrs
:
bool
)
->
(
~
[
attribute
],
~
[
attribute
])
{
if
parse_attrs
{
p
.parse_inner_attrs_and_next
()
...
...
@@ -2553,7 +2553,7 @@ fn maybe_parse_inner_attrs_and_next(p: Parser, parse_attrs: bool) ->
}
self
.expect
(
&
token
::
LBRACE
);
let
(
inner
,
next
)
=
maybe_parse_inner_attrs_and_next
(
self
,
parse_attrs
);
maybe_parse_inner_attrs_and_next
(
&
self
,
parse_attrs
);
(
inner
,
self
.parse_block_tail_
(
lo
,
default_blk
,
next
))
}
...
...
@@ -2780,7 +2780,7 @@ fn parse_ty_params() -> ~[ty_param] {
}
else
{
~
[]
}
}
fn
parse_fn_decl
(
parse_arg_fn
:
fn
(
Parser
)
->
arg_or_capture_item
)
fn
parse_fn_decl
(
parse_arg_fn
:
fn
(
&
Parser
)
->
arg_or_capture_item
)
->
fn_decl
{
let
args_or_capture_items
:
~
[
arg_or_capture_item
]
=
...
...
@@ -2823,11 +2823,11 @@ fn expect_self_ident() {
fn
parse_fn_decl_with_self
(
parse_arg_fn
:
fn
(
Parser
)
->
arg_or_capture_item
fn
(
&
Parser
)
->
arg_or_capture_item
)
->
(
self_ty
,
fn_decl
)
{
fn
maybe_parse_self_ty
(
cnstr
:
fn
(
+
v
:
mutability
)
->
ast
::
self_ty_
,
p
:
Parser
p
:
&
Parser
)
->
ast
::
self_ty_
{
// We need to make sure it isn't a mode or a type
if
p
.token_is_keyword
(
&~
"self"
,
&
p
.look_ahead
(
1
))
||
...
...
@@ -2851,13 +2851,13 @@ fn maybe_parse_self_ty(
let
lo
=
self
.span.lo
;
let
self_ty
=
match
*
self
.token
{
token
::
BINOP
(
token
::
AND
)
=>
{
maybe_parse_self_ty
(
sty_region
,
self
)
maybe_parse_self_ty
(
sty_region
,
&
self
)
}
token
::
AT
=>
{
maybe_parse_self_ty
(
sty_box
,
self
)
maybe_parse_self_ty
(
sty_box
,
&
self
)
}
token
::
TILDE
=>
{
maybe_parse_self_ty
(
sty_uniq
,
self
)
maybe_parse_self_ty
(
sty_uniq
,
&
self
)
}
token
::
IDENT
(
*
)
if
self
.is_self_ident
()
=>
{
self
.bump
();
...
...
@@ -3028,7 +3028,7 @@ fn parse_item_trait() -> item_info {
// impl<T> ~[T] : to_str { ... }
// impl<T> to_str for ~[T] { ... }
fn
parse_item_impl
()
->
item_info
{
fn
wrap_path
(
p
:
Parser
,
pt
:
@
path
)
->
@
Ty
{
fn
wrap_path
(
p
:
&
Parser
,
pt
:
@
path
)
->
@
Ty
{
@
Ty
{
id
:
p
.get_id
(),
node
:
ty_path
(
pt
,
p
.get_id
()),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录