Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
f4bd03b9
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,发现更多精彩内容 >>
提交
f4bd03b9
编写于
1月 13, 2012
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: Replace the lexer's error handling with diagnostic impl
上级
e90701c5
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
23 addition
and
11 deletion
+23
-11
src/comp/driver/driver.rs
src/comp/driver/driver.rs
+1
-1
src/comp/syntax/parse/lexer.rs
src/comp/syntax/parse/lexer.rs
+14
-6
src/comp/syntax/parse/parser.rs
src/comp/syntax/parse/parser.rs
+4
-2
src/comp/syntax/print/pprust.rs
src/comp/syntax/print/pprust.rs
+4
-2
未找到文件。
src/comp/driver/driver.rs
浏览文件 @
f4bd03b9
...
...
@@ -285,7 +285,7 @@ fn ann_identified_post(node: pprust::ann_node) {
}
ppm_normal
.
{
ann
=
pprust
::
no_ann
();
}
}
pprust
::
print_crate
(
sess
.codemap
,
crate
,
input
,
pprust
::
print_crate
(
sess
.codemap
,
sess
.diagnostic
,
crate
,
input
,
io
::
string_reader
(
src
),
io
::
stdout
(),
ann
);
}
...
...
src/comp/syntax/parse/lexer.rs
浏览文件 @
f4bd03b9
...
...
@@ -10,6 +10,7 @@
type
reader
=
@
{
cm
:
codemap
::
codemap
,
diagnostic
:
diagnostic
::
handler
,
src
:
str
,
len
:
uint
,
mutable
col
:
uint
,
...
...
@@ -48,14 +49,18 @@ fn bump() {
}
else
{
self
.curr
=
-
1
as
char
;
}
}
fn
err
(
m
:
str
)
{
diagnostic
::
emit_error
(
some
((
self
.cm
,
ast_util
::
mk_sp
(
self
.chpos
,
self
.chpos
))),
m
);
self
.diagnostic
.span_err
(
ast_util
::
mk_sp
(
self
.chpos
,
self
.chpos
),
m
);
}
}
fn
new_reader
(
cm
:
codemap
::
codemap
,
src
:
str
,
filemap
:
codemap
::
filemap
,
fn
new_reader
(
cm
:
codemap
::
codemap
,
diagnostic
:
diagnostic
::
handler
,
src
:
str
,
filemap
:
codemap
::
filemap
,
itr
:
@
interner
::
interner
<
str
>
)
->
reader
{
let
r
=
@
{
cm
:
cm
,
src
:
src
,
len
:
str
::
byte_len
(
src
),
let
r
=
@
{
cm
:
cm
,
diagnostic
:
diagnostic
,
src
:
src
,
len
:
str
::
byte_len
(
src
),
mutable
col
:
0u
,
mutable
pos
:
0u
,
mutable
curr
:
-
1
as
char
,
mutable
chpos
:
filemap
.start_pos.ch
,
mutable
strs
:
[],
filemap
:
filemap
,
interner
:
itr
};
...
...
@@ -666,12 +671,15 @@ fn is_lit(t: token::token) -> bool {
type
lit
=
{
lit
:
str
,
pos
:
uint
};
fn
gather_comments_and_literals
(
cm
:
codemap
::
codemap
,
path
:
str
,
fn
gather_comments_and_literals
(
cm
:
codemap
::
codemap
,
diagnostic
:
diagnostic
::
handler
,
path
:
str
,
srdr
:
io
::
reader
)
->
{
cmnts
:
[
cmnt
],
lits
:
[
lit
]}
{
let
src
=
str
::
unsafe_from_bytes
(
srdr
.read_whole_stream
());
let
itr
=
@
interner
::
mk
::
<
str
>
(
str
::
hash
,
str
::
eq
);
let
rdr
=
new_reader
(
cm
,
src
,
codemap
::
new_filemap
(
path
,
0u
,
0u
),
itr
);
let
rdr
=
new_reader
(
cm
,
diagnostic
,
src
,
codemap
::
new_filemap
(
path
,
0u
,
0u
),
itr
);
let
comments
:
[
cmnt
]
=
[];
let
literals
:
[
lit
]
=
[];
let
first_read
:
bool
=
true
;
...
...
src/comp/syntax/parse/parser.rs
浏览文件 @
f4bd03b9
...
...
@@ -102,7 +102,8 @@ fn new_parser_from_file(sess: parse_sess, cfg: ast::crate_cfg, path: str,
let
filemap
=
codemap
::
new_filemap
(
path
,
chpos
,
byte_pos
);
sess
.cm.files
+=
[
filemap
];
let
itr
=
@
interner
::
mk
(
str
::
hash
,
str
::
eq
);
let
rdr
=
lexer
::
new_reader
(
sess
.cm
,
src
,
filemap
,
itr
);
let
rdr
=
lexer
::
new_reader
(
sess
.cm
,
sess
.diagnostic
,
src
,
filemap
,
itr
);
ret
new_parser
(
sess
,
cfg
,
rdr
,
ftype
);
}
...
...
@@ -112,7 +113,8 @@ fn new_parser_from_source_str(sess: parse_sess, cfg: ast::crate_cfg,
let
filemap
=
codemap
::
new_filemap
(
name
,
0u
,
0u
);
sess
.cm.files
+=
[
filemap
];
let
itr
=
@
interner
::
mk
(
str
::
hash
,
str
::
eq
);
let
rdr
=
lexer
::
new_reader
(
sess
.cm
,
source
,
filemap
,
itr
);
let
rdr
=
lexer
::
new_reader
(
sess
.cm
,
sess
.diagnostic
,
source
,
filemap
,
itr
);
ret
new_parser
(
sess
,
cfg
,
rdr
,
ftype
);
}
...
...
src/comp/syntax/print/pprust.rs
浏览文件 @
f4bd03b9
...
...
@@ -9,6 +9,7 @@
import
pp
::{
break_offset
,
word
,
printer
,
space
,
zerobreak
,
hardbreak
,
breaks
,
consistent
,
inconsistent
,
eof
};
import
driver
::
diagnostic
;
// The ps is stored here to prevent recursive type.
// FIXME use a nominal tag instead
...
...
@@ -59,10 +60,11 @@ fn rust_printer(writer: io::writer) -> ps {
// Requires you to pass an input filename and reader so that
// it can scan the input text for comments and literals to
// copy forward.
fn
print_crate
(
cm
:
codemap
,
crate
:
@
ast
::
crate
,
filename
:
str
,
in
:
io
::
reader
,
fn
print_crate
(
cm
:
codemap
,
diagnostic
:
diagnostic
::
handler
,
crate
:
@
ast
::
crate
,
filename
:
str
,
in
:
io
::
reader
,
out
:
io
::
writer
,
ann
:
pp_ann
)
{
let
boxes
:
[
pp
::
breaks
]
=
[];
let
r
=
lexer
::
gather_comments_and_literals
(
cm
,
filename
,
in
);
let
r
=
lexer
::
gather_comments_and_literals
(
cm
,
diagnostic
,
filename
,
in
);
let
s
=
@
{
s
:
pp
::
mk_printer
(
out
,
default_columns
),
cm
:
some
(
cm
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录