Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
675073c2
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,发现更多精彩内容 >>
提交
675073c2
编写于
8月 27, 2011
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Convert parser to istrs. Issue #855
上级
427d4222
变更
8
展开全部
显示空白变更内容
内联
并排
Showing
8 changed file
with
231 addition
and
217 deletion
+231
-217
src/comp/driver/rustc.rs
src/comp/driver/rustc.rs
+6
-3
src/comp/middle/trans.rs
src/comp/middle/trans.rs
+1
-1
src/comp/syntax/codemap.rs
src/comp/syntax/codemap.rs
+13
-7
src/comp/syntax/ext/base.rs
src/comp/syntax/ext/base.rs
+2
-1
src/comp/syntax/parse/eval.rs
src/comp/syntax/parse/eval.rs
+3
-3
src/comp/syntax/parse/lexer.rs
src/comp/syntax/parse/lexer.rs
+1
-1
src/comp/syntax/parse/parser.rs
src/comp/syntax/parse/parser.rs
+200
-199
src/fuzzer/fuzzer.rs
src/fuzzer/fuzzer.rs
+5
-2
未找到文件。
src/comp/driver/rustc.rs
浏览文件 @
675073c2
...
...
@@ -95,7 +95,8 @@ fn input_is_stdin(filename: str) -> bool { filename == "-" }
fn
parse_input
(
sess
:
session
::
session
,
cfg
:
&
ast
::
crate_cfg
,
input
:
str
)
->
@
ast
::
crate
{
if
!
input_is_stdin
(
input
)
{
parser
::
parse_crate_from_file
(
input
,
cfg
,
sess
.get_parse_sess
())
parser
::
parse_crate_from_file
(
istr
::
from_estr
(
input
),
cfg
,
sess
.get_parse_sess
())
}
else
{
parse_input_src
(
sess
,
cfg
,
input
)
.crate
}
}
...
...
@@ -107,7 +108,9 @@ fn parse_input_src(sess: session::session, cfg: &ast::crate_cfg, infile: str)
}
else
{
io
::
stdin
()
}
.read_whole_stream
();
let
src
=
str
::
unsafe_from_bytes
(
srcbytes
);
let
crate
=
parser
::
parse_crate_from_source_str
(
infile
,
src
,
cfg
,
parser
::
parse_crate_from_source_str
(
istr
::
from_estr
(
infile
),
istr
::
from_estr
(
src
),
cfg
,
sess
.get_parse_sess
());
ret
{
crate
:
crate
,
src
:
src
};
}
...
...
src/comp/middle/trans.rs
浏览文件 @
675073c2
...
...
@@ -4649,7 +4649,7 @@ fn trans_fail_value(cx: &@block_ctxt, sp_opt: &option::t<span>,
alt
sp_opt
{
some
(
sp
)
{
let
loc
=
bcx_ccx
(
cx
)
.sess
.lookup_pos
(
sp
.lo
);
V_filename
=
C_cstr
(
bcx_ccx
(
cx
),
istr
::
from_estr
(
loc
.filename
)
);
V_filename
=
C_cstr
(
bcx_ccx
(
cx
),
loc
.filename
);
V_line
=
loc
.line
as
int
;
}
none
.
{
V_filename
=
C_cstr
(
bcx_ccx
(
cx
),
~
"<runtime>"
);
V_line
=
0
;
}
...
...
src/comp/syntax/codemap.rs
浏览文件 @
675073c2
...
...
@@ -8,7 +8,7 @@
import
std
::
option
::
some
;
import
std
::
option
::
none
;
type
filename
=
str
;
type
filename
=
i
str
;
type
file_pos
=
{
ch
:
uint
,
byte
:
uint
};
...
...
@@ -84,7 +84,9 @@ fn span_to_str(sp: &span, cm: &codemap) -> str {
#
fmt
[
"%s:%u:%u: %u:%u"
,
if
some
(
lo
.filename
)
==
prev_file
{
"-"
}
else
{
lo
.filename
},
lo
.line
,
lo
.col
,
hi
.line
,
hi
.col
];
}
else
{
istr
::
to_estr
(
lo
.filename
)
},
lo
.line
,
lo
.col
,
hi
.line
,
hi
.col
];
alt
cur
.expanded_from
{
os_none
.
{
break
;
}
os_some
(
new_sp
)
{
...
...
@@ -146,14 +148,16 @@ fn maybe_highlight_lines(sp: &option::t<span>, cm: &codemap,
// Print the offending lines
for
line
:
uint
in
display_lines
{
io
::
stdout
()
.write_str
(
istr
::
from_estr
(
#
fmt
[
"%s:%u "
,
fm
.name
,
line
+
1u
]));
istr
::
from_estr
(
#
fmt
[
"%s:%u "
,
istr
::
to_estr
(
fm
.name
),
line
+
1u
]));
let
s
=
get_line
(
fm
,
line
as
int
,
file
);
if
!
str
::
ends_with
(
s
,
"
\n
"
)
{
s
+=
"
\n
"
;
}
io
::
stdout
()
.write_str
(
istr
::
from_estr
(
s
));
}
if
elided
{
let
last_line
=
display_lines
[
vec
::
len
(
display_lines
)
-
1u
];
let
s
=
#
fmt
[
"%s:%u "
,
fm
.name
,
last_line
+
1u
];
let
s
=
#
fmt
[
"%s:%u "
,
istr
::
to_estr
(
fm
.name
),
last_line
+
1u
];
let
indent
=
str
::
char_len
(
s
);
let
out
=
~
""
;
while
indent
>
0u
{
out
+=
~
" "
;
indent
-=
1u
;
}
...
...
@@ -172,7 +176,7 @@ fn maybe_highlight_lines(sp: &option::t<span>, cm: &codemap,
while
num
>
0u
{
num
/=
10u
;
digits
+=
1u
;
}
// indent past |name:## | and the 0-offset column location
let
left
=
str
::
char_len
(
fm
.name
)
+
digits
+
lo
.col
+
3u
;
let
left
=
i
str
::
char_len
(
fm
.name
)
+
digits
+
lo
.col
+
3u
;
let
s
=
""
;
while
left
>
0u
{
str
::
push_char
(
s
,
' '
);
left
-=
1u
;
}
...
...
@@ -209,7 +213,7 @@ fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines {
for
each
i
:
uint
in
uint
::
range
(
lo
.line
-
1u
,
hi
.line
as
uint
)
{
lines
+=
[
i
];
}
ret
@
{
name
:
lo
.filename
,
lines
:
lines
};
ret
@
{
name
:
istr
::
to_estr
(
lo
.filename
)
,
lines
:
lines
};
}
fn
get_line
(
fm
:
filemap
,
line
:
int
,
file
:
&
str
)
->
str
{
...
...
@@ -230,7 +234,9 @@ fn get_line(fm: filemap, line: int, file: &str) -> str {
}
fn
get_filemap
(
cm
:
codemap
,
filename
:
str
)
->
filemap
{
for
fm
:
filemap
in
cm
.files
{
if
fm
.name
==
filename
{
ret
fm
;
}
}
for
fm
:
filemap
in
cm
.files
{
if
fm
.name
==
istr
::
from_estr
(
filename
)
{
ret
fm
;
}
}
//XXjdm the following triggers a mismatched type bug
// (or expected function, found _|_)
fail
;
// ("asking for " + filename + " which we don't know about");
...
...
src/comp/syntax/ext/base.rs
浏览文件 @
675073c2
...
...
@@ -93,7 +93,8 @@ fn mk_ctxt(sess: &session) -> ext_ctxt {
// super-ugly and needs a better solution.
let
crate_file_name_hack
=
sess
.get_codemap
()
.files
[
0
]
.name
;
ret
ext_ctxt
(
@
sess
,
crate_file_name_hack
,
codemap
::
os_none
);
ret
ext_ctxt
(
@
sess
,
istr
::
to_estr
(
crate_file_name_hack
),
codemap
::
os_none
);
}
fn
expr_to_str
(
cx
:
&
ext_ctxt
,
expr
:
@
ast
::
expr
,
error
:
str
)
->
str
{
...
...
src/comp/syntax/parse/eval.rs
浏览文件 @
675073c2
...
...
@@ -51,7 +51,7 @@ fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: &istr,
let
file_path
=
id
+
~
".rs"
;
alt
file_opt
{
some
(
f
)
{
file_path
=
istr
::
from_estr
(
f
)
;
file_path
=
f
;
}
none
.
{
}
}
...
...
@@ -63,7 +63,7 @@ fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: &istr,
if
cx
.mode
==
mode_depend
{
cx
.deps
+=
[
full_path
];
ret
;
}
let
p0
=
new_parser_from_file
(
cx
.sess
,
cx
.cfg
,
istr
::
to_estr
(
full_path
)
,
cx
.chpos
,
full_path
,
cx
.chpos
,
cx
.byte_pos
,
SOURCE_FILE
);
let
inner_attrs
=
parse_inner_attrs_and_next
(
p0
);
let
mod_attrs
=
attrs
+
inner_attrs
.inner
;
...
...
@@ -82,7 +82,7 @@ fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: &istr,
let
path
=
id
;
alt
dir_opt
{
some
(
d
)
{
path
=
istr
::
from_estr
(
d
)
;
path
=
d
;
}
none
.
{
}
}
...
...
src/comp/syntax/parse/lexer.rs
浏览文件 @
675073c2
...
...
@@ -728,7 +728,7 @@ fn gather_comments_and_literals(cm: &codemap::codemap, path: &istr,
let
itr
=
@
interner
::
mk
::
<
istr
>
(
istr
::
hash
,
istr
::
eq
);
let
rdr
=
new_reader
(
cm
,
src
,
codemap
::
new_filemap
(
istr
::
to_estr
(
path
)
,
0u
,
0u
),
itr
);
path
,
0u
,
0u
),
itr
);
let
comments
:
[
cmnt
]
=
[];
let
literals
:
[
lit
]
=
[];
let
first_read
:
bool
=
true
;
...
...
src/comp/syntax/parse/parser.rs
浏览文件 @
675073c2
此差异已折叠。
点击以展开。
src/fuzzer/fuzzer.rs
浏览文件 @
675073c2
...
...
@@ -252,7 +252,8 @@ fn parse_and_print(code: &str) -> str {
let
filename
=
"tmp.rs"
;
let
sess
=
@
{
cm
:
codemap
::
new_codemap
(),
mutable
next_id
:
0
};
//write_file(filename, code);
let
crate
=
parser
::
parse_crate_from_source_str
(
filename
,
code
,
[],
sess
);
let
crate
=
parser
::
parse_crate_from_source_str
(
istr
::
from_estr
(
filename
),
istr
::
from_estr
(
code
),
[],
sess
);
ret
as_str
(
bind
pprust
::
print_crate
(
sess
.cm
,
crate
,
filename
,
io
::
string_reader
(
istr
::
from_estr
(
code
)),
_
,
pprust
::
no_ann
()));
...
...
@@ -360,7 +361,9 @@ fn check_variants(files: &[str]) {
log_err
"check_variants: "
+
file
;
let
sess
=
@
{
cm
:
codemap
::
new_codemap
(),
mutable
next_id
:
0
};
let
crate
=
parser
::
parse_crate_from_source_str
(
file
,
s
,
[],
sess
);
parser
::
parse_crate_from_source_str
(
istr
::
from_estr
(
file
),
istr
::
from_estr
(
s
),
[],
sess
);
log_err
as_str
(
bind
pprust
::
print_crate
(
sess
.cm
,
crate
,
file
,
io
::
string_reader
(
istr
::
from_estr
(
s
)),
_
,
pprust
::
no_ann
()));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录