diff options
| author | bors <bors@rust-lang.org> | 2013-04-29 00:12:37 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-04-29 00:12:37 -0700 |
| commit | ea74f6845e08150e3b38766f57a4af928aea1376 (patch) | |
| tree | 7f595ee292241ed3520742a968e3f5077c687fd5 /src/libsyntax/parse/classify.rs | |
| parent | 7b7a0fc235cd2e0782302cd6fb83634e190b15b7 (diff) | |
| parent | cce13c18fe2f5c6dcd46f91a264cd99aa77f9135 (diff) | |
auto merge of #6083 : jbclements/rust/parser-cleanup, r=jbclements
r? @pcwalton A month's worth of parser cleanup here. Much of this is new comments and renaming. A number of these commits also remove unneeded code. Probably the biggest refactor here is splitting "parse_item_or_view_item" into two functions; it turns out that the only overlap between items in foreign modules and items in regular modules was macros, so this refactor should make things substantially easier for future maintenance.
Diffstat (limited to 'src/libsyntax/parse/classify.rs')
| -rw-r--r-- | src/libsyntax/parse/classify.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libsyntax/parse/classify.rs b/src/libsyntax/parse/classify.rs index 840fb891bff..e04914c0f1e 100644 --- a/src/libsyntax/parse/classify.rs +++ b/src/libsyntax/parse/classify.rs @@ -15,6 +15,13 @@ use ast; use codemap; +// does this expression require a semicolon to be treated +// as a statement? The negation of this: 'can this expression +// be used as a statement without a semicolon' -- is used +// as an early-bail-out in the parser so that, for instance, +// 'if true {...} else {...} +// |x| 5 ' +// isn't parsed as (if true {...} else {...} | x) | 5 pub fn expr_requires_semi_to_be_stmt(e: @ast::expr) -> bool { match e.node { ast::expr_if(*) @@ -40,6 +47,9 @@ pub fn expr_is_simple_block(e: @ast::expr) -> bool { } } +// this statement requires a semicolon after it. +// note that in one case (stmt_semi), we've already +// seen the semicolon, and thus don't need another. pub fn stmt_ends_with_semi(stmt: &ast::stmt) -> bool { return match stmt.node { ast::stmt_decl(d, _) => { |
