diff options
| author | John Clements <clements@racket-lang.org> | 2013-04-02 16:44:01 -0700 |
|---|---|---|
| committer | John Clements <clements@racket-lang.org> | 2013-04-28 09:51:16 -0700 |
| commit | 41af2792333fe739abb899c6815005b08674ff21 (patch) | |
| tree | 11747b5e61776b16fff33dcac286612a44b47dc8 /src/libsyntax/parse/classify.rs | |
| parent | 2985f74ff345638af2391a74b60e8e949691e694 (diff) | |
| download | rust-41af2792333fe739abb899c6815005b08674ff21.tar.gz rust-41af2792333fe739abb899c6815005b08674ff21.zip | |
parser comments
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, _) => { |
