Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
1676c674
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,发现更多精彩内容 >>
提交
1676c674
编写于
5月 30, 2011
作者:
G
Graydon Hoare
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tighten up comment rules a little more.
上级
cf575536
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
22 addition
and
22 deletion
+22
-22
src/comp/pretty/pp.rs
src/comp/pretty/pp.rs
+1
-1
src/comp/pretty/pprust.rs
src/comp/pretty/pprust.rs
+21
-21
未找到文件。
src/comp/pretty/pp.rs
浏览文件 @
1676c674
...
...
@@ -547,7 +547,7 @@ fn break_offset(printer p, uint n, int off) {
fn
word
(
printer
p
,
str
wrd
)
{
p
.pretty_print
(
STRING
(
wrd
,
str
::
char_len
(
wrd
)
as
int
));
}
fn
word_and_eol
(
printer
p
,
str
wrd
)
{
fn
huge_word
(
printer
p
,
str
wrd
)
{
p
.pretty_print
(
STRING
(
wrd
,
0xffff
));
}
fn
spaces
(
printer
p
,
uint
n
)
{
break_offset
(
p
,
n
,
0
);
}
...
...
src/comp/pretty/pprust.rs
浏览文件 @
1676c674
...
...
@@ -17,7 +17,7 @@
import
pp
::
cbox
;
import
pp
::
ibox
;
import
pp
::
word
;
import
pp
::
word_and_eol
;
import
pp
::
huge_word
;
import
pp
::
space
;
import
pp
::
zerobreak
;
import
pp
::
hardbreak
;
...
...
@@ -152,7 +152,8 @@ fn commasep_cmnt[IN](ps s, breaks b, vec[IN] elts, fn(ps, &IN) op,
i
+=
1u
;
if
(
i
<
len
)
{
word
(
s
.s
,
","
);
if
(
!
maybe_print_line_comment
(
s
,
get_span
(
elt
)))
{
space
(
s
.s
);}
maybe_print_trailing_comment
(
s
,
get_span
(
elt
));
space
(
s
.s
);
}
}
end
(
s
.s
);
...
...
@@ -350,7 +351,7 @@ fn print_variant_arg(ps s, &ast::variant_arg arg) {
pclose
(
s
);
}
word
(
s
.s
,
";"
);
maybe_print_
line
_comment
(
s
,
v
.span
);
maybe_print_
trailing
_comment
(
s
,
v
.span
);
}
bclose
(
s
,
item
.span
);
}
...
...
@@ -409,13 +410,13 @@ fn print_block(ps s, ast::block blk) {
}
}
if
(
front
::
parser
::
stmt_ends_with_semi
(
st
))
{
word
(
s
.s
,
";"
);}
maybe_print_
line
_comment
(
s
,
st
.span
);
maybe_print_
trailing
_comment
(
s
,
st
.span
);
}
alt
(
blk
.node.expr
)
{
case
(
option
::
some
[
@
ast
::
expr
](
?
expr
))
{
space
(
s
.s
);
print_expr
(
s
,
expr
);
maybe_print_
line
_comment
(
s
,
expr
.span
);
maybe_print_
trailing
_comment
(
s
,
expr
.span
);
}
case
(
_
)
{}
}
...
...
@@ -1105,19 +1106,17 @@ fn maybe_print_comment(ps s, uint pos) {
}
}
fn
maybe_print_
line_comment
(
ps
s
,
common
::
span
span
)
->
bool
{
fn
maybe_print_
trailing_comment
(
ps
s
,
common
::
span
span
)
{
auto
cm
;
alt
(
s
.cm
)
{
case
(
option
::
some
[
codemap
](
?
ccm
))
{
cm
=
ccm
;
}
case
(
_
)
{
ret
false
;
}
case
(
_
)
{
ret
;
}
}
alt
(
next_comment
(
s
))
{
case
(
option
::
some
[
lexer
::
cmnt
](
?
cmnt
))
{
if
(
cmnt
.style
!=
lexer
::
trailing
)
{
ret
false
;
}
if
(
cmnt
.style
!=
lexer
::
trailing
)
{
ret
;
}
auto
span_line
=
codemap
::
lookup_pos
(
cm
,
span
.hi
);
auto
comment_line
=
codemap
::
lookup_pos
(
cm
,
cmnt
.pos
);
...
...
@@ -1125,12 +1124,10 @@ fn maybe_print_line_comment(ps s, common::span span) -> bool {
word
(
s
.s
,
" "
);
print_comment
(
s
,
cmnt
);
s
.cur_cmnt
+=
1u
;
ret
true
;
}
}
case
(
_
)
{}
}
ret
false
;
}
fn
print_remaining_comments
(
ps
s
)
{
...
...
@@ -1148,21 +1145,24 @@ fn print_remaining_comments(ps s) {
fn
print_comment
(
ps
s
,
lexer
::
cmnt
cmnt
)
{
alt
(
cmnt
.style
)
{
case
(
lexer
::
isolated
)
{
zero
break
(
s
.s
);
hard
break
(
s
.s
);
for
(
str
line
in
cmnt
.lines
)
{
word_and_eol
(
s
.s
,
line
);
huge_word
(
s
.s
,
line
);
zerobreak
(
s
.s
);
}
zerobreak
(
s
.s
);
}
case
(
lexer
::
trailing
)
{
cbox
(
s
.s
,
0u
);
for
(
str
line
in
cmnt
.lines
)
{
word_and_eol
(
s
.s
,
line
);
zerobreak
(
s
.s
);
if
(
vec
::
len
(
cmnt
.lines
)
==
1u
)
{
word
(
s
.s
,
cmnt
.lines
.
(
0
));
hardbreak
(
s
.s
);
}
else
{
cbox
(
s
.s
,
0u
);
for
(
str
line
in
cmnt
.lines
)
{
huge_word
(
s
.s
,
line
);
zerobreak
(
s
.s
);
}
end
(
s
.s
);
}
end
(
s
.s
);
zerobreak
(
s
.s
);
}
case
(
lexer
::
mixed
)
{
assert
vec
::
len
(
cmnt
.lines
)
==
1u
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录