From 41af2792333fe739abb899c6815005b08674ff21 Mon Sep 17 00:00:00 2001 From: John Clements Date: Tue, 2 Apr 2013 16:44:01 -0700 Subject: parser comments --- src/libsyntax/parse/classify.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/libsyntax/parse/classify.rs') 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, _) => { -- cgit 1.4.1-3-g733a5