diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-04-17 22:02:00 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-04-18 10:50:50 -0700 |
| commit | 2c0cb901c8ee464b9d5d4e069b98c692678b2ee7 (patch) | |
| tree | ea37dfde59d606b591e979eae6c41c5e0d1ad3c1 /src/librustsyntax/parse/classify.rs | |
| parent | d51973a6a66756c2f2cb7ab0649483ef41ba3050 (diff) | |
| download | rust-2c0cb901c8ee464b9d5d4e069b98c692678b2ee7.tar.gz rust-2c0cb901c8ee464b9d5d4e069b98c692678b2ee7.zip | |
syntax: Begin moving functions from mod parser to mod classify
Diffstat (limited to 'src/librustsyntax/parse/classify.rs')
| -rw-r--r-- | src/librustsyntax/parse/classify.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/librustsyntax/parse/classify.rs b/src/librustsyntax/parse/classify.rs new file mode 100644 index 00000000000..f2c9aece0c1 --- /dev/null +++ b/src/librustsyntax/parse/classify.rs @@ -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; + } + } +} |
