Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
014c6922
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,发现更多精彩内容 >>
提交
014c6922
编写于
8月 16, 2011
作者:
E
Erick Tryzelaar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change expr foo[T] syntax to foo::<T>.
This preserves the old syntax for now.
上级
9304b7ee
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
38 addition
and
8 deletion
+38
-8
src/comp/syntax/parse/parser.rs
src/comp/syntax/parse/parser.rs
+29
-2
src/comp/syntax/print/pprust.rs
src/comp/syntax/print/pprust.rs
+9
-6
未找到文件。
src/comp/syntax/parse/parser.rs
浏览文件 @
014c6922
...
...
@@ -643,8 +643,8 @@ fn parse_fn_block_arg(p: &parser) -> ast::arg {
ret
{
mode
:
m
,
ty
:
t
,
ident
:
i
,
id
:
p
.get_id
()};
}
fn
parse_seq_to_
gt
[
T
](
sep
:
option
::
t
[
token
::
token
],
f
:
fn
(
&
parser
)
->
T
,
p
:
&
parser
)
->
[
T
]
{
fn
parse_seq_to_
before_gt
[
T
](
sep
:
option
::
t
[
token
::
token
]
,
f
:
fn
(
&
parser
)
->
T
,
p
:
&
parser
)
->
[
T
]
{
let
first
=
true
;
let
v
=
~
[];
while
p
.peek
()
!=
token
::
GT
&&
...
...
@@ -657,11 +657,27 @@ fn parse_seq_to_gt[T](sep: option::t[token::token], f: fn(&parser) -> T,
v
+=
~
[
f
(
p
)];
}
ret
v
;
}
fn
parse_seq_to_gt
[
T
](
sep
:
option
::
t
[
token
::
token
],
f
:
fn
(
&
parser
)
->
T
,
p
:
&
parser
)
->
[
T
]
{
let
v
=
parse_seq_to_before_gt
(
sep
,
f
,
p
);
expect_gt
(
p
);
ret
v
;
}
fn
parse_seq_lt_gt
[
T
](
sep
:
option
::
t
[
token
::
token
],
f
:
fn
(
&
parser
)
->
T
,
p
:
&
parser
)
->
spanned
[[
T
]]
{
let
lo
=
p
.get_lo_pos
();
expect
(
p
,
token
::
LT
);
let
result
=
parse_seq_to_before_gt
[
T
](
sep
,
f
,
p
);
let
hi
=
p
.get_hi_pos
();
expect_gt
(
p
);
ret
spanned
(
lo
,
hi
,
result
);
}
fn
parse_seq_to_end
[
T
](
ket
:
token
::
token
,
sep
:
option
::
t
[
token
::
token
],
f
:
fn
(
&
parser
)
->
T
,
p
:
&
parser
)
->
[
T
]
{
let
val
=
parse_seq_to_before_end
(
ket
,
sep
,
f
,
p
);
...
...
@@ -787,6 +803,17 @@ fn parse_path_and_ty_param_substs(p: &parser) -> ast::path {
{
global
:
path
.node.global
,
idents
:
path
.node.idents
,
types
:
seq
.node
});
}
else
if
p
.peek
()
==
token
::
MOD_SEP
{
p
.bump
();
let
seq
=
parse_seq_lt_gt
(
some
(
token
::
COMMA
),
bind
parse_ty
(
_
,
false
),
p
);
let
hi
=
seq
.span.hi
;
path
=
spanned
(
lo
,
hi
,
{
global
:
path
.node.global
,
idents
:
path
.node.idents
,
types
:
seq
.node
});
}
ret
path
;
}
...
...
src/comp/syntax/print/pprust.rs
浏览文件 @
014c6922
...
...
@@ -100,7 +100,9 @@ fn print_crate(cm: &codemap, crate: @ast::crate, filename: str,
fn
item_to_str
(
i
:
&@
ast
::
item
)
->
str
{
be
to_str
(
i
,
print_item
);
}
fn
path_to_str
(
p
:
&
ast
::
path
)
->
str
{
be
to_str
(
p
,
print_path
);
}
fn
path_to_str
(
p
:
&
ast
::
path
)
->
str
{
be
to_str
(
p
,
bind
print_path
(
_
,
_
,
false
));
}
fn
fun_to_str
(
f
:
&
ast
::
_
fn
,
name
:
str
,
params
:
&
[
ast
::
ty_param
])
->
str
{
let
writer
=
io
::
string_writer
();
...
...
@@ -341,7 +343,7 @@ fn print_field(s: &ps, f: &ast::ty_field) {
}
bclose
(
s
,
ty
.span
);
}
ast
::
ty_path
(
path
,
_
)
{
print_path
(
s
,
path
);
}
ast
::
ty_path
(
path
,
_
)
{
print_path
(
s
,
path
,
false
);
}
ast
::
ty_type
.
{
word
(
s
.s
,
"type"
);
}
ast
::
ty_constr
(
t
,
cs
)
{
print_type
(
s
,
t
);
...
...
@@ -690,7 +692,7 @@ fn print_mac(s: &ps, m: &ast::mac) {
alt
m
.node
{
ast
::
mac_invoc
(
path
,
arg
,
body
)
{
word
(
s
.s
,
"#"
);
print_path
(
s
,
path
);
print_path
(
s
,
path
,
false
);
alt
(
arg
.node
)
{
ast
::
expr_vec
(
_
,
_
,
_
)
{}
_
{
word
(
s
.s
,
" "
);
}
...
...
@@ -933,7 +935,7 @@ fn print_opt(s: &ps, expr: &option::t[@ast::expr]) {
print_expr
(
s
,
index
);
pclose
(
s
);
}
ast
::
expr_path
(
path
)
{
print_path
(
s
,
path
);
}
ast
::
expr_path
(
path
)
{
print_path
(
s
,
path
,
true
);
}
ast
::
expr_fail
(
maybe_fail_val
)
{
word
(
s
.s
,
"fail"
);
alt
maybe_fail_val
{
...
...
@@ -1088,7 +1090,7 @@ fn print_for_decl(s: &ps, loc: &@ast::local, coll: &@ast::expr) {
print_expr
(
s
,
coll
);
}
fn
print_path
(
s
:
&
ps
,
path
:
&
ast
::
path
)
{
fn
print_path
(
s
:
&
ps
,
path
:
&
ast
::
path
,
colons_before_params
:
bool
)
{
maybe_print_comment
(
s
,
path
.span.lo
);
if
path
.node.global
{
word
(
s
.s
,
"::"
);
}
let
first
=
true
;
...
...
@@ -1097,6 +1099,7 @@ fn print_path(s: &ps, path: &ast::path) {
word
(
s
.s
,
id
);
}
if
vec
::
len
(
path
.node.types
)
>
0u
{
if
colons_before_params
{
word
(
s
.s
,
"::"
);
}
word
(
s
.s
,
"<"
);
commasep
(
s
,
inconsistent
,
path
.node.types
,
print_type
);
word
(
s
.s
,
">"
);
...
...
@@ -1112,7 +1115,7 @@ fn print_pat(s: &ps, pat: &@ast::pat) {
ast
::
pat_bind
(
id
)
{
word
(
s
.s
,
id
);
}
ast
::
pat_lit
(
lit
)
{
print_literal
(
s
,
lit
);
}
ast
::
pat_tag
(
path
,
args
)
{
print_path
(
s
,
path
);
print_path
(
s
,
path
,
true
);
if
vec
::
len
(
args
)
>
0u
{
popen
(
s
);
commasep
(
s
,
inconsistent
,
args
,
print_pat
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录