Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
80cf4ecd
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,发现更多精彩内容 >>
提交
80cf4ecd
编写于
6月 29, 2011
作者:
P
Paul Stansifer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add nodes for embedding types and blocks in expressions for macros.
上级
fd24fd5e
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
58 addition
and
45 deletion
+58
-45
src/comp/syntax/ast.rs
src/comp/syntax/ast.rs
+0
-1
src/comp/syntax/fold.rs
src/comp/syntax/fold.rs
+6
-16
src/comp/syntax/parse/lexer.rs
src/comp/syntax/parse/lexer.rs
+16
-10
src/comp/syntax/parse/parser.rs
src/comp/syntax/parse/parser.rs
+16
-2
src/comp/syntax/parse/token.rs
src/comp/syntax/parse/token.rs
+8
-16
src/comp/syntax/visit.rs
src/comp/syntax/visit.rs
+6
-0
src/comp/syntax/walk.rs
src/comp/syntax/walk.rs
+6
-0
未找到文件。
src/comp/syntax/ast.rs
浏览文件 @
80cf4ecd
...
...
@@ -323,7 +323,6 @@ fn unop_to_str(unop op) -> str {
to expr_if_check. */
expr_if_check
(
@
expr
,
block
,
option
::
t
[
@
expr
]);
expr_port
(
option
::
t
[
@
ty
]);
expr_chan
(
@
expr
);
expr_anon_obj
(
anon_obj
,
ty_param
[]);
}
...
...
src/comp/syntax/fold.rs
浏览文件 @
80cf4ecd
...
...
@@ -445,6 +445,12 @@ fn fold_anon_obj_field_(&anon_obj_field aof, ast_fold fld)
case
(
expr_anon_obj
(
?
ao
,
?
typms
))
{
expr_anon_obj
(
fold_anon_obj
(
ao
),
typms
)
}
case
(
expr_embeded_type
(
?
ty
))
{
expr_embeded_type
(
fld
.fold_ty
(
ty
))
}
case
(
expr_embeded_block
(
?
blk
))
{
expr_embeded_block
(
fld
.fold_block
(
blk
))
}
}
}
...
...
@@ -695,22 +701,6 @@ fn f_local(&ast_fold_precursor afp, ast_fold f, &@local x) -> @local {
fold_path
=
bind
f_path
(
afp
,
result
,
_
),
fold_local
=
bind
f_local
(
afp
,
result
,
_
));
ret
result
;
/*
ret rec(fold_crate = noop_fold_crate,
fold_crate_directive = noop_fold_crate_drective,
fold_view_item = noop_fold_view_item,
fold_native_item = noop_fold_native_item,
fold_item = noop_fold_item,
fold_method = noop_fold_method,
fold_block = noop_fold_block,
fold_stmt = noop_fold_stmt,
fold_arm = noop_fold_arm,
fold_pat = noop_fold_pat,
fold_decl = noop_fold_decl,
fold_expr = noop_fold_expr,
fold_ty = noop_fold_ty,
fold_constr = noop_fold_constr,
fold_fn = noop_fold_fn);*/
}
...
...
src/comp/syntax/parse/lexer.rs
浏览文件 @
80cf4ecd
...
...
@@ -361,12 +361,8 @@ fn binop(&reader rdr, token::binop op) -> token::token {
}
else
{
ret
token
::
BINOP
(
op
);
}
}
alt
(
c
)
{
case
(
// One-byte tokens.
'?'
)
{
rdr
.bump
();
ret
token
::
QUES
;
}
// One-byte tokens.
case
(
'?'
)
{
rdr
.bump
();
ret
token
::
QUES
;
}
case
(
';'
)
{
rdr
.bump
();
ret
token
::
SEMI
;
}
case
(
','
)
{
rdr
.bump
();
ret
token
::
COMMA
;
}
case
(
'.'
)
{
rdr
.bump
();
ret
token
::
DOT
;
}
...
...
@@ -377,7 +373,18 @@ fn binop(&reader rdr, token::binop op) -> token::token {
case
(
'['
)
{
rdr
.bump
();
ret
token
::
LBRACKET
;
}
case
(
']'
)
{
rdr
.bump
();
ret
token
::
RBRACKET
;
}
case
(
'@'
)
{
rdr
.bump
();
ret
token
::
AT
;
}
case
(
'#'
)
{
rdr
.bump
();
ret
token
::
POUND
;
}
case
(
'#'
)
{
rdr
.bump
();
if
(
rdr
.curr
()
==
'<'
)
{
rdr
.bump
();
ret
token
::
POUND_LT
;
}
if
(
rdr
.curr
()
==
'{'
)
{
rdr
.bump
();
ret
token
::
POUND_LBRACE
;
}
ret
token
::
POUND
;
}
case
(
'~'
)
{
rdr
.bump
();
ret
token
::
TILDE
;
}
case
(
':'
)
{
rdr
.bump
();
...
...
@@ -386,9 +393,8 @@ fn binop(&reader rdr, token::binop op) -> token::token {
ret
token
::
MOD_SEP
;
}
else
{
ret
token
::
COLON
;
}
}
case
(
// Multi-byte tokens.
'='
)
{
// Multi-byte tokens.
case
(
'='
)
{
rdr
.bump
();
if
(
rdr
.curr
()
==
'='
)
{
rdr
.bump
();
...
...
src/comp/syntax/parse/parser.rs
浏览文件 @
80cf4ecd
...
...
@@ -804,6 +804,13 @@ fn parse_elt(&parser p) -> ast::elt {
parse_seq_to_end_ivec
(
token
::
RBRACKET
,
some
(
token
::
COMMA
),
parse_expr
,
p
);
ex
=
ast
::
expr_vec
(
es
,
mut
,
ast
::
sk_rc
);
}
else
if
(
p
.peek
()
==
token
::
POUND_LT
)
{
p
.bump
();
ex
=
ast
::
expr_embeded_type
(
parse_ty
(
p
));
expect
(
p
,
token
::
GT
);
}
else
if
(
p
.peek
()
==
token
::
POUND_LBRACE
)
{
p
.bump
();
ex
=
ast
::
expr_embeded_block
(
parse_block_tail
(
p
));
}
else
if
(
p
.peek
()
==
token
::
TILDE
)
{
p
.bump
();
alt
(
p
.peek
())
{
...
...
@@ -1715,10 +1722,15 @@ fn stmt_ends_with_semi(&ast::stmt stmt) -> bool {
}
fn
parse_block
(
&
parser
p
)
->
ast
::
block
{
expect
(
p
,
token
::
LBRACE
);
be
parse_block_tail
(
p
);
}
// some blocks start with "#{"...
fn
parse_block_tail
(
&
parser
p
)
->
ast
::
block
{
auto
lo
=
p
.get_lo_pos
();
let
(
@
ast
::
stmt
)[]
stmts
=
~
[];
let
option
::
t
[
@
ast
::
expr
]
expr
=
none
;
expect
(
p
,
token
::
LBRACE
);
while
(
p
.peek
()
!=
token
::
RBRACE
)
{
alt
(
p
.peek
())
{
case
(
token
::
SEMI
)
{
...
...
@@ -2204,8 +2216,10 @@ fn parse_outer_attrs_or_ext(&parser p) -> attr_or_ext {
if
(
p
.peek
()
==
token
::
LBRACKET
)
{
auto
first_attr
=
parse_attribute_naked
(
p
,
ast
::
attr_outer
,
lo
);
ret
some
(
left
(
~
[
first_attr
]
+
parse_outer_attributes
(
p
)));
}
else
{
}
else
if
(
!
(
p
.peek
()
==
token
::
LT
||
p
.peek
()
==
token
::
LBRACKET
))
{
ret
some
(
right
(
parse_syntax_ext_naked
(
p
,
lo
)));
}
else
{
ret
none
;
}
}
else
{
ret
none
;
...
...
src/comp/syntax/parse/token.rs
浏览文件 @
80cf4ecd
...
...
@@ -60,6 +60,8 @@
LBRACE
;
RBRACE
;
POUND
;
POUND_LBRACE
;
POUND_LT
;
/* Literals */
LIT_INT
(
int
);
...
...
@@ -110,11 +112,8 @@ fn to_str(lexer::reader r, token t) -> str {
case
(
ANDAND
)
{
ret
"&&"
;
}
case
(
BINOP
(
?
op
))
{
ret
binop_to_str
(
op
);
}
case
(
BINOPEQ
(
?
op
))
{
ret
binop_to_str
(
op
)
+
"="
;
}
case
(
/* Structural symbols */
AT
)
{
ret
"@"
;
}
case
(
AT
)
{
ret
"@"
;
}
case
(
DOT
)
{
ret
"."
;
}
case
(
COMMA
)
{
ret
","
;
}
case
(
SEMI
)
{
ret
";"
;
}
...
...
@@ -133,11 +132,10 @@ fn to_str(lexer::reader r, token t) -> str {
case
(
LBRACE
)
{
ret
"{"
;
}
case
(
RBRACE
)
{
ret
"}"
;
}
case
(
POUND
)
{
ret
"#"
;
}
case
(
case
(
POUND_LBRACE
)
{
ret
"#{"
;
}
case
(
POUND_LT
)
{
ret
"#<"
;
}
/* Literals */
LIT_INT
(
?
i
))
{
ret
int
::
to_str
(
i
,
10u
);
}
case
(
LIT_INT
(
?
i
))
{
ret
int
::
to_str
(
i
,
10u
);
}
case
(
LIT_UINT
(
?
u
))
{
ret
uint
::
to_str
(
u
,
10u
);
}
case
(
LIT_MACH_INT
(
?
tm
,
?
i
))
{
ret
int
::
to_str
(
i
,
10u
)
+
"_"
+
ty_mach_to_str
(
tm
);
...
...
@@ -147,25 +145,19 @@ fn to_str(lexer::reader r, token t) -> str {
ty_mach_to_str
(
tm
);
}
case
(
LIT_FLOAT
(
?
s
))
{
ret
interner
::
get
[
str
](
*
r
.get_interner
(),
s
);
}
case
(
LIT_STR
(
?
s
))
{
// FIXME: escape.
case
(
LIT_STR
(
?
s
))
{
// FIXME: escape.
ret
"
\"
"
+
interner
::
get
[
str
](
*
r
.get_interner
(),
s
)
+
"
\"
"
;
}
case
(
LIT_CHAR
(
?
c
))
{
// FIXME: escape.
auto
tmp
=
"'"
;
str
::
push_char
(
tmp
,
c
);
str
::
push_byte
(
tmp
,
'\''
as
u8
);
ret
tmp
;
}
case
(
LIT_BOOL
(
?
b
))
{
if
(
b
)
{
ret
"true"
;
}
else
{
ret
"false"
;
}
}
case
(
/* Name components */
IDENT
(
?
s
,
_
))
{
ret
interner
::
get
[
str
](
*
r
.get_interner
(),
s
);
}
case
(
IDENT
(
?
s
,
_
))
{
ret
interner
::
get
[
str
](
*
r
.get_interner
(),
s
);
}
case
(
IDX
(
?
i
))
{
ret
"_"
+
int
::
to_str
(
i
,
10u
);
}
case
(
UNDERSCORE
)
{
ret
"_"
;
}
case
(
BRACEQUOTE
(
_
))
{
ret
"<bracequote>"
;
}
...
...
src/comp/syntax/visit.rs
浏览文件 @
80cf4ecd
...
...
@@ -397,6 +397,12 @@ fn visit_expr[E](&@expr ex, &E e, &vt[E] v) {
m
.node.id
,
e
,
v
);
}
}
case
(
expr_embeded_type
(
?
ty
))
{
vt
(
v
)
.visit_ty
(
ty
,
e
,
v
);
}
case
(
expr_embeded_block
(
?
blk
))
{
vt
(
v
)
.visit_block
(
blk
,
e
,
v
);
}
}
}
...
...
src/comp/syntax/walk.rs
浏览文件 @
80cf4ecd
...
...
@@ -410,6 +410,12 @@ fn walk_expr(&ast_visitor v, @ast::expr e) {
v
.visit_method_post
(
m
);
}
}
case
(
ast
::
expr_embeded_type
(
?
ty
))
{
walk_ty
(
v
,
ty
);
}
case
(
ast
::
expr_embeded_block
(
?
blk
))
{
walk_block
(
v
,
blk
);
}
}
v
.visit_expr_post
(
e
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录