syntax: Begin moving functions from mod parser to mod classify
This commit is contained in:
parent
d51973a6a6
commit
2c0cb901c8
4 changed files with 41 additions and 37 deletions
31
src/librustsyntax/parse/classify.rs
Normal file
31
src/librustsyntax/parse/classify.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
// FIXME: There are a bunch of similar functions in pprust that
|
||||
// likely belong here
|
||||
|
||||
fn expr_requires_semi_to_be_stmt(e: @ast::expr) -> bool {
|
||||
alt e.node {
|
||||
ast::expr_if(_, _, _) | ast::expr_if_check(_, _, _)
|
||||
| ast::expr_alt(_, _, _) | ast::expr_block(_)
|
||||
| ast::expr_do_while(_, _) | ast::expr_while(_, _)
|
||||
| ast::expr_loop(_) | ast::expr_call(_, _, true) {
|
||||
false
|
||||
}
|
||||
_ { true }
|
||||
}
|
||||
}
|
||||
|
||||
fn stmt_ends_with_semi(stmt: ast::stmt) -> bool {
|
||||
alt stmt.node {
|
||||
ast::stmt_decl(d, _) {
|
||||
ret alt d.node {
|
||||
ast::decl_local(_) { true }
|
||||
ast::decl_item(_) { false }
|
||||
}
|
||||
}
|
||||
ast::stmt_expr(e, _) {
|
||||
ret expr_requires_semi_to_be_stmt(e);
|
||||
}
|
||||
ast::stmt_semi(e, _) {
|
||||
ret false;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue